Skip to content

Commit 2520087

Browse files
e2e tests maintenance (#158)
The following has been done: - Ginkgo is properly installed if missing - Old README is removed, a TBD is placed - Removed unused terraform installation - Removed github.com/pkg/errors - Remove --progress Did _not_ do: - Update Go in go.mod - Bump deps for ginkgo and gomega - could not because of other old dependencies - Run tests in parallel - we don't have them set up for that (is that even possible?) - Added golangci-lint for our tests directory
1 parent 8c37946 commit 2520087

6 files changed

Lines changed: 12 additions & 85 deletions

File tree

e2e/Makefile

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
export GO111MODULE=on
21
IMG ?= linode/linode-cloud-controller-manager:latest
2+
GINKGO_PATH := $(shell go env GOPATH)/bin/ginkgo
33

44
REUSED_KUBECONFIG := test/ccm-linode-for-reuse.conf
55

66
ifneq ("$(wildcard $(REUSED_KUBECONFIG))","")
77
CONTROL_PLANE_IP := $(shell grep -E -o "([0-9]{1,3}[\.]){3}[0-9]{1,3}" $(REUSED_KUBECONFIG))
88
endif
99

10-
imports: $(GOPATH)/bin/goimports
11-
goimports -w test
12-
1310
.PHONY: test reuse-and-test clean
1411

12+
${GINKGO_PATH}:
13+
go install github.com/onsi/ginkgo/v2/ginkgo@v2.3.1
14+
1515
reuse-and-test: SUITE_ARGS='--reuse'
1616

17-
test reuse-and-test: $(GOPATH)/bin/ginkgo check-token
17+
test reuse-and-test: ${GINKGO_PATH} check-token
1818
go list -m; \
19-
ginkgo -r --v --progress --trace --cover $(TEST_ARGS) -- --v=3 --image=${IMG} $(SUITE_ARGS)
19+
ginkgo -r --v --trace --cover $(TEST_ARGS) -- --v=3 --image=${IMG} $(SUITE_ARGS)
2020

2121
clean: check-token
2222
cd test; \
@@ -30,11 +30,5 @@ check-token:
3030
exit 1; \
3131
fi
3232

33-
install-terraform:
34-
sudo apt-get install wget unzip
35-
wget https://releases.hashicorp.com/terraform/0.11.13/terraform_0.11.13_linux_amd64.zip
36-
unzip terraform_0.11.13_linux_amd64.zip
37-
sudo mv terraform /usr/local/bin/
38-
3933
control-plane-ssh: $(REUSED_KUBECONFIG)
4034
ssh root@$(CONTROL_PLANE_IP)

e2e/README.md

Lines changed: 2 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,4 @@
11
## How to run these End-to-end (e2e) tests
22

3-
Install the following packages (macOS examples)
4-
5-
```
6-
brew install terraform
7-
brew install kubectl
8-
brew install hg
9-
brew install golang
10-
```
11-
12-
Add the following environment variables to your shell rc
13-
14-
```
15-
export LINODE_API_TOKEN=<your linode API token>
16-
17-
export GOPATH=$HOME/go
18-
export PATH=$HOME/go/bin:$PATH
19-
export GO111MODULE=on
20-
```
21-
22-
If you need a Linode API token visit this page:
23-
https://cloud.linode.com/profile/tokens
24-
25-
Then, `go get` this repo
26-
`go get github.com/linode/linode-cloud-controller-manager`
27-
28-
That may fail, if it does, navigate to the directory that was created and run `go mod tidy`:
29-
30-
```
31-
cd ~/go/src/github.com/linode/linode-cloud-controller-manager
32-
go mod tidy
33-
```
34-
35-
Then, use the makefile in the directory above this directory to build the CCM (this is to download goimports)
36-
37-
```
38-
cd $GOPATH/src/github.com/linode/linode-cloud-controller-manager
39-
make build
40-
```
41-
42-
By default the tests use $HOME/.ssh/id\_rsa.pub as the public key used to provision the cluster, so it needs to be added to your agent.
43-
44-
```
45-
ssh-add $HOME/.ssh/id_rsa
46-
```
47-
48-
Come back here and run the tests
49-
50-
```
51-
cd e2e
52-
make test
53-
```
54-
55-
To save time on multiple runs by allowing the cluster to remain, use `make reuse-and-test`
56-
57-
### Generating a new server certificate for testing
58-
59-
Some of the tests require a secret containing a TLS certificate, for use in creating or updating a NodeBalancer config using TLS. A CA certificate and server certificate can be found in the `test/certificates` directory. The server certificate, used for TLS NodeBalancer configs, has an expiry of 4 years. You can use the following command to generate a new TLS certificate, using the existing CSR:
60-
61-
```
62-
openssl x509 -req -in test/certificates/server.csr -CA test/certificates/ca.crt -CAkey test/certificates/ca.key -CAcreateserial -out test/certificates/server.crt -days 1440 -sha256 -extfile <(printf "subjectAltName=DNS:linode.test,DNS:www.linode.test")
63-
```
64-
Once a new cert is generated, you will need to replace the existing constants, "serverCert" and "serverKey", in test/framework/secret.go.
3+
TBD: the way we run these e2e tests has recently changed, there is currently
4+
no convenient way to run these with no pre-existing clusters.

e2e/go.mod

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ go 1.17
44

55
require (
66
github.com/appscode/go v0.0.0-20200323182826-54e98e09185a
7-
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27
87
github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b
98
github.com/linode/linodego v0.21.1
109
github.com/onsi/ginkgo/v2 v2.3.1
1110
github.com/onsi/gomega v1.22.0
12-
github.com/pkg/errors v0.9.1
1311
k8s.io/api v0.19.2
1412
k8s.io/apimachinery v0.19.2
1513
k8s.io/client-go v0.19.2
1614
)
1715

1816
require (
19-
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 // indirect
2017
github.com/davecgh/go-spew v1.1.1 // indirect
2118
github.com/go-logr/logr v0.2.0 // indirect
2219
github.com/go-resty/resty/v2 v2.1.1-0.20191201195748-d7b97669fe48 // indirect

e2e/go.sum

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,7 @@ github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWR
3636
github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI=
3737
github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU=
3838
github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw=
39-
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0 h1:sDMmm+q/3+BukdIpxwO365v/Rbspp2Nt5XntgQRXq8Q=
4039
github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM=
41-
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27 h1:HHUr4P/aKh4quafGxDT9LDasjGdlGkzLbfmmrlng3kA=
4240
github.com/codeskyblue/go-sh v0.0.0-20190412065543-76bd3d59ff27/go.mod h1:VQx0hjo2oUeQkQUET7wRwradO6f+fN5jzXgB/zROxxE=
4341
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
4442
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
@@ -176,7 +174,6 @@ github.com/onsi/gomega v1.22.0 h1:AIg2/OntwkBiCg5Tt1ayyiF1ArFrWFoCSMtMi/wdApk=
176174
github.com/onsi/gomega v1.22.0/go.mod h1:iYAIXgPSaDHak0LCMA+AWBpIKBr8WZicMxnE8luStNc=
177175
github.com/peterbourgon/diskv v2.0.1+incompatible/go.mod h1:uqqh8zWWbv1HBMNONnaR/tNboyR3/BZd58JJSHlUSCU=
178176
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
179-
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
180177
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
181178
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
182179
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=

e2e/test/ccm_e2e_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import (
44
"context"
55
"e2e_test/test/framework"
66
"fmt"
7+
"os/exec"
78
"strconv"
89

9-
"github.com/codeskyblue/go-sh"
1010
"github.com/linode/linodego"
1111
. "github.com/onsi/ginkgo/v2"
1212
. "github.com/onsi/gomega"
@@ -231,12 +231,12 @@ var _ = Describe("e2e tests", func() {
231231
}
232232

233233
var addNewNode = func() {
234-
_, err := sh.Command("terraform", "apply", "-var", "nodes=3", "-auto-approve").Output()
234+
err := exec.Command("terraform", "apply", "-var", "nodes=3", "-auto-approve").Run()
235235
Expect(err).NotTo(HaveOccurred())
236236
}
237237

238238
var deleteNewNode = func() {
239-
_, err := sh.Command("terraform", "apply", "-var", "nodes=2", "-auto-approve").Output()
239+
err := exec.Command("terraform", "apply", "-var", "nodes=2", "-auto-approve").Run()
240240
Expect(err).NotTo(HaveOccurred())
241241
}
242242

e2e/test/framework/service.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"fmt"
66

7-
"github.com/pkg/errors"
87
core "k8s.io/api/core/v1"
98
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
109
"k8s.io/apimachinery/pkg/util/intstr"
@@ -117,7 +116,7 @@ func (i *lbInvocation) GetLoadBalancerIps() ([]string, error) {
117116
}
118117
}
119118
if serverAddr == nil {
120-
return nil, errors.Errorf("failed to get Status.LoadBalancer.Ingress for service %s/%s", TestServerResourceName, i.Namespace())
119+
return nil, fmt.Errorf("failed to get Status.LoadBalancer.Ingress for service %s/%s", TestServerResourceName, i.Namespace())
121120
}
122121
return serverAddr, nil
123122
}

0 commit comments

Comments
 (0)