Skip to content
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

SDK-347 - The deploy goal should support upgrading all SDK artifacts from the distribution properties #313

Merged
merged 34 commits into from
Nov 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b8f062f
SDK-347 - The deploy goal should support upgrading all SDK artifacts …
mseaton Nov 12, 2024
ea53eaf
SDK-347 - The deploy goal should support upgrading all SDK artifacts …
mseaton Nov 13, 2024
9e1f498
SDK-347 - The deploy goal should support upgrading all SDK artifacts …
mseaton Nov 13, 2024
791d4c1
SDK-347 - The deploy goal should support upgrading all SDK artifacts …
mseaton Nov 13, 2024
d8fd4c6
SDK-347 - The deploy goal should support upgrading all SDK artifacts …
mseaton Nov 13, 2024
fa19a30
SDK-347 - The deploy goal should support upgrading all SDK artifacts …
mseaton Nov 13, 2024
6f18512
SDK-347 - The deploy goal should support upgrading all SDK artifacts …
mseaton Nov 13, 2024
68d696f
SDK-347 - The deploy goal should support upgrading all SDK artifacts …
mseaton Nov 13, 2024
b745914
All tests passing
mseaton Nov 13, 2024
57cdef5
All tests passing
mseaton Nov 13, 2024
97282fb
All tests passing
mseaton Nov 13, 2024
754998a
All tests passing
mseaton Nov 13, 2024
852039d
Additional fixes and refactoring
mseaton Nov 13, 2024
07f246b
Additional fixes and refactoring
mseaton Nov 13, 2024
5dbf510
Additional fixes and refactoring
mseaton Nov 13, 2024
bf8c779
Additional fixes and refactoring
mseaton Nov 13, 2024
2d9695d
Remove incorrect prevention of downgrading war
mseaton Nov 13, 2024
cea1dfa
Improve spa installer and speed up integration tests
mseaton Nov 14, 2024
0764391
Expand AddExclusion tests
mseaton Nov 14, 2024
893dd65
Merge branch 'master' into SDK-347
mseaton Nov 14, 2024
4205d39
Fix merge issues
mseaton Nov 14, 2024
58b5c5a
Merge branch 'master' into SDK-347
mseaton Nov 15, 2024
ff19456
remove unused import
mseaton Nov 15, 2024
35c46e9
Merge branch 'master' into SDK-347
mseaton Nov 15, 2024
5ce1af4
Merge branch 'master' into SDK-347
mseaton Nov 20, 2024
5214e48
Merge branch 'master' into SDK-347
mseaton Nov 24, 2024
cf0e992
Unused import
mseaton Nov 24, 2024
5152cfc
Add unit test for UpgradeDifferential
mseaton Nov 25, 2024
5329ae6
Move UpgradeDifferential methods into ServerUpgrader, add unit tests,…
mseaton Nov 25, 2024
59eea66
Add additional tests and logic for deploy of content and config packages
mseaton Nov 25, 2024
aa650aa
Add additional tests and logic for deploy of content and config packages
mseaton Nov 25, 2024
cb982ed
Add additional tests for wizard
mseaton Nov 25, 2024
b4c1a64
Unused imports
mseaton Nov 25, 2024
8572178
Additional test for deploy of owas
mseaton Nov 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.io.FileMatchers.anExistingFileOrDirectory;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.openmrs.maven.plugins.SdkMatchers.hasModuleVersion;
Expand Down Expand Up @@ -145,12 +146,12 @@ static synchronized int nextCounter() {
return counter++;
}

public String setupTestServer() throws Exception{
public String setupTestServer(String distro) throws Exception{
Verifier setupServer = new Verifier(testDirectory.getAbsolutePath());
String serverId = UUID.randomUUID().toString();
try {
addTaskParam(setupServer, "openMRSPath", testDirectory.getAbsolutePath());
addTaskParam(setupServer, "distro", "referenceapplication:2.2");
addTaskParam(setupServer, "distro", distro);
addTaskParam(setupServer, "debug", "1044");
addMockDbSettings(setupServer);

Expand Down Expand Up @@ -326,22 +327,28 @@ protected void assertServerInstalled(String serverId) {
assertFilePresent(serverId, SDKConstants.OPENMRS_SERVER_PROPERTIES);
}

protected void assertModulesInstalled(String serverId, String... filenames){
protected void assertModulesInstalled(String serverId, String... filenames) {
Path modulesRoot = testDirectoryPath.resolve(Paths.get(serverId, "modules"));
for(String filename : filenames){
for(String filename : filenames) {
assertPathPresent(modulesRoot.resolve(filename));
}
}

protected void assertModulesInstalled(String serverId, DistroProperties distroProperties) {
protected void assertOnlyModulesInstalled(String serverId, DistroProperties distroProperties) {
List<Artifact> modules = distroProperties.getModuleArtifacts();
String[] moduleFilenames = new String[modules.size()];

for (int i = 0; i < modules.size(); i ++) {
moduleFilenames[i] = modules.get(i).getDestFileName();
}

assertModulesInstalled(serverId, moduleFilenames);
Path modulesRoot = testDirectoryPath.resolve(Paths.get(serverId, "modules"));
File[] expectedFiles = modulesRoot.toFile().listFiles(f -> f.getName().endsWith(".omod"));
assertNotNull(expectedFiles);
assertThat(expectedFiles.length, equalTo(moduleFilenames.length));
for(String filename : moduleFilenames) {
assertPathPresent(modulesRoot.resolve(filename));
}
}

protected void addMockDbSettings() {
Expand Down Expand Up @@ -376,4 +383,18 @@ protected String getAnswers() {
answers = StringUtils.removeStart(answers, "[");
return answers;
}

protected String getLogContents() throws Exception {
File logFile = new File(testDirectory, "log.txt");
assertTrue(logFile.exists());
return FileUtils.readFileToString(logFile, "UTF-8");
}

protected void assertLogContains(String message) throws Exception {
assertTrue(getLogContents().contains(message));
}

protected void assertLogDoesNotContain(String message) throws Exception {
assertFalse(getLogContents().contains(message));
}
}
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package org.openmrs.maven.plugins;

import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.openmrs.maven.plugins.model.DistroProperties;
import org.openmrs.maven.plugins.utility.PropertiesUtils;

import java.io.File;
import java.util.Properties;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
Expand All @@ -35,7 +33,7 @@ public void shouldAddExclusionIfNoParentDefined() throws Exception {
executeExclusionTask(distroFile, "omod.uicommons");
assertNotNull(getDistroProperties());
assertTrue(getDistroProperties().getExclusions().contains("omod.uicommons"));
assertTrue(getLogContents().contains(AddExclusion.WARNING_NO_PARENT_DISTRO));
assertLogContains(AddExclusion.WARNING_NO_PARENT_DISTRO);
}

@Test
Expand All @@ -47,8 +45,8 @@ public void shouldAddExclusionForPropertyContainedInParent() throws Exception {
executeExclusionTask(distroFile, "omod.uicommons");
assertNotNull(getDistroProperties());
assertTrue(getDistroProperties().getExclusions().contains("omod.uicommons"));
assertFalse(getLogContents().contains(AddExclusion.WARNING_NO_PARENT_DISTRO));
assertFalse(getLogContents().contains(AddExclusion.WARNING_PROPERTY_NOT_IN_PARENT));
assertLogDoesNotContain(AddExclusion.WARNING_NO_PARENT_DISTRO);
assertLogDoesNotContain(AddExclusion.WARNING_PROPERTY_NOT_IN_PARENT);
}

@Test
Expand All @@ -60,8 +58,8 @@ public void shouldAddExclusionForPropertyContainedInDistro() throws Exception {
executeExclusionTask(distroFile, "omod.uicommons");
assertNotNull(getDistroProperties());
assertTrue(getDistroProperties().getExclusions().contains("omod.uicommons"));
assertFalse(getLogContents().contains(AddExclusion.WARNING_NO_PARENT_DISTRO));
assertFalse(getLogContents().contains(AddExclusion.WARNING_PROPERTY_NOT_IN_PARENT));
assertLogDoesNotContain(AddExclusion.WARNING_NO_PARENT_DISTRO);
assertLogDoesNotContain(AddExclusion.WARNING_PROPERTY_NOT_IN_PARENT);
}

@Test
Expand All @@ -73,14 +71,8 @@ public void shouldAddExclusionForPropertyNotContainedInParent() throws Exception
executeExclusionTask(distroFile, "omod.invalidmodulename");
assertNotNull(getDistroProperties());
assertTrue(getDistroProperties().getExclusions().contains("omod.invalidmodulename"));
assertFalse(getLogContents().contains(AddExclusion.WARNING_NO_PARENT_DISTRO));
assertTrue(getLogContents().contains(AddExclusion.WARNING_PROPERTY_NOT_IN_PARENT));
}

private String getLogContents() throws Exception {
File logFile = new File(testDirectory, "log.txt");
assertTrue(logFile.exists());
return FileUtils.readFileToString(logFile, "UTF-8");
assertLogDoesNotContain(AddExclusion.WARNING_NO_PARENT_DISTRO);
assertLogContains(AddExclusion.WARNING_PROPERTY_NOT_IN_PARENT);
}

private void executeExclusionTask(File distroFile, String exclusion) throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ protected void addTestResources() throws Exception {
@Override
public void setup() throws Exception {
super.setup();
serverId = setupTestServer();
serverId = setupTestServer("referenceapplication:2.2");
Server server = Server.loadServer(testDirectoryPath.resolve(serverId));
File firstDir = new File(testDirectory, "module1");
File secondDir = new File(testDirectory, "module2");
Expand Down
Loading