-
Notifications
You must be signed in to change notification settings - Fork 216
Add test to verify the restarted operator would detect the existing introspector and wait for the job to complete #2482
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
2f40cda
initial version
maggiehe00 9145d9b
minor java doc editing
maggiehe00 89d9cde
addressing the review comments
maggiehe00 523f251
adding the review comments
maggiehe00 ad872b6
Merge remote-tracking branch 'origin/main' into introver
maggiehe00 4cb3cb0
refactor the code
maggiehe00 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
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
72 changes: 72 additions & 0 deletions
72
integration-tests/src/test/java/oracle/weblogic/kubernetes/utils/CommonOperatorUtils.java
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 |
|---|---|---|
| @@ -0,0 +1,72 @@ | ||
| // Copyright (c) 2021, Oracle and/or its affiliates. | ||
| // Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl. | ||
|
|
||
| package oracle.weblogic.kubernetes.utils; | ||
|
|
||
| import oracle.weblogic.kubernetes.logging.LoggingFacade; | ||
| import org.awaitility.core.ConditionFactory; | ||
|
|
||
| import static java.util.concurrent.TimeUnit.MINUTES; | ||
| import static java.util.concurrent.TimeUnit.SECONDS; | ||
| import static oracle.weblogic.kubernetes.TestConstants.OPERATOR_RELEASE_NAME; | ||
| import static oracle.weblogic.kubernetes.actions.TestActions.getOperatorPodName; | ||
| import static oracle.weblogic.kubernetes.actions.TestActions.startOperator; | ||
| import static oracle.weblogic.kubernetes.actions.TestActions.stopOperator; | ||
| import static oracle.weblogic.kubernetes.assertions.TestAssertions.operatorIsReady; | ||
| import static oracle.weblogic.kubernetes.utils.CommonTestUtils.checkPodDoesNotExist; | ||
| import static oracle.weblogic.kubernetes.utils.ThreadSafeLogger.getLogger; | ||
| import static org.awaitility.Awaitility.with; | ||
| import static org.junit.jupiter.api.Assertions.assertDoesNotThrow; | ||
| import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
| import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
|
||
|
|
||
| /** | ||
| * The common utility class for Operator. | ||
| */ | ||
| public class CommonOperatorUtils { | ||
|
|
||
| private static final ConditionFactory withStandardRetryPolicy | ||
| = with().pollDelay(2, SECONDS) | ||
| .and().with().pollInterval(10, SECONDS) | ||
| .atMost(5, MINUTES).await(); | ||
|
|
||
|
|
||
| /** | ||
| * Restart Operator by changing replica to 0 in operator deployment to stop Operator | ||
| * and changing replica back to 1 to start Operator. | ||
| * @param opNamespace namespace where Operator exists | ||
| */ | ||
| public static void restartOperator(String opNamespace) { | ||
| LoggingFacade logger = getLogger(); | ||
| // get operator pod name | ||
| String operatorPodName = assertDoesNotThrow( | ||
| () -> getOperatorPodName(OPERATOR_RELEASE_NAME, opNamespace)); | ||
| assertNotNull(operatorPodName, "Operator pod name returned is null"); | ||
| logger.info("Operator pod name {0}", operatorPodName); | ||
|
|
||
| // stop operator by changing replica to 0 in operator deployment | ||
| assertTrue(stopOperator(opNamespace), "Couldn't stop the Operator"); | ||
|
|
||
| // check operator pod is not running | ||
| checkPodDoesNotExist(operatorPodName, null, opNamespace); | ||
|
|
||
| // start operator by changing replica to 1 in operator deployment | ||
| assertTrue(startOperator(opNamespace), "Couldn't start the Operator"); | ||
|
|
||
| // check operator is running | ||
| logger.info("Check Operator pod is running in namespace {0}", opNamespace); | ||
| withStandardRetryPolicy | ||
| .conditionEvaluationListener( | ||
| condition -> logger.info("Waiting for operator to be running in namespace {0} " | ||
| + "(elapsed time {1}ms, remaining time {2}ms)", | ||
| opNamespace, | ||
| condition.getElapsedTimeInMS(), | ||
| condition.getRemainingTimeInMS())) | ||
| .until(operatorIsReady(opNamespace)); | ||
|
|
||
| logger.info("Operator pod is restarted in namespace {0}", opNamespace); | ||
|
|
||
| } | ||
|
|
||
| } |
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
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.
Uh oh!
There was an error while loading. Please reload this page.