Skip to content

Commit

Permalink
[E2E VM Test] Increase timeout for sftp deployment to become ready (a…
Browse files Browse the repository at this point in the history
…ntrea-io#5405)

Sometimes the image can take a long time to pull from Harbor, and 30s
may not be enough.

Also improve logging to make future issues easier to troubleshoot.

Signed-off-by: Antonin Bas <abas@vmware.com>
  • Loading branch information
antoninbas authored Aug 18, 2023
1 parent 5199aa3 commit c421847
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions test/e2e/vmagent_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,16 +82,20 @@ func TestVMAgent(t *testing.T) {
t.Run("testExternalNodeSupportBundleCollection", func(t *testing.T) { testExternalNodeSupportBundleCollection(t, data, vmList) })
}

func (data *TestData) waitForDeploymentRealized(t *testing.T, namespace string, name string, timeout time.Duration) error {
t.Logf("Waiting for Deployment '%s/%s' to be realized", namespace, name)
if err := wait.Poll(100*time.Millisecond, timeout, func() (bool, error) {
func (data *TestData) waitForDeploymentReady(t *testing.T, namespace string, name string, timeout time.Duration) error {
t.Logf("Waiting for Deployment '%s/%s' to be ready", namespace, name)
err := wait.Poll(1*time.Second, timeout, func() (bool, error) {
dp, err := data.clientset.AppsV1().Deployments(namespace).Get(context.TODO(), name, metav1.GetOptions{})
if err != nil {
return false, err
}
return dp.Status.ObservedGeneration == dp.Generation && dp.Status.ReadyReplicas == *dp.Spec.Replicas, nil
}); err != nil {
return fmt.Errorf("error when waiting for Deployment '%s/%s' to be realized: %v", namespace, name, err)
})
if err == wait.ErrWaitTimeout {
_, stdout, _, _ := data.provider.RunCommandOnNode(controlPlaneNodeName(), fmt.Sprintf("kubectl -n %s describe pod -l app=sftp", namespace))
return fmt.Errorf("some replicas for Deployment '%s/%s' are not ready after %v:\n%v", namespace, name, timeout, stdout)
} else if err != nil {
return fmt.Errorf("error when waiting for Deployment '%s/%s' to be ready: %w", namespace, name, err)
}
return nil
}
Expand Down Expand Up @@ -133,6 +137,7 @@ func testExternalNodeSupportBundleCollection(t *testing.T, data *TestData, vmLis
}
applySFTPYamlCommand := fmt.Sprintf("kubectl apply -f %s -n %s", sftpServiceYAML, data.testNamespace)
code, stdout, stderr, err := data.RunCommandOnNode(controlPlaneNodeName(), applySFTPYamlCommand)
require.NoError(t, err)
defer func() {
deleteSFTPYamlCommand := fmt.Sprintf("kubectl delete -f %s -n %s", sftpServiceYAML, data.testNamespace)
data.RunCommandOnNode(controlPlaneNodeName(), deleteSFTPYamlCommand)
Expand All @@ -141,8 +146,7 @@ func testExternalNodeSupportBundleCollection(t *testing.T, data *TestData, vmLis
if code != 0 {
t.Errorf("Error when applying %s: %v", sftpServiceYAML, stderr)
}
require.NoError(t, err)
failOnError(data.waitForDeploymentRealized(t, data.testNamespace, "sftp", 30*time.Second), t)
failOnError(data.waitForDeploymentReady(t, data.testNamespace, "sftp", defaultTimeout), t)
sec := &v1.Secret{
ObjectMeta: metav1.ObjectMeta{
Name: secretName,
Expand Down

0 comments on commit c421847

Please sign in to comment.