Skip to content

Commit

Permalink
round 3: e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
okokes-akamai committed Dec 22, 2023
1 parent d1f9e07 commit ab8260f
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ linters:
- typecheck
- unused
# cherry picked from https://golangci-lint.run/usage/linters/
- ginkgolinter
# - ginkgolinter # to be enabled once #158 is merged
- bodyclose
- exportloopref
- gocheckcompilerdirectives
Expand Down
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ codegen:
lint:
docker run --rm -v "$(shell pwd):/var/work:ro" -w /var/work \
golangci/golangci-lint:v1.55.2 golangci-lint run -v --timeout=5m
docker run --rm -v "$(shell pwd):/var/work:ro" -w /var/work/e2e \
golangci/golangci-lint:v1.55.2 golangci-lint run -v --timeout=5m

.PHONY: fmt
fmt:
Expand Down
9 changes: 4 additions & 5 deletions e2e/test/ccm_e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ package test

import (
"context"
"e2e_test/test/framework"
"fmt"
"strconv"

"e2e_test/test/framework"

"github.com/codeskyblue/go-sh"
"github.com/linode/linodego"
. "github.com/onsi/ginkgo/v2"
Expand Down Expand Up @@ -97,13 +96,13 @@ var _ = Describe("e2e tests", func() {
ensureServiceLoadBalancer()
}

createServiceWithAnnotations := func(labels map[string]string, annotations map[string]string, ports []core.ServicePort, isSessionAffinityClientIP bool) {
createServiceWithAnnotations := func(labels, annotations map[string]string, ports []core.ServicePort, isSessionAffinityClientIP bool) {
Expect(f.LoadBalancer.CreateService(labels, annotations, ports, isSessionAffinityClientIP)).NotTo(HaveOccurred())
Eventually(f.LoadBalancer.GetServiceEndpoints).Should(Not(BeEmpty()))
ensureServiceLoadBalancer()
}

updateServiceWithAnnotations := func(labels map[string]string, annotations map[string]string, ports []core.ServicePort, isSessionAffinityClientIP bool) {
updateServiceWithAnnotations := func(labels, annotations map[string]string, ports []core.ServicePort, isSessionAffinityClientIP bool) {
Expect(f.LoadBalancer.UpdateService(labels, annotations, ports, isSessionAffinityClientIP)).NotTo(HaveOccurred())
Eventually(f.LoadBalancer.GetServiceEndpoints).Should(Not(BeEmpty()))
ensureServiceLoadBalancer()
Expand All @@ -116,7 +115,7 @@ var _ = Describe("e2e tests", func() {
createNodeBalancer := func() int {
var nb *linodego.NodeBalancer
nb, err = getLinodeClient().CreateNodeBalancer(context.TODO(), linodego.NodeBalancerCreateOptions{
Region: fmt.Sprintf("%s", region),
Region: region,
})
Expect(err).NotTo(HaveOccurred())
Expect(nb).NotTo(BeNil())
Expand Down
3 changes: 1 addition & 2 deletions e2e/test/ccm_suite_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package test

import (
"e2e_test/test/framework"
"flag"
"os"
"path/filepath"
"testing"
"time"

"e2e_test/test/framework"

"github.com/linode/linodego"

"github.com/appscode/go/crypto/rand"
Expand Down
14 changes: 1 addition & 13 deletions e2e/test/framework/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import (
"github.com/pkg/errors"
core "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/util/intstr"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/client-go/util/retry"
)

func (i *lbInvocation) createOrUpdateService(selector, annotations map[string]string, ports []core.ServicePort, isSessionAffinityClientIP bool, isCreate bool) error {
func (i *lbInvocation) createOrUpdateService(selector, annotations map[string]string, ports []core.ServicePort, isSessionAffinityClientIP, isCreate bool) error {
var sessionAffinity core.ServiceAffinity = "None"
if isSessionAffinityClientIP {
sessionAffinity = "ClientIP"
Expand Down Expand Up @@ -133,14 +132,3 @@ func (i *lbInvocation) getServiceIngress(name, namespace string) ([]core.LoadBal
}
return svc.Status.LoadBalancer.Ingress, nil
}

func (i *lbInvocation) testServerServicePorts() []core.ServicePort {
return []core.ServicePort{
{
Name: "http-1",
Port: 80,
TargetPort: intstr.FromInt(8080),
Protocol: "TCP",
},
}
}
3 changes: 1 addition & 2 deletions e2e/test/framework/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ func runCommand(cmd string, args ...string) error {
c := exec.Command(cmd, args...)
c.Stdout = os.Stdout
c.Stderr = os.Stderr
c.Env = append(c.Env, append(os.Environ())...)
glog.Infof("Running command %q\n", cmd)
return c.Run()
}
Expand Down Expand Up @@ -146,7 +145,7 @@ func WaitForHTTPSResponse(link string) (string, error) {
if err != nil {
return "", err
}
return string(resp), nil
return resp, nil
}

func getHTTPResponse(link string) (bool, string, error) {
Expand Down

0 comments on commit ab8260f

Please sign in to comment.