-
Notifications
You must be signed in to change notification settings - Fork 216
Owls88697 stop namespaces that no longer managed by operator when change to dedicated strategy #2345
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
Merged
Merged
Owls88697 stop namespaces that no longer managed by operator when change to dedicated strategy #2345
Changes from 1 commit
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
1e35582
add NamespaceListAfterStep to dedicated case to clean up domains
doxiao 781c8eb
unit test use recheckDomains when testing a specific strategy
doxiao 278f808
unit test use createReadNamespacesStep in strategy specific cases
doxiao 6504e32
merge
doxiao d16766f
more namespace cleanup when stop a namespace
doxiao 57f03aa
more cleanup on stopping a namespace
doxiao a0113e8
revert one unnecessary change to a method signature
doxiao aadcf82
address review comments
doxiao b38c93d
more style changes
doxiao File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
unit test use recheckDomains when testing a specific strategy
- Loading branch information
commit 781c8eb2bbd70d349aed4a99dea807273751c5ac
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -394,14 +394,14 @@ public void afterMissingCRDcorrected_subsequentFailureLogsReasonForFailure() { | |
} | ||
|
||
@Test | ||
public void withNamespaceList_onStartNamespaceStep_startsNamespaces() { | ||
public void withNamespaceList_onRecheckDomains_startsNamespaces() { | ||
defineSelectionStrategy(SelectionStrategy.List); | ||
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, | ||
String.join(",", NS_WEBLOGIC1, NS_WEBLOGIC2, NS_WEBLOGIC3)); | ||
testSupport.defineResources(NAMESPACE_WEBLOGIC1, NAMESPACE_WEBLOGIC2, NAMESPACE_WEBLOGIC3, | ||
NAMESPACE_WEBLOGIC4, NAMESPACE_WEBLOGIC5); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat(getStartingNamespaces(), contains(NS_WEBLOGIC1, NS_WEBLOGIC2, NS_WEBLOGIC3)); | ||
} | ||
|
@@ -443,25 +443,25 @@ public void describeTo(Description description) { | |
} | ||
|
||
@Test | ||
public void withRegExp_onReadExistingNamespaces_startsNamespaces() { | ||
public void withRegExp_onRecheckDomains_startsNamespaces() { | ||
defineSelectionStrategy(SelectionStrategy.RegExp); | ||
testSupport.defineResources(NAMESPACE_WEBLOGIC1, NAMESPACE_WEBLOGIC2, NAMESPACE_WEBLOGIC3, | ||
NAMESPACE_WEBLOGIC4, NAMESPACE_WEBLOGIC5); | ||
|
||
TuningParameters.getInstance().put("domainNamespaceRegExp", REGEXP); | ||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat(getStartingNamespaces(), contains(NS_WEBLOGIC2, NS_WEBLOGIC4)); | ||
} | ||
|
||
@Test | ||
public void withLabelSelector_onReadExistingNamespaces_startsNamespaces() { | ||
public void withLabelSelector_onRecheckDomains_startsNamespaces() { | ||
defineSelectionStrategy(SelectionStrategy.LabelSelector); | ||
testSupport.defineResources(NAMESPACE_WEBLOGIC1, NAMESPACE_WEBLOGIC2, NAMESPACE_WEBLOGIC3, | ||
NAMESPACE_WEBLOGIC4, NAMESPACE_WEBLOGIC5); | ||
|
||
TuningParameters.getInstance().put("domainNamespaceLabelSelector", LABEL + "=" + VALUE); | ||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat(getStartingNamespaces(), contains(NS_WEBLOGIC1, NS_WEBLOGIC3, NS_WEBLOGIC5)); | ||
} | ||
|
@@ -781,50 +781,49 @@ public void withNamespaceList_onCreateStartNamespacesStep_foundExpectedLogMessag | |
} | ||
|
||
@Test | ||
public void withNamespaceList_onReadExistingNamespaces_whenConfiguredDomainNamespaceMissing_noEventCreated() { | ||
public void withNamespaceList_onRecheckDomains_whenConfiguredDomainNamespaceMissing_noEventCreated() { | ||
defineSelectionStrategy(SelectionStrategy.List); | ||
String namespaceString = "NS" + LAST_NAMESPACE_NUM + ",NS" + DEFAULT_CALL_LIMIT; | ||
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(LAST_NAMESPACE_NUM - 1); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat("Found no event", | ||
containsEvent(getEvents(testSupport), NAMESPACE_WATCHING_STARTED_EVENT), is(false)); | ||
} | ||
|
||
@Test | ||
public void withNamespaceList_onReadExistingNamespaces_whenDomainNamespaceRemoved_nsWatchStoppedEventCreated() { | ||
public void withNamespaceList_onRecheckDomains_whenDomainNamespaceRemoved_nsWatchStoppedEventCreated() { | ||
domainNamespaces.isStopping("NS3"); | ||
defineSelectionStrategy(SelectionStrategy.List); | ||
String namespaceString = "NS1,NS2"; | ||
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(4); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
|
||
recheckDomains(); | ||
assertThat("Found NAMESPACE_WATCHING_STOPPED event with expected message", | ||
containsEventWithMessageForNamespaces(getEvents(testSupport), | ||
NAMESPACE_WATCHING_STOPPED, Collections.singletonList("NS3")), is(true)); | ||
} | ||
|
||
@Test | ||
public void withNamespaceList_onReadExistingNamespaces_whenDomainNamespaceRemoved_stopManagingNSEventCreated() { | ||
public void withNamespaceList_onRecheckDomains_whenDomainNamespaceRemoved_stopManagingNSEventCreated() { | ||
domainNamespaces.isStopping("NS3"); | ||
defineSelectionStrategy(SelectionStrategy.List); | ||
String namespaceString = "NS1,NS2"; | ||
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(4); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat("Found NAMESPACE_WATCHING_STOPPED event with expected message", | ||
containsEventWithMessageForNamespaces(getEvents(testSupport), | ||
STOP_MANAGING_NAMESPACE, Collections.singletonList("NS3")), is(true)); | ||
} | ||
|
||
@Test | ||
public void withNamespaceList_onReadExistingNamespaces_whenDomainNamespaceRemoved_foundExpectedLogMessage() { | ||
public void withNamespaceList_onRecheckDomains_whenDomainNamespaceRemoved_foundExpectedLogMessage() { | ||
logRecords.clear(); | ||
loggerControl.withLogLevel(Level.INFO).collectLogMessages(logRecords, MessageKeys.END_MANAGING_NAMESPACE); | ||
domainNamespaces.isStopping("NS3"); | ||
|
@@ -833,18 +832,18 @@ public void withNamespaceList_onReadExistingNamespaces_whenDomainNamespaceRemove | |
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(4); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
assertThat(logRecords, containsInfo(MessageKeys.END_MANAGING_NAMESPACE, "NS3")); | ||
} | ||
|
||
@Test | ||
public void withNamespaceList_changeToDedicatedAfterReadExistingNSs_onRecheck_nsWatchStoppedEventCreated() { | ||
public void withNamespaceList_changeToDedicatedAfterRecheckDomains_onRecheckAgain_nsWatchStoppedEventCreated() { | ||
defineSelectionStrategy(SelectionStrategy.List); | ||
String namespaceString = "NS1"; | ||
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(4); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
defineSelectionStrategy(SelectionStrategy.Dedicated); | ||
|
||
|
@@ -856,13 +855,13 @@ public void withNamespaceList_changeToDedicatedAfterReadExistingNSs_onRecheck_ns | |
} | ||
|
||
@Test | ||
public void withNamespaceList_changeToDedicatedAfterReadExistingNSs_onRecheck_nsWatchStartedEventCreatedInOpNS() { | ||
public void withNamespaceList_changeToDedicatedAfterRecheckDomains_onRecheckAgain_nsWatchStartedEventCreatedInOpNS() { | ||
defineSelectionStrategy(SelectionStrategy.List); | ||
String namespaceString = "NS1"; | ||
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(4); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
defineSelectionStrategy(SelectionStrategy.Dedicated); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here you are changing to a new strategy, so line 859 begins the 'action' part of the test and should be separated by a blank line from the 'setup' |
||
|
||
|
@@ -874,13 +873,13 @@ public void withNamespaceList_changeToDedicatedAfterReadExistingNSs_onRecheck_ns | |
} | ||
|
||
@Test | ||
public void withNamespaceList_changeToDedicatedAfterReadExistingNSs_onRecheck_StartManagingNSEventCreatedInOpNS() { | ||
public void withNamespaceList_changeToDedicatedAfterRecheckDomains_onRecheckAgain_StartManagingEventCreatedInOpNS() { | ||
defineSelectionStrategy(SelectionStrategy.List); | ||
String namespaceString = "NS1"; | ||
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(4); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
defineSelectionStrategy(SelectionStrategy.Dedicated); | ||
|
||
|
@@ -927,40 +926,39 @@ public void withNamespaceLabelSelector_onCreateStartNamespacesStep_startManaging | |
|
||
|
||
@Test | ||
public void withNamespaceLabelSelector_onReadExistingNamespaces_whenLabelRemoved_nsWatchStoppedEventCreated() { | ||
public void withNamespaceLabelSelector_onRecheckDomains_whenLabelRemoved_nsWatchStoppedEventCreated() { | ||
domainNamespaces.isStopping("NS3"); | ||
testSupport.defineResources(NAMESPACE_WEBLOGIC1, NAMESPACE_WEBLOGIC2, NAMESPACE_WEBLOGIC3, | ||
NAMESPACE_WEBLOGIC4, NAMESPACE_WEBLOGIC5); | ||
|
||
defineSelectionStrategy(SelectionStrategy.LabelSelector); | ||
TuningParameters.getInstance().put("domainNamespaceLabelSelector", LABEL + "=" + VALUE); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
|
||
recheckDomains(); | ||
|
||
assertThat("Found NAMESPACE_WATCHING_STOPPED event with expected message", | ||
containsEventWithMessageForNamespaces(getEvents(testSupport), | ||
NAMESPACE_WATCHING_STOPPED, Collections.singletonList("NS3")), is(true)); | ||
} | ||
|
||
@Test | ||
public void withNamespaceLabelSelector_onReadExistingNamespaces_whenLabelRemoved_stopManagingNSEventCreated() { | ||
public void withNamespaceLabelSelector_onRecheckDomains_whenLabelRemoved_stopManagingNSEventCreated() { | ||
domainNamespaces.isStopping("NS3"); | ||
testSupport.defineResources(NAMESPACE_WEBLOGIC1, NAMESPACE_WEBLOGIC2, NAMESPACE_WEBLOGIC3, | ||
NAMESPACE_WEBLOGIC4, NAMESPACE_WEBLOGIC5); | ||
|
||
defineSelectionStrategy(SelectionStrategy.LabelSelector); | ||
TuningParameters.getInstance().put("domainNamespaceLabelSelector", LABEL + "=" + VALUE); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat("Found NAMESPACE_WATCHING_STOPPED event with expected message", | ||
containsEventWithMessageForNamespaces(getEvents(testSupport), | ||
STOP_MANAGING_NAMESPACE, Collections.singletonList("NS3")), is(true)); | ||
} | ||
|
||
@Test | ||
public void withNamespaceLabelSelector_onReadExistingNamespaces_whenNamespaceLabelRemoved_foundExpectedLogMessage() { | ||
public void withNamespaceLabelSelector_onRecheckDomains_whenNamespaceLabelRemoved_foundExpectedLogMessage() { | ||
logRecords.clear(); | ||
loggerControl.withLogLevel(Level.INFO).collectLogMessages(logRecords, MessageKeys.END_MANAGING_NAMESPACE); | ||
domainNamespaces.isStopping("NS3"); | ||
|
@@ -970,7 +968,7 @@ public void withNamespaceLabelSelector_onReadExistingNamespaces_whenNamespaceLab | |
defineSelectionStrategy(SelectionStrategy.LabelSelector); | ||
TuningParameters.getInstance().put("domainNamespaceLabelSelector", LABEL + "=" + VALUE); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat(logRecords, containsInfo(MessageKeys.END_MANAGING_NAMESPACE, "NS3")); | ||
} | ||
|
@@ -1010,37 +1008,37 @@ public void withNamespaceRegExp_onCreateStartNamespacesStep_startManagingNSEvent | |
} | ||
|
||
@Test | ||
public void withNamespaceRegExp_onReadExistingNamespaces_whenNamespaceLabelRemoved_nsWatchStoppedEventCreated() { | ||
public void withNamespaceRegExp_onRecheckDomains_whenNamespaceLabelRemoved_nsWatchStoppedEventCreated() { | ||
domainNamespaces.isStopping("NS3"); | ||
testSupport.defineResources(NAMESPACE_WEBLOGIC1, NAMESPACE_WEBLOGIC2, NAMESPACE_WEBLOGIC3, | ||
NAMESPACE_WEBLOGIC4, NAMESPACE_WEBLOGIC5); | ||
|
||
defineSelectionStrategy(SelectionStrategy.RegExp); | ||
TuningParameters.getInstance().put("domainNamespaceRegExp", REGEXP); | ||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat("Found NAMESPACE_WATCHING_STOPPED event with expected message", | ||
containsEventWithMessageForNamespaces(getEvents(testSupport), | ||
NAMESPACE_WATCHING_STOPPED, Collections.singletonList("NS3")), is(true)); | ||
} | ||
|
||
@Test | ||
public void withNamespaceRegExp_onReadExistingNamespaces_whenNamespaceLabelRemoved_stopManagingNSEventCreated() { | ||
public void withNamespaceRegExp_onRecheckDomains_whenNamespaceLabelRemoved_stopManagingNSEventCreated() { | ||
domainNamespaces.isStopping("NS3"); | ||
testSupport.defineResources(NAMESPACE_WEBLOGIC1, NAMESPACE_WEBLOGIC2, NAMESPACE_WEBLOGIC3, | ||
NAMESPACE_WEBLOGIC4, NAMESPACE_WEBLOGIC5); | ||
|
||
defineSelectionStrategy(SelectionStrategy.RegExp); | ||
TuningParameters.getInstance().put("domainNamespaceRegExp", REGEXP); | ||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat("Found NAMESPACE_WATCHING_STOPPED event with expected message", | ||
containsEventWithMessageForNamespaces(getEvents(testSupport), | ||
STOP_MANAGING_NAMESPACE, Collections.singletonList("NS3")), is(true)); | ||
} | ||
|
||
@Test | ||
public void withNamespaceRegExp_onReadExistingNamespaces_whenNamespaceLabelRemoved_foundExpectedLogMessage() { | ||
public void withNamespaceRegExp_onRecheckDomains_whenNamespaceLabelRemoved_foundExpectedLogMessage() { | ||
logRecords.clear(); | ||
loggerControl.withLogLevel(Level.INFO).collectLogMessages(logRecords, MessageKeys.END_MANAGING_NAMESPACE); | ||
domainNamespaces.isStopping("NS3"); | ||
|
@@ -1049,7 +1047,7 @@ public void withNamespaceRegExp_onReadExistingNamespaces_whenNamespaceLabelRemov | |
|
||
defineSelectionStrategy(SelectionStrategy.RegExp); | ||
TuningParameters.getInstance().put("domainNamespaceRegExp", REGEXP); | ||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat(logRecords, containsInfo(MessageKeys.END_MANAGING_NAMESPACE, "NS3")); | ||
} | ||
|
@@ -1078,7 +1076,7 @@ public void withNamespaceDedicated_onRecheckDomains_startManagingNSEventCreatedW | |
} | ||
|
||
@Test | ||
public void withNamespaceDedicated_changeToListAfterRecheck_onReadExistingNSs_nsWatchStoppedEventCreatedInOpNS() { | ||
public void withNamespaceDedicated_changeToListAfterRecheckDomains_onRecheckAgain_nsWatchStoppedEventCreatedInOpNS() { | ||
defineSelectionStrategy(SelectionStrategy.Dedicated); | ||
recheckDomains(); | ||
|
||
|
@@ -1087,15 +1085,14 @@ public void withNamespaceDedicated_changeToListAfterRecheck_onReadExistingNSs_ns | |
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(4); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
|
||
recheckDomains(); | ||
assertThat("Found NAMESPACE_WATCHING_STOPPED event with expected message", | ||
containsEventWithMessageForNamespaces(getEvents(testSupport), | ||
NAMESPACE_WATCHING_STOPPED, Collections.singletonList(OP_NS)), is(true)); | ||
} | ||
|
||
@Test | ||
public void withNamespaceDedicated_changeToListAfterRecheck_onReadingExistingNSs_nsWatchStartedEventCreated() { | ||
public void withNamespaceDedicated_changeToListAfterRecheckDomains_onRecheckAgain_nsWatchStartedEventCreated() { | ||
defineSelectionStrategy(SelectionStrategy.Dedicated); | ||
recheckDomains(); | ||
|
||
|
@@ -1104,15 +1101,15 @@ public void withNamespaceDedicated_changeToListAfterRecheck_onReadingExistingNSs | |
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(4); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat("Found NAMESPACE_WATCHING_STARTED event with expected message", | ||
containsEventWithMessageForNamespaces(getEvents(testSupport), | ||
NAMESPACE_WATCHING_STARTED, Collections.singletonList("NS1")), is(true)); | ||
} | ||
|
||
@Test | ||
public void withNamespaceDedicated_changeToListAfterRecheck_onReadingExistingNSs_StartManagingNSEventCreated() { | ||
public void withNamespaceDedicated_changeToListAfterRecheckDomains_onRecheckAgain_StartManagingNSEventCreated() { | ||
defineSelectionStrategy(SelectionStrategy.Dedicated); | ||
recheckDomains(); | ||
|
||
|
@@ -1121,7 +1118,7 @@ public void withNamespaceDedicated_changeToListAfterRecheck_onReadingExistingNSs | |
HelmAccessStub.defineVariable(HelmAccess.OPERATOR_DOMAIN_NAMESPACES, namespaceString); | ||
createNamespaces(4); | ||
|
||
testSupport.runSteps(createDomainRecheck().readExistingNamespaces()); | ||
recheckDomains(); | ||
|
||
assertThat("Found START_MANAGING_NAMESPACE event with expected message", | ||
containsEventWithMessageForNamespaces(getEvents(testSupport), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have found that organizing tests can help readability:
You can do that with judicious use of spaces. Here, lines 845-850 establish your starting point, and 852-854 are the action, so I would remove the blank lines in between them, and reserve those as separators only between the three sections.
If those are complex, you might consider extract them to their own methods, especially if you do the same setup in multiple tests.