Merge pull request #234 from jakalkhalili/master
Adjust timeout for user configuration in e2e tests
This commit is contained in:
		
						commit
						cbda28a6cb
					
				|  | @ -27,7 +27,7 @@ func TestConfiguration(t *testing.T) { | ||||||
| 	namespace, ctx := setupTest(t) | 	namespace, ctx := setupTest(t) | ||||||
| 
 | 
 | ||||||
| 	defer showLogsAndCleanup(t, ctx) | 	defer showLogsAndCleanup(t, ctx) | ||||||
|    | 
 | ||||||
| 	jenkinsCRName := "e2e" | 	jenkinsCRName := "e2e" | ||||||
| 	numberOfExecutors := 6 | 	numberOfExecutors := 6 | ||||||
| 	numberOfExecutorsEnvName := "NUMBER_OF_EXECUTORS" | 	numberOfExecutorsEnvName := "NUMBER_OF_EXECUTORS" | ||||||
|  |  | ||||||
|  | @ -126,18 +126,22 @@ func printKubernetesPods(t *testing.T, namespace string) { | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func showLogsAndCleanup(t *testing.T, ctx *framework.TestCtx) { | func showLogsAndCleanup(t *testing.T, ctx *framework.TestCtx) { | ||||||
|  | 	namespace, err := ctx.GetNamespace() | ||||||
|  | 	if err != nil { | ||||||
|  | 		t.Fatalf("Failed to get '%s' namespace", err) | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
| 	if t.Failed() { | 	if t.Failed() { | ||||||
| 		t.Log("Test failed. Bellow here you can check logs:") | 		t.Log("Test failed. Bellow here you can check logs:") | ||||||
| 
 | 
 | ||||||
| 		namespace, err := ctx.GetNamespace() |  | ||||||
| 		if err != nil { |  | ||||||
| 			t.Fatalf("Failed to get '%s' namespace", err) |  | ||||||
| 		} |  | ||||||
| 
 |  | ||||||
| 		printOperatorLogs(t, namespace) | 		printOperatorLogs(t, namespace) | ||||||
| 		printKubernetesEvents(t, namespace) | 		printKubernetesEvents(t, namespace) | ||||||
| 		printKubernetesPods(t, namespace) | 		printKubernetesPods(t, namespace) | ||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	ctx.Cleanup() | 	ctx.Cleanup() | ||||||
|  | 	err = waitUntilNamespaceDestroyed(namespace) | ||||||
|  | 	if err != nil { | ||||||
|  | 		t.Fatalf("Failed to wait for namespace until destroyed '%s'", err) | ||||||
|  | 	} | ||||||
| } | } | ||||||
|  |  | ||||||
|  | @ -38,7 +38,7 @@ func TestBackupAndRestore(t *testing.T) { | ||||||
| 	i, err := job.InvokeSimple(map[string]string{}) | 	i, err := job.InvokeSimple(map[string]string{}) | ||||||
| 	require.NoError(t, err, i) | 	require.NoError(t, err, i) | ||||||
| 	// FIXME: waitForJobToFinish use
 | 	// FIXME: waitForJobToFinish use
 | ||||||
| 	time.Sleep(120 * time.Second) // wait for the build to complete
 | 	time.Sleep(80 * time.Second) // wait for the build to complete
 | ||||||
| 
 | 
 | ||||||
| 	restartJenkinsMasterPod(t, jenkins) | 	restartJenkinsMasterPod(t, jenkins) | ||||||
| 	waitForRecreateJenkinsMasterPod(t, jenkins) | 	waitForRecreateJenkinsMasterPod(t, jenkins) | ||||||
|  |  | ||||||
|  | @ -2,6 +2,7 @@ package e2e | ||||||
| 
 | 
 | ||||||
| import ( | import ( | ||||||
| 	goctx "context" | 	goctx "context" | ||||||
|  | 	"golang.org/x/net/context" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| 	"testing" | 	"testing" | ||||||
| 	"time" | 	"time" | ||||||
|  | @ -16,10 +17,12 @@ import ( | ||||||
| 	"github.com/pkg/errors" | 	"github.com/pkg/errors" | ||||||
| 	"github.com/stretchr/testify/assert" | 	"github.com/stretchr/testify/assert" | ||||||
| 	"github.com/stretchr/testify/require" | 	"github.com/stretchr/testify/require" | ||||||
|  | 	v1 "k8s.io/api/core/v1" | ||||||
| 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" | ||||||
| 	"k8s.io/apimachinery/pkg/labels" | 	"k8s.io/apimachinery/pkg/labels" | ||||||
| 	"k8s.io/apimachinery/pkg/types" | 	"k8s.io/apimachinery/pkg/types" | ||||||
| 	"k8s.io/apimachinery/pkg/util/wait" | 	"k8s.io/apimachinery/pkg/util/wait" | ||||||
|  | 	"sigs.k8s.io/controller-runtime/pkg/client" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| var ( | var ( | ||||||
|  | @ -92,7 +95,7 @@ func waitForRecreateJenkinsMasterPod(t *testing.T, jenkins *v1alpha2.Jenkins) { | ||||||
| 
 | 
 | ||||||
| func waitForJenkinsUserConfigurationToComplete(t *testing.T, jenkins *v1alpha2.Jenkins) { | func waitForJenkinsUserConfigurationToComplete(t *testing.T, jenkins *v1alpha2.Jenkins) { | ||||||
| 	t.Log("Waiting for Jenkins user configuration to complete") | 	t.Log("Waiting for Jenkins user configuration to complete") | ||||||
| 	_, err := WaitUntilJenkinsConditionSet(retryInterval, 70, jenkins, func(jenkins *v1alpha2.Jenkins, err error) bool { | 	_, err := WaitUntilJenkinsConditionSet(retryInterval, 80, jenkins, func(jenkins *v1alpha2.Jenkins, err error) bool { | ||||||
| 		t.Logf("Current Jenkins status: '%+v', error '%s'", jenkins.Status, err) | 		t.Logf("Current Jenkins status: '%+v', error '%s'", jenkins.Status, err) | ||||||
| 		return err == nil && jenkins.Status.UserConfigurationCompletedTime != nil | 		return err == nil && jenkins.Status.UserConfigurationCompletedTime != nil | ||||||
| 	}) | 	}) | ||||||
|  | @ -129,3 +132,25 @@ func WaitUntilJenkinsConditionSet(retryInterval time.Duration, retries int, jenk | ||||||
| 	} | 	} | ||||||
| 	return jenkinsStatus, nil | 	return jenkinsStatus, nil | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | func waitUntilNamespaceDestroyed(namespace string) error { | ||||||
|  | 	err := try.Until(func() (bool, error) { | ||||||
|  | 		var namespaceList v1.NamespaceList | ||||||
|  | 		err := framework.Global.Client.List(context.TODO(), &client.ListOptions{}, &namespaceList) | ||||||
|  | 		if err != nil { | ||||||
|  | 			return true, err | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		exists := false | ||||||
|  | 		for _, namespaceItem := range namespaceList.Items { | ||||||
|  | 			if namespaceItem.Name == namespace { | ||||||
|  | 				exists = true | ||||||
|  | 				break | ||||||
|  | 			} | ||||||
|  | 		} | ||||||
|  | 
 | ||||||
|  | 		return !exists, nil | ||||||
|  | 	}, time.Second, time.Second*120) | ||||||
|  | 
 | ||||||
|  | 	return err | ||||||
|  | } | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue