Adjust timeouts for jobs, user configuration. Add waiting mechanism for namespace removal
This commit is contained in:
parent
ed5a59655c
commit
cdde6acec3
|
|
@ -27,7 +27,7 @@ func TestConfiguration(t *testing.T) {
|
|||
namespace, ctx := setupTest(t)
|
||||
|
||||
defer showLogsAndCleanup(t, ctx)
|
||||
|
||||
|
||||
jenkinsCRName := "e2e"
|
||||
numberOfExecutors := 6
|
||||
numberOfExecutorsEnvName := "NUMBER_OF_EXECUTORS"
|
||||
|
|
|
|||
|
|
@ -126,18 +126,22 @@ func printKubernetesPods(t *testing.T, namespace string) {
|
|||
}
|
||||
|
||||
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() {
|
||||
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)
|
||||
printKubernetesEvents(t, namespace)
|
||||
printKubernetesPods(t, namespace)
|
||||
}
|
||||
|
||||
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{})
|
||||
require.NoError(t, err, i)
|
||||
// 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)
|
||||
waitForRecreateJenkinsMasterPod(t, jenkins)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package e2e
|
|||
|
||||
import (
|
||||
goctx "context"
|
||||
"golang.org/x/net/context"
|
||||
"net/http"
|
||||
"testing"
|
||||
"time"
|
||||
|
|
@ -16,10 +17,12 @@ import (
|
|||
"github.com/pkg/errors"
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
"k8s.io/apimachinery/pkg/util/wait"
|
||||
"sigs.k8s.io/controller-runtime/pkg/client"
|
||||
)
|
||||
|
||||
var (
|
||||
|
|
@ -92,7 +95,7 @@ func waitForRecreateJenkinsMasterPod(t *testing.T, jenkins *v1alpha2.Jenkins) {
|
|||
|
||||
func waitForJenkinsUserConfigurationToComplete(t *testing.T, jenkins *v1alpha2.Jenkins) {
|
||||
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)
|
||||
return err == nil && jenkins.Status.UserConfigurationCompletedTime != nil
|
||||
})
|
||||
|
|
@ -129,3 +132,25 @@ func WaitUntilJenkinsConditionSet(retryInterval time.Duration, retries int, jenk
|
|||
}
|
||||
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