Adjust timeouts for jobs, user configuration. Add waiting mechanism for namespace removal
This commit is contained in:
parent
ed5a59655c
commit
cdde6acec3
|
|
@ -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