-
Notifications
You must be signed in to change notification settings - Fork 9
Base classes for upgrade pipeline #2727
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
21 commits
Select commit
Hold shift + click to select a range
f797690
Base classes for upgrade pipeline
labkey-tchad 8c70809
Merge remote-tracking branch 'origin/develop' into fb_upgradeTestPipe…
labkey-tchad 1d83b91
Merge remote-tracking branch 'origin/develop' into fb_upgradeTestPipe…
labkey-tchad bf373b4
Cleanup imports
labkey-tchad abbac24
Merge remote-tracking branch 'origin/develop' into fb_upgradeTestPipe…
labkey-tchad e189bd8
Merge remote-tracking branch 'origin/develop' into fb_upgradeTestPipe…
labkey-tchad b9b8fa9
Merge remote-tracking branch 'origin/develop' into fb_upgradeTestPipe…
labkey-tchad 81894aa
Merge remote-tracking branch 'origin/develop' into fb_upgradeTestPipe…
labkey-tchad dd289ae
Don't wait an hour for server to start
labkey-tchad 73a32a7
Use Java remote API to connect to starting server
labkey-tchad 8b04631
wrong file
labkey-tchad cf23760
Interpret response correctly
labkey-tchad 9dfaf9b
Back to old HttpClient
labkey-tchad 4cd57b2
Merge remote-tracking branch 'origin/develop' into fb_upgradeTestPipe…
labkey-tchad bf701cb
Try ensureLogin
labkey-tchad 2f24b32
Merge remote-tracking branch 'origin/develop' into fb_upgradeTestPipe…
labkey-tchad 3d0a1cb
Update project name
labkey-tchad 59fbef0
Merge remote-tracking branch 'origin/develop' into fb_upgradeTestPipe…
labkey-tchad cdc53bb
Reuse code
labkey-tchad dfb3619
Update upgrade tests
labkey-tchad bbdbacd
Add comments and fix version range check
labkey-tchad 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
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
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
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
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,125 @@ | ||
| package org.labkey.test.tests.upgrade; | ||
|
|
||
| import org.jetbrains.annotations.NotNull; | ||
| import org.junit.Assume; | ||
| import org.junit.BeforeClass; | ||
| import org.junit.Rule; | ||
| import org.junit.rules.TestRule; | ||
| import org.junit.runner.Description; | ||
| import org.junit.runners.model.Statement; | ||
| import org.labkey.test.BaseWebDriverTest; | ||
| import org.labkey.test.TestProperties; | ||
| import org.labkey.test.util.TestLogger; | ||
| import org.labkey.test.util.Version; | ||
| import org.labkey.test.util.VersionRange; | ||
|
|
||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
| import java.util.Arrays; | ||
| import java.util.List; | ||
| import java.util.Optional; | ||
|
|
||
| import static org.apache.commons.lang3.StringUtils.trimToNull; | ||
|
|
||
| /** | ||
| * Base test class for tests that setup data and configure a server then verify the persistence or modification of those | ||
| * data and configurations after upgrading to a newer version of LabKey.<br> | ||
| * The {@code EariestVersion} and {@code LatestVersion} annotations can be used to skip particular tests when they are | ||
| * not relevant to the version of LabKey being upgraded from (specified in the {@code webtest.upgradePreviousVersion} | ||
| * system property).<br> | ||
| * The setup steps will be skipped if the {@code webtest.upgradeSetup} system property is set to {@code false}. | ||
| */ | ||
| public abstract class BaseUpgradeTest extends BaseWebDriverTest | ||
| { | ||
|
|
||
| protected static final boolean isUpgradeSetupPhase = TestProperties.getBooleanProperty("webtest.upgradeSetup", true); | ||
| protected static final Version previousVersion = Optional.ofNullable(trimToNull(System.getProperty("webtest.upgradePreviousVersion"))) | ||
| .map(Version::new).orElse(null); | ||
|
|
||
| @Override | ||
| protected boolean skipCleanup(boolean afterTest) | ||
| { | ||
| return afterTest || !isUpgradeSetupPhase; | ||
| } | ||
|
|
||
| @BeforeClass | ||
| public static void setupProject() throws Exception | ||
| { | ||
| BaseUpgradeTest currentTest = BaseWebDriverTest.getCurrentTest(); | ||
|
|
||
| if (isUpgradeSetupPhase) | ||
| { | ||
| currentTest.doSetup(); | ||
| } | ||
| else | ||
| { | ||
| TestLogger.info("Skipping setup for %s. Verifying upgrade.". formatted(currentTest.getClass().getSimpleName())); | ||
| } | ||
| } | ||
|
|
||
| protected abstract void doSetup() throws Exception; | ||
|
|
||
| @Rule | ||
| public final TestRule upgradeVersionCheck = new UpgradeVersionCheck(); | ||
|
|
||
| @Override | ||
| public List<String> getAssociatedModules() | ||
| { | ||
| return Arrays.asList(); | ||
| } | ||
|
|
||
| /** | ||
| * Annotates test methods that should only run when upgrading from particular LabKey versions, as specified in | ||
| * {@code webtest.upgradePreviousVersion}.<br> | ||
| * Specifies the earliest version of the test class that performed the required setup for the annotated method. | ||
| */ | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.METHOD}) | ||
| protected @interface EariestVersion { | ||
| String value(); | ||
| } | ||
|
|
||
| /** | ||
| * Annotates test methods that should only run when upgrading from particular LabKey versions, as specified in | ||
| * {@code webtest.upgradePreviousVersion}.<br> | ||
| * Specifies the latest version of the test class that performed the required setup for the annotated method. | ||
| */ | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| @Target({ElementType.METHOD}) | ||
| protected @interface LatestVersion { | ||
| String value(); | ||
| } | ||
|
|
||
| private static class UpgradeVersionCheck implements TestRule | ||
| { | ||
|
|
||
| @Override | ||
| public @NotNull Statement apply(Statement base, Description description) | ||
| { | ||
| String eariestVersion = Optional.ofNullable(description.getAnnotation(EariestVersion.class)) | ||
| .map(EariestVersion::value).orElse(null); | ||
| String latestVersion = Optional.ofNullable(description.getAnnotation(LatestVersion.class)) | ||
| .map(LatestVersion::value).orElse(null); | ||
|
|
||
| if (isUpgradeSetupPhase || previousVersion == null || (eariestVersion == null && latestVersion == null)) | ||
| { | ||
| return base; // Run the test normally | ||
| } | ||
|
|
||
| return new Statement() | ||
| { | ||
| @Override | ||
| public void evaluate() throws Throwable | ||
| { | ||
| Assume.assumeTrue("Test doesn't support upgrading from version: " + previousVersion, | ||
| VersionRange.versionRange(eariestVersion, latestVersion).contains(previousVersion) | ||
| ); | ||
| base.evaluate(); | ||
| } | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| } |
Oops, something went wrong.
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.
Is this an efficiency change, and not related to this story?
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.
This was an accidental inclusion. The
WebStorageAPI for WebDriver has been deprecated for a while and I was removing it.