This is an automated email from the ASF dual-hosted git repository.
clebertsuconic pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/activemq-artemis.git
The following commit(s) were added to refs/heads/main by this push:
new 999789bdc5 ARTEMIS-4390 Fix the upgrade-linux smoke test on Windows
999789bdc5 is described below
commit 999789bdc5ab5e397077b4488f8fdbadbafb21d7
Author: Å mucr Jan <[email protected]>
AuthorDate: Tue Aug 15 08:38:31 2023 +0200
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.
---
.../activemq/artemis/cli/commands/Create.java | 4 +--
.../artemis/cli/commands/InstallAbstract.java | 31 +++++++++++++++++-----
.../activemq/artemis/cli/commands/Upgrade.java | 4 +--
tests/smoke-tests/pom.xml | 7 +++--
4 files changed, 33 insertions(+), 13 deletions(-)
diff --git
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
index 1717d042fb..3f388da583 100644
---
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
+++
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Create.java
@@ -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)));
diff --git
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InstallAbstract.java
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InstallAbstract.java
index e13f1c8b93..452d5509e6 100644
---
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InstallAbstract.java
+++
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/InstallAbstract.java
@@ -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)) {
diff --git
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Upgrade.java
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Upgrade.java
index 9185ef4dd4..f8086eac15 100644
---
a/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Upgrade.java
+++
b/artemis-cli/src/main/java/org/apache/activemq/artemis/cli/commands/Upgrade.java
@@ -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);
diff --git a/tests/smoke-tests/pom.xml b/tests/smoke-tests/pom.xml
index 0423f57923..514298ab60 100644
--- a/tests/smoke-tests/pom.xml
+++ b/tests/smoke-tests/pom.xml
@@ -1276,8 +1276,11 @@
</goals>
<configuration>
<instance>${basedir}/target/classes/servers/linuxUpgrade</instance>
- <!-- we don't pass the java memory argumnent on purpose,
- as the upgrade should keep the relevant JVM
arguments during the upgrade -->
+ <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>