Skip to content

Commit

Permalink
Fix flaky integration test TestDynamicNamespaceDelete (#369)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardartoul authored and Katie Tezapsidis committed Oct 20, 2017
1 parent f8dd4dd commit b59917c
Showing 1 changed file with 8 additions and 12 deletions.
20 changes: 8 additions & 12 deletions integration/dynamic_namespace_delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ func TestDynamicNamespaceDelete(t *testing.T) {
ns1 := testOpts.Namespaces()[1]

reporter := xmetrics.NewTestStatsReporter(xmetrics.NewTestStatsReporterOptions())
scope, closer := tally.NewRootScope(tally.ScopeOptions{Reporter: reporter}, 100*time.Millisecond)
scope, closer := tally.NewRootScope(
tally.ScopeOptions{Reporter: reporter}, time.Millisecond)
defer closer.Close()

// embedded kv
Expand Down Expand Up @@ -119,14 +120,14 @@ func TestDynamicNamespaceDelete(t *testing.T) {
}

// delete namespace key, ensure update propagates
numInvalid := numInvalidNamespaceUpdates(scope)
numInvalid := numInvalidNamespaceUpdates(reporter)
_, err = kvStore.Delete(dynamicOpts.NamespaceRegistryKey())
require.NoError(t, err)
deletePropagated := func() bool {
return numInvalidNamespaceUpdates(scope) > numInvalid
return numInvalidNamespaceUpdates(reporter) > numInvalid
}
require.True(t, waitUntil(deletePropagated, 20*time.Second))
log.Infof("deleted namespace key from kv")
log.Infof("deleted namespace key propagated from KV to testSetup")

// update value in kv
_, err = kvStore.Set(dynamicOpts.NamespaceRegistryKey(), protoKey(ns0, ns1))
Expand All @@ -139,7 +140,7 @@ func TestDynamicNamespaceDelete(t *testing.T) {
return ok
}
require.True(t, waitUntil(nsExists, 5*time.Second))
log.Infof("new namespace available in testSetup")
log.Infof("new namespace propagated from KV to testSetup")

// write to new namespace
for start, testData := range seriesMaps {
Expand All @@ -162,11 +163,6 @@ func TestDynamicNamespaceDelete(t *testing.T) {
log.Infof("data is verified")
}

func numInvalidNamespaceUpdates(scope tally.Scope) int64 {
testScope := scope.(tally.TestScope)
count, ok := testScope.Snapshot().Counters()["namespace-registry.invalid-update+"]
if !ok {
return 0
}
return count.Value()
func numInvalidNamespaceUpdates(reporter xmetrics.TestStatsReporter) int64 {
return reporter.Counters()["namespace-registry.invalid-update"]
}

0 comments on commit b59917c

Please sign in to comment.