Fixes flaky e2e tests. Closes #2086 (#2126)

This commit is contained in:
Alex Collins 2019-08-08 16:17:44 -07:00 committed by GitHub
parent 9c8ab50d60
commit 9d0824beb6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View file

@ -47,6 +47,7 @@ func TestAutoSyncSelfHealEnabled(t *testing.T) {
app.Spec.SyncPolicy = &SyncPolicy{Automated: &SyncPolicyAutomated{SelfHeal: true}}
}).
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
When().
// app should be auto-synced once k8s change detected
@ -55,12 +56,14 @@ func TestAutoSyncSelfHealEnabled(t *testing.T) {
"guestbook-ui", types.MergePatchType, []byte(`{"spec": {"revisionHistoryLimit": 0}}`)))
}).
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
When().
// app should be attempted to auto-synced once and marked with error after failed attempt detected
PatchFile("guestbook-ui-deployment.yaml", `[{"op": "replace", "path": "/spec/revisionHistoryLimit", "value": "badValue"}]`).
Refresh(RefreshTypeNormal).
Then().
Expect(OperationPhaseIs(OperationFailed)).
Expect(SyncStatusIs(SyncStatusCodeOutOfSync)).
Expect(Condition(ApplicationConditionSyncError, "Failed sync attempt"))
}

View file

@ -35,7 +35,7 @@ type Context struct {
func Given(t *testing.T) *Context {
fixture.EnsureCleanState(t)
return &Context{t: t, destServer: KubernetesInternalAPIServerAddr, repoURLType: fixture.RepoURLTypeFile, name: fixture.Name(), timeout: 5, project: "default", prune: true}
return &Context{t: t, destServer: KubernetesInternalAPIServerAddr, repoURLType: fixture.RepoURLTypeFile, name: fixture.Name(), timeout: 10, project: "default", prune: true}
}
func (c *Context) CustomCACertAdded() *Context {

View file

@ -274,6 +274,8 @@ func TestHookDeleteBeforeCreation(t *testing.T) {
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(HealthStatusHealthy)).
And(func(_ *Application) {
var err error
creationTimestamp1, err = getCreationTimestamp()
@ -286,6 +288,8 @@ func TestHookDeleteBeforeCreation(t *testing.T) {
Sync().
Then().
Expect(OperationPhaseIs(OperationSucceeded)).
Expect(SyncStatusIs(SyncStatusCodeSynced)).
Expect(HealthIs(HealthStatusHealthy)).
And(func(_ *Application) {
creationTimestamp2, err := getCreationTimestamp()
CheckError(err)
@ -295,6 +299,7 @@ func TestHookDeleteBeforeCreation(t *testing.T) {
}
func getCreationTimestamp() (string, error) {
FailOnErr(Run(".", "kubectl", "-n", DeploymentNamespace(), "get", "all"))
return Run(".", "kubectl", "-n", DeploymentNamespace(), "get", "pod", "hook", "-o", "jsonpath={.metadata.creationTimestamp}")
}