Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e: delete duplicate log data on e2e-test failure #1297

Merged
merged 1 commit into from
Aug 30, 2022

Conversation

AlinsRan
Copy link
Contributor

@AlinsRan AlinsRan commented Aug 30, 2022

Type of change:

  • Bugfix
  • New feature provided
  • Improve performance
  • Backport patches

What this PR does / why we need it:

func (s *Scaffold) afterEach() {
	defer ginkgo.GinkgoRecover()

	if ginkgo.CurrentSpecReport().Failed() {
		if os.Getenv("E2E_ENV") == "ci" {
			// dump and delete related resource
			_, _ = 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)
			}
			// Get the logs of apisix
			output = s.GetDeploymentLogs("apisix-deployment-e2e-test")
			if output != "" {
				_, _ = fmt.Fprintln(ginkgo.GinkgoWriter, output)
			}
			// Get the logs of ingress
			output = s.GetDeploymentLogs("ingress-apisix-controller-deployment-e2e-test")
			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)
		}
	} else {
		// if the test case is successful, just delete namespace
		err := k8s.DeleteNamespaceE(s.t, s.kubectlOptions, s.namespace)
		assert.Nilf(ginkgo.GinkgoT(), err, "deleting namespace %s", s.namespace)
	}

	for _, f := range s.finializers {
		runWithRecover(f)
	}

	// Wait for a while to prevent the worker node being overwhelming
	// (new cases will be run).
	time.Sleep(3 * time.Second)
}
  1. k8s.RunKubectlAndGetOutputE Etc, the interface will print the log (terratest.logger).
  2. fmt.Fprintln(ginkgo.GinkgoWriter, output) also prints log (ginkgo.logger).
  3. At this time, two identical log data will be generated

solve:

  • Disable logging of terratest library.

Pre-submission checklist:

  • Did you explain what problem does this PR solve? Or what new features have been added?
  • Have you added corresponding test cases?
  • Have you modified the corresponding document?
  • Is this PR backward compatible? If it is not backward compatible, please discuss on the mailing list first

@AlinsRan AlinsRan changed the title e2e: delete duplicate log data on failure e2e: delete duplicate log data on e2e-test failure Aug 30, 2022
@tao12345666333 tao12345666333 added this to the v1.6.0 milestone Aug 30, 2022
@tao12345666333 tao12345666333 merged commit 6b86d2a into apache:master Aug 30, 2022
@AlinsRan AlinsRan deleted the e2e/log branch September 2, 2022 01:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

None yet

3 participants