Skip to content

Commit

Permalink
Merge pull request #2229 from rphillips/ctrcfg-test-race
Browse files Browse the repository at this point in the history
Bug 1897361: ctrcfg_test: Wait for our prior target config
  • Loading branch information
openshift-merge-robot committed Nov 19, 2020
2 parents d5aaed6 + b818d76 commit 806f77e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 2 additions & 6 deletions test/e2e/ctrcfg_test.go
Expand Up @@ -84,7 +84,7 @@ func runTestWithCtrcfg(t *testing.T, testName, regexKey, expectedConfValue strin
err := cs.MachineConfigs().Delete(context.TODO(), oldMCConfig.Name, metav1.DeleteOptions{})
require.Nil(t, err, "machine config deletion failed")
})
waitForConfigAndPoolComplete(t, cs, poolName, oldMCConfig.Name)
lastTarget := waitForConfigAndPoolComplete(t, cs, poolName, oldMCConfig.Name)

// create our ctrcfg and attach it to our created node pool
cleanupCtrcfgFunc := createCtrcfgWithConfig(t, cs, ctrcfgName, poolName, cfg)
Expand All @@ -103,14 +103,10 @@ func runTestWithCtrcfg(t *testing.T, testName, regexKey, expectedConfValue strin
// cleanup ctrcfg and make sure it doesn't error
err = cleanupCtrcfgFunc()
require.Nil(t, err)

t.Logf("Deleted ContainerRuntimeConfig %s", ctrcfgName)
// there's a weird race where we observe the pool is updated when in reality
// that update is from before. Sleeping allows a new update cycle to start
time.Sleep(time.Second * 5)

// ensure config rolls back as expected
waitForConfigAndPoolComplete(t, cs, poolName, oldMCConfig.Name)
waitForPoolComplete(t, cs, poolName, lastTarget)

restoredConfValue := getValueFromCrioConfig(t, cs, node, regexKey, defaultPath)
require.Equal(t, restoredConfValue, oldConfValue, "ctrcfg deletion didn't cause node to roll back config")
Expand Down
6 changes: 4 additions & 2 deletions test/e2e/utils_test.go
Expand Up @@ -32,12 +32,14 @@ func getMcName(t *testing.T, cs *framework.ClientSet, poolName string) string {
return mcp.Status.Configuration.Name
}

// waitForConfigAndPoolComplete is a helper function that gets a renderedConfig and waits for its pool to complete
func waitForConfigAndPoolComplete(t *testing.T, cs *framework.ClientSet, pool, mcName string) {
// waitForConfigAndPoolComplete is a helper function that gets a renderedConfig and waits for its pool to complete.
// The return value is the final rendered config.
func waitForConfigAndPoolComplete(t *testing.T, cs *framework.ClientSet, pool, mcName string) string {
config, err := waitForRenderedConfig(t, cs, pool, mcName)
require.Nil(t, err, "failed to render machine config %s from pool %s", mcName, pool)
err = waitForPoolComplete(t, cs, pool, config)
require.Nil(t, err, "pool %s did not update to config %s", pool, config)
return config
}

// waitForRenderedConfig polls a MachineConfigPool until it has
Expand Down

0 comments on commit 806f77e

Please sign in to comment.