Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove the race condition on the ClusterProxyConfig integration test (for release/v0.5) #477

Open
wants to merge 1 commit into
base: release/v0.5
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion tests/integration/clusterProxyConfig_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ func (m *IntegrationSuite) TestClusterProxyConfig() {
Version: "v3",
Kind: "ClusterProxyConfig",
}
validCreateObj := getObjectToCreate("testclusterproxyconfig")
cpcName := "testclusterproxyconfig"
validCreateObj := getObjectToCreate(cpcName)
client, err := m.clientFactory.ForKind(objGVK)
m.Require().NoError(err, "Failed to create client")
result := &v3.ClusterProxyConfig{}
Expand All @@ -26,6 +27,22 @@ func (m *IntegrationSuite) TestClusterProxyConfig() {
// Creating the first CPC should succeed
err = client.Create(ctx, validCreateObj.Namespace, validCreateObj, result, metav1.CreateOptions{})
m.NoError(err, "Error returned during the creation of a valid clusterProxyConfig")

// Verify the API knows about the first object before we try to create a second one.
// Wait 5 minutes for the object to be created (should be more than ample time)
timeout := int64(5 * time.Minute)
listOptions := metav1.ListOptions{
Watch: true,
TimeoutSeconds: &timeout,
}
watcher, err := client.Watch(ctx, validCreateObj.Namespace, listOptions)
m.Require().NoError(err, "Error returned trying to watch the clusterProxyConfig")
defer watcher.Stop()

receivedEvent, ok := <-watcher.ResultChan()
m.Require().True(ok, "The CPC watcher closed before it sent any notifications")
m.Require().EqualValues(receivedEvent.Object.GetObjectKind().GroupVersionKind().Kind, "ClusterProxyConfig")

secondCPC := getObjectToCreate("anotherclusterproxyconfig")
// Attempting to create another CPC in the same namespace should fail
err = client.Create(ctx, validCreateObj.Namespace, secondCPC, result, metav1.CreateOptions{})
Expand Down
Loading