ARTEMIS-4390 Fix the upgrade-linux smoke test on Windows
The test cannot work on Windows unless I can make the `upgrade` CLI command respect my choice to upgrade a Linux distribution. This commit therefore adds a new `--linux` option for the `upgrade` command, and leverages it in the `upgrade-linux` smoke test. * The `--cygwin` option has been preserved for backwards compatibility. * The `IS_CYGWIN` attribute has been renamed to `IS_NIX` to reflect the change. * The OS "recognition" method (in `InstallAbstract::run`) has been updated to reflect the need for enforcing *nix behavior, which is now the default if all other methods fail.
This commit is contained in:
parent
ab3e67a24b
commit
999789bdc5
|
@ -756,7 +756,7 @@ public class Create extends InstallAbstract {
|
|||
writeEtc(ETC_ARTEMIS_PROFILE_CMD, etcFolder, filters, false);
|
||||
}
|
||||
|
||||
if (!IS_WINDOWS || IS_CYGWIN) {
|
||||
if (IS_NIX) {
|
||||
write(BIN_ARTEMIS, filters, true);
|
||||
makeExec(BIN_ARTEMIS);
|
||||
write(BIN_ARTEMIS_SERVICE, filters, true);
|
||||
|
@ -847,7 +847,7 @@ public class Create extends InstallAbstract {
|
|||
File service = new File(directory, BIN_ARTEMIS_SERVICE);
|
||||
context.out.println("");
|
||||
|
||||
if (!IS_WINDOWS || IS_CYGWIN) {
|
||||
if (IS_NIX) {
|
||||
context.out.println("Or you can run the broker in the background using:");
|
||||
context.out.println("");
|
||||
context.out.println(String.format(" \"%s\" start", path(service)));
|
||||
|
|
|
@ -52,8 +52,8 @@ public class InstallAbstract extends InputAbstract {
|
|||
@Option(names = "--windows", description = "Force Windows script creation. Default: based on your actual system.")
|
||||
protected boolean windows = false;
|
||||
|
||||
@Option(names = "--cygwin", description = "Force Cygwin script creation. Default: based on your actual system.")
|
||||
protected boolean cygwin = false;
|
||||
@Option(names = {"--cygwin", "--linux"}, description = "Force Linux or Cygwin script creation. Default: based on your actual system.")
|
||||
protected boolean nix = false;
|
||||
|
||||
@Option(names = "--java-options", description = "Extra Java options to be passed to the profile.")
|
||||
protected List<String> javaOptions;
|
||||
|
@ -93,12 +93,29 @@ public class InstallAbstract extends InputAbstract {
|
|||
}
|
||||
|
||||
protected boolean IS_WINDOWS;
|
||||
protected boolean IS_CYGWIN;
|
||||
protected boolean IS_NIX;
|
||||
|
||||
public Object run(ActionContext context) throws Exception {
|
||||
IS_WINDOWS = windows | System.getProperty("os.name").toLowerCase().trim().startsWith("win");
|
||||
IS_CYGWIN = cygwin | IS_WINDOWS && "cygwin".equals(System.getenv("OSTYPE"));
|
||||
|
||||
IS_NIX = false;
|
||||
IS_WINDOWS = false;
|
||||
if (nix) {
|
||||
IS_NIX = true;
|
||||
return null;
|
||||
}
|
||||
if (windows) {
|
||||
IS_WINDOWS = true;
|
||||
return null;
|
||||
}
|
||||
if ("cygwin".equals(System.getenv("OSTYPE"))) {
|
||||
IS_NIX = true;
|
||||
return null;
|
||||
}
|
||||
if (System.getProperty("os.name").toLowerCase().trim().startsWith("win")) {
|
||||
IS_WINDOWS = true;
|
||||
return null;
|
||||
}
|
||||
// Fallback to *nix
|
||||
IS_NIX = true;
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -140,7 +157,7 @@ public class InstallAbstract extends InputAbstract {
|
|||
|
||||
// and then writing out in the new target encoding.. Let's also replace \n with the values
|
||||
// that is correct for the current platform.
|
||||
String separator = unixTarget && IS_CYGWIN ? "\n" : System.getProperty("line.separator");
|
||||
String separator = unixTarget && IS_NIX ? "\n" : System.getProperty("line.separator");
|
||||
content = content.replaceAll("\\r?\\n", Matcher.quoteReplacement(separator));
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(content.getBytes(encoding));
|
||||
try (FileOutputStream fout = new FileOutputStream(target)) {
|
||||
|
|
|
@ -89,7 +89,7 @@ public class Upgrade extends InstallAbstract {
|
|||
final File artemisScript = new File(bin, Create.ARTEMIS);
|
||||
|
||||
if (etc == null || etc.equals("etc")) {
|
||||
if (IS_WINDOWS && !IS_CYGWIN) {
|
||||
if (IS_WINDOWS) {
|
||||
String pattern = "set ARTEMIS_INSTANCE_ETC=";
|
||||
etcFolder = getETC(context, etcFolder, artemisCmdScript, pattern);
|
||||
} else {
|
||||
|
@ -157,7 +157,7 @@ public class Upgrade extends InstallAbstract {
|
|||
"set ARTEMIS_INSTANCE=\"", "set ARTEMIS_DATA_DIR=", "set ARTEMIS_ETC_DIR=", "set ARTEMIS_OOME_DUMP=", "set ARTEMIS_INSTANCE_URI=", "set ARTEMIS_INSTANCE_ETC_URI=");
|
||||
}
|
||||
|
||||
if (!IS_WINDOWS || IS_CYGWIN) {
|
||||
if (IS_NIX) {
|
||||
final File artemisScriptTmp = new File(tmp, Create.ARTEMIS);
|
||||
final File artemisScriptBkp = new File(binBkp, Create.ARTEMIS);
|
||||
|
||||
|
|
|
@ -1276,8 +1276,11 @@
|
|||
</goals>
|
||||
<configuration>
|
||||
<instance>${basedir}/target/classes/servers/linuxUpgrade</instance>
|
||||
<args>
|
||||
<arg>--linux</arg>
|
||||
<!-- we don't pass the java memory argumnent on purpose,
|
||||
as the upgrade should keep the relevant JVM arguments during the upgrade -->
|
||||
</args>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
|
|
Loading…
Reference in New Issue