You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by "AlinsRan (via GitHub)" <gi...@apache.org> on 2023/04/14 07:13:18 UTC

[GitHub] [apisix-ingress-controller] AlinsRan opened a new issue, #1792: e2e: check if the controller is restarted

AlinsRan opened a new issue, #1792:
URL: https://github.com/apache/apisix-ingress-controller/issues/1792

   At the end of each e2e use case, detect if the controller has restarted.
   
   To avoid incorrect coding causing the controller to crash and restart and make the test cases pass, we should detect and report it when cleaning up the cases.
   
   Can be detected in the `afterEach` https://github.com/apache/apisix-ingress-controller/blob/master/test/e2e/scaffold/scaffold.go#L503.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] ps-19 commented on issue #1792: e2e: check if the controller is restarted

Posted by "ps-19 (via GitHub)" <gi...@apache.org>.
ps-19 commented on issue #1792:
URL: https://github.com/apache/apisix-ingress-controller/issues/1792#issuecomment-1512467236

   I have a solution for this issue, but I am struggling with the testing part.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #1792: e2e: check if the controller is restarted

Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on issue #1792:
URL: https://github.com/apache/apisix-ingress-controller/issues/1792#issuecomment-1512490873

   You can submit your changes through PR instead of pasting the code directly into the issue. Thanks


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] tao12345666333 commented on issue #1792: e2e: check if the controller is restarted

Posted by "tao12345666333 (via GitHub)" <gi...@apache.org>.
tao12345666333 commented on issue #1792:
URL: https://github.com/apache/apisix-ingress-controller/issues/1792#issuecomment-1512486225

   Very glad that you are interested in this, I have already assigned this issue to you.
   
   FYI: https://github.com/apache/apisix-ingress-controller/tree/master/test/e2e
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [apisix-ingress-controller] ps-19 commented on issue #1792: e2e: check if the controller is restarted

Posted by "ps-19 (via GitHub)" <gi...@apache.org>.
ps-19 commented on issue #1792:
URL: https://github.com/apache/apisix-ingress-controller/issues/1792#issuecomment-1512488436

   ```
   func (s *Scaffold) GetDeploymentRestartCount(deploymentName string) (int32, error) {
           deployment, err := s.kubectlOptions.Namespace(s.namespace).GetDeployment(deploymentName)
           if err != nil {
    return 0, err
           }
           return (deployment.Status.Replicas - deployment.Status.ReadyReplicas), nil
   }
   func (s *Scaffold) afterEach() {
           defer ginkgo.GinkgoRecover()
           // The controller has restarted checking
           restartCount, err := s.GetDeploymentRestartCount("ingress-apisix-controller-deployment-e2e-test")
           if err != nil {
    ginkgo.Fail(fmt.Sprintf("Failed to get restart count for controller deployment: %v", err))
           } else if restartCount > 0 {
    ginkgo.Fail(fmt.Sprintf("Controller deployment has restarted %d times", restartCount))
           }
           if ginkgo.CurrentSpecReport().Failed() {
    // dump and delete related resource
    env := os.Getenv("E2E_ENV")
    if env == "ci" || env == "debug" {
    _, _ = 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)
    }
    if s.opts.EnableWebhooks {
    output, _ = k8s.RunKubectlAndGetOutputE(ginkgo.GinkgoT(), s.kubectlOptions, "get", "validatingwebhookconfigurations", "-o", "yaml")
    if output != "" {
    _, _ = fmt.Fprintln(ginkgo.GinkgoWriter, output)
    }
    }
    }
    if env != "debug" {
    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.finalizers {
    runWithRecover(f)
           }
           // Wait for a while to prevent the worker node being overwhelming
           // (new cases will be run).
           time.Sleep(3 * time.Second)
   }
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org