Skip to content

Commit

Permalink
test: dump the namespace content when e2e test cases failed (#571)
Browse files Browse the repository at this point in the history
* chore: fix the count field type in apisix client

* fix: show k8s nodes

* change: kind version
  • Loading branch information
tokers committed Jul 5, 2021
1 parent dbc8133 commit c871bdf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
6 changes: 5 additions & 1 deletion .github/workflows/e2e-test-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ jobs:
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
Expand All @@ -84,6 +84,10 @@ jobs:
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: |
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/scaffold/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,12 +150,12 @@ func (s *Scaffold) ensureNumApisixCRDsCreated(url string, desired int) error {
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
}
Expand Down
13 changes: 13 additions & 0 deletions test/e2e/scaffold/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,19 @@ func (s *Scaffold) beforeEach() {

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)

Expand Down

0 comments on commit c871bdf

Please sign in to comment.