Skip to content

Commit

Permalink
Add an event poll for TestOAuthServiceAccountClientEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Rogers committed May 25, 2018
1 parent 586dd8e commit 5460a8e
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions test/integration/oauth_serviceaccount_client_events_test.go
@@ -1,7 +1,6 @@
package integration

import (
"golang.org/x/net/html"
"net/http"
"net/http/cookiejar"
"net/http/httptest"
Expand All @@ -10,6 +9,8 @@ import (
"testing"
"time"

"golang.org/x/net/html"

"github.com/RangelReale/osincli"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
Expand Down Expand Up @@ -151,10 +152,21 @@ func TestOAuthServiceAccountClientEvent(t *testing.T) {

runTestOAuthFlow(t, testServer, sa, secret, redirect, testCase.expectBadRequest)

// Check events
evList, err := testServer.clusterAdminKubeClient.Core().Events(projectName).List(metav1.ListOptions{})
// Check events with a short poll to stop flakes
var evList *kapi.EventList
err = wait.Poll(time.Second, 5*time.Second, func() (bool, error) {
evList, err = testServer.clusterAdminKubeClient.Core().Events(projectName).List(metav1.ListOptions{})
if err != nil {
return false, err
}
if len(evList.Items) < testCase.numEvents {
return false, nil
}
return true, nil
})

if err != nil {
t.Fatalf("%s: err listing events", tcName)
t.Fatalf("%s: err polling for events", tcName)
}

events := collectEventsWithReason(evList, testCase.expectedEventReason)
Expand Down

0 comments on commit 5460a8e

Please sign in to comment.