test: dump the namespace content when e2e test cases failed (#571)
* chore: fix the count field type in apisix client
* fix: show k8s nodes
* change: kind version
diff --git a/.github/workflows/e2e-test-ci.yml b/.github/workflows/e2e-test-ci.yml
index a05bc85..4cc767c 100644
--- a/.github/workflows/e2e-test-ci.yml
+++ b/.github/workflows/e2e-test-ci.yml
@@ -73,7 +73,7 @@
submodules: recursive
- name: Install kind
run: |
- curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.10.0/kind-linux-amd64
+ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.11.1/kind-linux-amd64
chmod +x ./kind
sudo mv kind /usr/local/bin
- name: Setup Go Env
@@ -84,6 +84,10 @@
run: |
go get -u github.com/onsi/ginkgo/ginkgo
sudo cp ~/go/bin/ginkgo /usr/local/bin
+ - name: Create K8s cluster
+ run: |
+ make kind-up
+ kubectl wait --for=condition=Ready nodes --all
- name: Run e2e test cases
working-directory: ./
run: |
diff --git a/test/e2e/scaffold/k8s.go b/test/e2e/scaffold/k8s.go
index 40e6c76..4517bda 100644
--- a/test/e2e/scaffold/k8s.go
+++ b/test/e2e/scaffold/k8s.go
@@ -150,12 +150,12 @@
ginkgo.GinkgoT().Logf("got status code %d from APISIX", resp.StatusCode)
return false, nil
}
- c := &counter{}
+ var c counter
b, err := ioutil.ReadAll(resp.Body)
if err != nil {
return false, err
}
- err = json.Unmarshal(b, c)
+ err = json.Unmarshal(b, &c)
if err != nil {
return false, err
}
diff --git a/test/e2e/scaffold/scaffold.go b/test/e2e/scaffold/scaffold.go
index 2e0998c..a1c8dd2 100644
--- a/test/e2e/scaffold/scaffold.go
+++ b/test/e2e/scaffold/scaffold.go
@@ -299,6 +299,19 @@
func (s *Scaffold) afterEach() {
defer ginkgo.GinkgoRecover()
+
+ if ginkgo.CurrentGinkgoTestDescription().Failed {
+ fmt.Fprintln(ginkgo.GinkgoWriter, "Dumping namespace contents")
+ output, _ := k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), s.kubectlOptions, "get", "deploy,sts,svc,pods")
+ if output != "" {
+ fmt.Fprintln(ginkgo.GinkgoWriter, output)
+ }
+ output, _ = k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), s.kubectlOptions, "describe", "pods")
+ if output != "" {
+ fmt.Fprintln(ginkgo.GinkgoWriter, output)
+ }
+ }
+
err := k8s.DeleteNamespaceE(s.t, s.kubectlOptions, s.namespace)
assert.Nilf(ginkgo.GinkgoT(), err, "deleting namespace %s", s.namespace)