From de7969f2bb38d399faa6c4c420aa527f278723fa Mon Sep 17 00:00:00 2001 From: Karl DeBisschop Date: Sat, 17 Oct 2020 17:20:32 -0400 Subject: [PATCH] Console logging enhancements (#58) * Simplify console capture some. * Reduce length of STDERR_TOKEN by removing its predictable part ("STDERR_"), which makes it less likely to get split on a packet boundary * Resolve some minor code quality warnings * Switch to Java 11 tool chain (but compile 1.8 byte code) Co-authored-by: Karl DeBisschop --- .github/ISSUE_TEMPLATE/bug_report.md | 2 +- .github/ISSUE_TEMPLATE/feature_request.md | 2 +- .github/workflows/gradle.yml | 43 ++++-- .gitignore | 22 +-- CODE_OF_CONDUCT.md | 2 +- CONTRIBUTING.md | 17 ++- README.md | 2 +- build.gradle | 36 +++-- gradle/wrapper/gradle-wrapper.jar | Bin 58910 -> 59203 bytes gradle/wrapper/gradle-wrapper.properties | 5 +- gradlew | 2 +- gradlew.bat | 21 +-- .../bioraft/rundeck/rancher/Constants.java | 8 +- .../rundeck/rancher/RancherAddService.java | 3 +- .../rancher/RancherWebSocketListener.java | 42 +++--- .../rancher/RancherAddServiceTest.java | 2 +- .../rancher/RancherLaunchConfigTest.java | 2 +- .../RancherResourceModelSourceTest.java | 20 +-- .../rancher/RancherWebSocketListenerTest.java | 27 ++-- src/test/resources/container.json | 36 ++--- src/test/resources/containers.json | 140 +++++++++--------- src/test/resources/launchConfig.json | 8 +- src/test/resources/service.json | 36 ++--- src/test/resources/services.json | 36 ++--- 24 files changed, 267 insertions(+), 247 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index dd84ea7..5aec9b3 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,5 +1,5 @@ --- -name: Bug report +name: Bug Report about: Create a report to help us improve title: '' labels: '' diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index bbcbbe7..769d4d3 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -8,7 +8,7 @@ assignees: '' --- **Is your feature request related to a problem? Please describe.** -A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] +A clear and concise description of what the problem is. Ex. I'm always frustrated when... **Describe the solution you'd like** A clear and concise description of what you want to happen. diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index 4d1216a..a3c3cb0 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -8,19 +8,30 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v1 - - name: Set up JDK 1.8 - uses: actions/setup-java@v1 - with: - java-version: 1.8 - - name: Run unit tests - run: ./gradlew test - - name: Determine coverage - run: ./gradlew jacocoTestReport - - name: Scan with Sonar - run: ./gradlew sonar - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - - name: Build with Gradle - run: ./gradlew build + - uses: actions/checkout@v2 + with: + # Shallow clones should be disabled for a better relevancy of analysis + fetch-depth: 0 + - name: Set up JDK 11 + uses: actions/setup-java@v1 + with: + java-version: 11 + - name: Cache Gradle packages + uses: actions/cache@v1 + with: + path: ~/.gradle/caches + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle') }} + restore-keys: ${{ runner.os }}-gradle + - name: Cache SonarCloud packages + uses: actions/cache@v1 + with: + path: ~/.sonar/cache + key: ${{ runner.os }}-sonar + restore-keys: ${{ runner.os }}-sonar + - name: Build and analyze + run: ./gradlew build jacocoTestReport sonarqube --info + env: + # Needed to get some information about the pull request, if any + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + # SonarCloud access token should be generated from https://sonarcloud.io/account/security/ + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.gitignore b/.gitignore index 549076d..45ba6c7 100644 --- a/.gitignore +++ b/.gitignore @@ -1,10 +1,12 @@ +/.java-version + # Eclipse -.classpath -.project -.settings/ +/.classpath +/.project +/.settings/ # Intellij -.idea/ +/.idea/ *.iml *.iws @@ -12,13 +14,13 @@ .DS_Store # Maven -log/ -target/ -.gradle/ -build/ -out/ +/log/ +/target/ +/.gradle/ +/build/ +/out/ # Integration tests -build.log +/build.log /bin/ diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 44beca3..4af9881 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -4,7 +4,7 @@ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and -our community a harassment-free experience for everyone, regardless of age, body +community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e0f8dae..229c5da 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,18 +2,25 @@ #### **Did you find a bug?** -* **Do not open up a GitHub issue if the bug is a security vulnerability**, and instead communicate directly with the maintainer(s). +* **Do not open up a GitHub issue if the bug is a security vulnerability**, + and instead communicate directly with the maintainer(s). -* **Ensure the bug was not already reported** by searching on GitHub under [Issues](https://github.com/kdebisschop/rundeck-rancher-node-plugin/issues). +* **Ensure the bug was not already reported** by searching on GitHub under + [Issues](https://github.com/kdebisschop/rundeck-rancher-node-plugin/issues). -* If you're unable to find an open issue addressing the problem, [open a new one](https://github.com/kdebisschop/rundeck-rancher-node-plugin/issues/new). Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** or an **executable test case** demonstrating the expected behavior that is not occurring. +* If you're unable to find an open issue addressing the problem, + [open a new one](https://github.com/kdebisschop/rundeck-rancher-node-plugin/issues/new). + Be sure to include a **title and clear description**, as much relevant information as possible, and a **code sample** + or **executable test case** demonstrating the expected behavior that is not occurring. #### **Did you write a patch that fixes a bug or intorduces a new feature?** * Open a new GitHub pull request with the patch. -* Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable. +* Ensure the PR description clearly describes the problem and solution. + Include the relevant issue number if applicable. #### **Do you have questions about the source code?** -* Ask any question about this plugin on the [ServerFault Rundeck tag](https://serverfault.com/questions/tagged/rundeck). +* Ask any question about this plugin on the + [ServerFault Rundeck tag](https://serverfault.com/questions/tagged/rundeck). diff --git a/README.md b/README.md index 54f5f27..cfee9a9 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ Features: ### Rancher File Copier Copies files to a node. Can be configured to use Rancher CLI if it is installed and -available. Otherwise assembles file from Base64-encoded parts transmitted via Rancher +available. Otherwise, assembles files from Base64-encoded parts transmitted via Rancher API. To distribute to all containers in a stack's service, omit the filter for "seen". diff --git a/build.gradle b/build.gradle index 957eac3..7b58a53 100644 --- a/build.gradle +++ b/build.gradle @@ -29,6 +29,16 @@ java { targetCompatibility = JavaVersion.VERSION_1_8 } +compileJava { + options.release.set(8) + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" +} + +compileTestJava { + options.release.set(8) + options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" +} + defaultTasks 'clean','test','jacocoTestReport','build' ext.rundeckPluginVersion = '1.2' ext.pluginClassNames='com.bioraft.rundeck.rancher.RancherNodeExecutorPlugin,' + @@ -75,23 +85,19 @@ configurations { } dependencies { - implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.10.1' - - implementation group: 'com.squareup.okhttp3', name: 'okhttp', version: '3.12.0' - - implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.13.2' - implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.13.2' - implementation ( - 'org.rundeck:rundeck-core:3.3.+', - 'org.rundeck:rundeck-storage-api:3.3.+', + 'com.fasterxml.jackson.core:jackson-databind:2.10.1', + 'com.squareup.okhttp3:okhttp:3.14.9', + 'org.apache.logging.log4j:log4j-api:2.13.2', + 'org.apache.logging.log4j:log4j-core:2.13.2', + 'org.rundeck:rundeck-core:3.3.4-20201007', + 'org.rundeck:rundeck-storage-api:3.3.4-20201007', ) - - testImplementation group: 'junit', name: 'junit', version:'4.12' - testImplementation ( - 'org.mockito:mockito-core:3.+', - 'com.squareup.okhttp3:mockwebserver:3.13.1' + 'com.squareup.okhttp3:mockwebserver:3.11.0', + 'junit:junit:4.12', + 'org.mockito:mockito-core:3.+', + 'org.slf4j:slf4j-simple:1.7.30+', ) } @@ -128,5 +134,5 @@ jar { } wrapper { - gradleVersion = '6.5.1' + gradleVersion = '6.6.1' } diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 62d4c053550b91381bbd28b1afc82d634bf73a8a..e708b1c023ec8b20f512888fe07c5bd3ff77bb8f 100644 GIT binary patch delta 6656 zcmY+Ibx_pN*Z*PZ4(U#j1qtbvrOTyO8fghZ8kYJfEe%U|$dV!@ASKczEZq$fg48M@ z;LnHO_j#Uq?%bL4dY^md%$$4Y+&@nKC|1uHR&59YNhubGh72|a#ylPdh9V+akp|I; zPk^W-a00GrFMkz_NSADdv2G2-i6rb=cB_@WnG(**4ZO$=96R=t|NZ@|0_z&q3GwO^ ziUFcuj$a9QaZ3j?xt`5#q`sT-ufrtBP0nt3IA&dr*+VCsBzBVW?vZ6eZr0oD%t33z zm~-5IVsjy(F>;S~Pm@bxX85>Z*@(QL6i3JQc?1ryQFcC@X^2^mZWhFv|v? z49>l|nA&XNQ6#OvccUTyBMB*WO#NA;FW5|eE_K6dtVYP2G?uUZ09!`Iq1IF2gA(aS zLu@G^cQJmh=x?-YsYa@E6QnE5+1@ds&0f#OQRDl^GnIT_m84G5XY%W z;Ck6bk^Oeu*Ma-XmxI5GjqzWNbJMsQF4)WfMZEA{oxW0E32e)*JfG}3otPishIQBw zkBe6N#4pKPN>q1R6G1@5&(u#5yPEToMBB6_oEK|q z@(i5j!?;NNCv~=HvW%zF&1yWBq(nJa_#``G&SRmQvE|jePUPs{J!$TacM|e}Fsceb zx+76|mD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Bm69Jf+C!h_}ep zwzpQj9sRA94<{x3{~z&ix-DwX;RAzka)4-#6ZHJqKh|SVuO|>Yrv+m30+!|sK<-|E z=)5E->#y<_1V|T1f%Af!ZYqXg}`O zI$qKOWdnclF`%_Z`WGOe{`A`l-#a?s=Q1a#@BOWmExH2;Wl`OB!B-%lq3nO{4=WO& z#k_x|N&(qzm*6S{G*|GCegF2N2ulC+(58z2DG~yUs}i8zvRf&$CJCaexJ6Xu!`qz( z)*v8*kAE#D0KCo*s{8^Rbg=`*E2MzeIt0|x55%n-gO&yX#$l=3W7-_~&(G8j1E(XB hw}tl`5K!1C(72%nnjQrp<7@!WCh47rWB+@R{{wClNUHz< diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ff89b19..12d38de 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Fri May 29 14:32:58 EDT 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.4.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/gradlew b/gradlew index fbd7c51..4f906e0 100755 --- a/gradlew +++ b/gradlew @@ -130,7 +130,7 @@ fi if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then APP_HOME=`cygpath --path --mixed "$APP_HOME"` CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - + JAVACMD=`cygpath --unix "$JAVACMD"` # We build the pattern for arguments to be converted via cygpath diff --git a/gradlew.bat b/gradlew.bat index 5093609..107acd3 100644 --- a/gradlew.bat +++ b/gradlew.bat @@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if "%ERRORLEVEL%" == "0" goto execute echo. echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. @@ -54,7 +54,7 @@ goto fail set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init +if exist "%JAVA_EXE%" goto execute echo. echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% @@ -64,21 +64,6 @@ echo location of your Java installation. goto fail -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - :execute @rem Setup the command line @@ -86,7 +71,7 @@ set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar @rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* :end @rem End local scope for the variables with windows NT shell diff --git a/src/main/java/com/bioraft/rundeck/rancher/Constants.java b/src/main/java/com/bioraft/rundeck/rancher/Constants.java index ed5f392..2727876 100644 --- a/src/main/java/com/bioraft/rundeck/rancher/Constants.java +++ b/src/main/java/com/bioraft/rundeck/rancher/Constants.java @@ -34,6 +34,9 @@ private Constants() { public static final int INTERVAL_MILLIS = 2000; + @SuppressWarnings("SpellCheckingInspection") + public static final String STDERR_TOKEN = "STDERR_6v9ZvwThpU1FtyrlIBf4UIC8"; + // These are fields in JSON from Rancher API. public static final String NODE_ID = "id"; public static final String NODE_NAME = "name"; @@ -71,7 +74,10 @@ private Constants() { public static final String DISPLAY_CODE = "CODE"; public static final String SYNTAX_MODE_JSON = "json"; - public static final String PATH_PROJECTS = "/projects/"; + // Project path in Rancher. + public static final String FILE_SEP = System.getProperty("file.separator"); + public static final String PATH_PROJECTS = FILE_SEP + "projects" + FILE_SEP; + public static final String JSON_PAGINATION = "pagination"; public static final String OPT_DATA_VOLUMES = "dataVolumes"; diff --git a/src/main/java/com/bioraft/rundeck/rancher/RancherAddService.java b/src/main/java/com/bioraft/rundeck/rancher/RancherAddService.java index 39d5bd1..d9cfa41 100644 --- a/src/main/java/com/bioraft/rundeck/rancher/RancherAddService.java +++ b/src/main/java/com/bioraft/rundeck/rancher/RancherAddService.java @@ -82,7 +82,6 @@ public class RancherAddService implements StepPlugin { @RenderingOption(key = CODE_SYNTAX_MODE, value = SYNTAX_MODE_JSON) private String ports; - private final HttpClient client; public RancherAddService () { @@ -125,6 +124,8 @@ public void executeStep(final PluginStepContext context, final Map >(while read line;do echo \"" + STDERR_TOK - + " $line\";done) ;"; + String cmd = String.join(" ", command); + String job = "( " + cmd + " ) 2> >(while read line;do echo \"" + STDERR_TOKEN + "$line\";done)"; // Note that bash is required to support adding a prefix token to STDERR. - return new String[]{ "bash", "-c", "printf $$" + file + job + "printf ' %s' $?" + file }; + return new String[]{ "bash", "-c", "printf $$ >>" + file + job + ";printf ' %s' $? >>" + file }; } @Override @@ -287,15 +289,15 @@ private void put(String url, String accessKey, String secretKey, File input, Str int encodedSize = encoded.length(); int chunkSize = 5000; - String redirector = ">"; + String redirection = ">"; for (int i = 0; i < encodedSize; i = i + chunkSize) { String text = encoded.substring(i, Math.min(i + chunkSize, encodedSize)); // The command cats a HEREDOC to the desired file. Note the quote that ensures // the contents are not interpreted as shell variables. String[] command = { "sh", "-c", - "cat <<'" + marker + "'" + redirector + "/tmp/" + marker + "\n" + text + "\n" + marker }; + "cat <<'" + marker + "'" + redirection + "/tmp/" + marker + "\n" + text + "\n" + marker }; this.runCommand(command, 50); - redirector = ">>"; + redirection = ">>"; } String[] command = { "sh", "-c", "base64 -d /tmp/" + marker + " > " + file + "; rm /tmp/" + marker }; @@ -392,14 +394,14 @@ public void logDockerStream(byte[] bytes) { BufferedReader stringReader; try (MessageReader reader = new MessageReader(ByteSource.wrap(bytes).openStream())) { while ((message = reader.nextMessage()) != null) { - // If logging to RunDeck, we send lines beginning with STRDERR_TOK to ERR_LEVEL. - // To do that, we make a BufferedReader and process it line-by-line in log - // function. + // If logging to RunDeck, we send lines beginning with STDERR_TOK to ERR_LEVEL. + // To do that, we make a BufferedReader and process it line-by-line in log function. + String nextMessage = new String(message.content.array(), StandardCharsets.UTF_8); if (listener != null) { - stringReader = new BufferedReader(new StringReader(new String(message.content.array()))); + stringReader = new BufferedReader(new StringReader(nextMessage)); log(stringReader); } else { - output.append(new String(message.content.array())); + output.append(nextMessage); } nextHeader = reader.nextHeader(); } @@ -418,8 +420,8 @@ public void logDockerStream(byte[] bytes) { private void log(BufferedReader stringReader) throws IOException { String line; while ((line = stringReader.readLine()) != null) { - if (line.startsWith(STDERR_TOK)) { - this.log(Constants.WARN_LEVEL, line.substring(STDERR_TOKLEN - 1) + "\n"); + if (line.startsWith(STDERR_TOKEN)) { + this.log(Constants.WARN_LEVEL, line.substring(STDERR_TOKEN_LENGTH) + "\n"); } else { this.log(Constants.INFO_LEVEL, line + "\n"); } diff --git a/src/test/java/com/bioraft/rundeck/rancher/RancherAddServiceTest.java b/src/test/java/com/bioraft/rundeck/rancher/RancherAddServiceTest.java index 39a506f..c47eebd 100644 --- a/src/test/java/com/bioraft/rundeck/rancher/RancherAddServiceTest.java +++ b/src/test/java/com/bioraft/rundeck/rancher/RancherAddServiceTest.java @@ -66,7 +66,7 @@ public class RancherAddServiceTest extends PluginStepTest { @Before public void implSetUp() { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); setUp(); } diff --git a/src/test/java/com/bioraft/rundeck/rancher/RancherLaunchConfigTest.java b/src/test/java/com/bioraft/rundeck/rancher/RancherLaunchConfigTest.java index eefd5e6..c83b006 100644 --- a/src/test/java/com/bioraft/rundeck/rancher/RancherLaunchConfigTest.java +++ b/src/test/java/com/bioraft/rundeck/rancher/RancherLaunchConfigTest.java @@ -34,7 +34,7 @@ public class RancherLaunchConfigTest { public void setUp() throws Exception { reference = (ObjectNode) readFromInputStream(getResourceStream()); objectNode = (ObjectNode) readFromInputStream(getResourceStream()); - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); } @Test diff --git a/src/test/java/com/bioraft/rundeck/rancher/RancherResourceModelSourceTest.java b/src/test/java/com/bioraft/rundeck/rancher/RancherResourceModelSourceTest.java index ad2fa6a..84e84a8 100644 --- a/src/test/java/com/bioraft/rundeck/rancher/RancherResourceModelSourceTest.java +++ b/src/test/java/com/bioraft/rundeck/rancher/RancherResourceModelSourceTest.java @@ -68,7 +68,7 @@ public void setUp() { configuration.setProperty(CONFIG_SECRETKEY, "secretKey"); configuration.setProperty(CONFIG_ACCESSKEY_PATH, "keys/rancher/access.key"); configuration.setProperty(CONFIG_SECRETKEY_PATH, "keys/rancher/secret.key"); - configuration.setProperty(CONFIG_STACK_FILTER, "mysite-dev"); + configuration.setProperty(CONFIG_STACK_FILTER, "my-site-dev"); configuration.setProperty(CONFIG_LIMIT_ONE_CONTAINER, "true"); configuration.setProperty(CONFIG_HANDLE_SYSTEM, "Exclude"); configuration.setProperty(CONFIG_HANDLE_GLOBAL, "Exclude"); @@ -125,11 +125,11 @@ public void processContainers() throws ResourceModelSourceException, IOException assertEquals(1, nodeList.getNodes().size()); Iterator iterator = nodeList.iterator(); INodeEntry node = iterator.next(); - assertEquals("myEnvironment_mysite-dev-frontend-1", node.getNodename()); + assertEquals("myEnvironment_my-site-dev-frontend-1", node.getNodename()); assertEquals("1h70", node.getHostname()); assertEquals("root", node.getUsername()); Map attributes = node.getAttributes(); - assertEquals("abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", attributes.get("externalId")); + assertEquals("6chars6chars6chars6chars6chars6chars6chars6chars", attributes.get("externalId")); assertEquals("running", attributes.get("state")); assertFalse(iterator.hasNext()); } @@ -353,23 +353,23 @@ private String itemPlusText() { ",\"environment\": \"" + environment + "\"" + // ",\"image\": \"image" + "1" + "\"" + // ",\"labels\": {\n" + - " \"com.example.description\": \"mysite.development.example.com\",\n" + + " \"com.example.description\": \"my-site.development.example.com\",\n" + " \"com.example.group\": \"dev\",\n" + " \"com.example.service\": \"frontend\",\n" + - " \"com.example.site\": \"mysite\",\n" + + " \"com.example.site\": \"my-site\",\n" + " \"io.rancher.cni.network\": \"ipsec\",\n" + " \"io.rancher.cni.wait\": \"true\",\n" + - " \"io.rancher.project.name\": \"mysite-dev\",\n" + - " \"io.rancher.project_service.name\": \"mysite-dev/frontend\",\n" + + " \"io.rancher.project.name\": \"my-site-dev\",\n" + + " \"io.rancher.project_service.name\": \"my-site-dev/frontend\",\n" + " \"io.rancher.service.deployment.unit\": \"00000000-0000-0000-0000-000000000000\",\n" + - " \"io.rancher.stack_service.name\": \"mysite-dev/frontend\",\n" + + " \"io.rancher.stack_service.name\": \"my-site-dev/frontend\",\n" + " \"io.rancher.service.hash\": \"0123456789012345678901234567890123456789\",\n" + " \"io.rancher.service.launch.config\": \"io.rancher.service.primary.launch.config\",\n" + - " \"io.rancher.stack.name\": \"mysite-dev\",\n" + + " \"io.rancher.stack.name\": \"my-site-dev\",\n" + " \"io.rancher.container.ip\": \"10.0.0.11/16\",\n" + " \"io.rancher.container.uuid\": \"00000000-0000-0000-0000-000000000000\",\n" + " \"io.rancher.container.mac_address\": \"11:22:33:44:55:66\",\n" + - " \"io.rancher.container.name\": \"mysite-dev-frontend-1\"\n" + + " \"io.rancher.container.name\": \"my-site-dev-frontend-1\"\n" + "}\n" + // ",\"" + accessKeyPath + "\": \"" + accessKeyPath + "1" + "\"" + // ",\"" + secretKeyPath + "\": \"" + secretKeyPath + "1" + "\"" + // diff --git a/src/test/java/com/bioraft/rundeck/rancher/RancherWebSocketListenerTest.java b/src/test/java/com/bioraft/rundeck/rancher/RancherWebSocketListenerTest.java index b3ad4ff..747a6d6 100644 --- a/src/test/java/com/bioraft/rundeck/rancher/RancherWebSocketListenerTest.java +++ b/src/test/java/com/bioraft/rundeck/rancher/RancherWebSocketListenerTest.java @@ -13,6 +13,7 @@ import java.io.IOException; import java.util.concurrent.TimeUnit; +import static com.bioraft.rundeck.rancher.Constants.STDERR_TOKEN; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.mockito.Mockito.*; @@ -29,7 +30,7 @@ public class RancherWebSocketListenerTest { @Before public void setup() throws IOException { - MockitoAnnotations.initMocks(this); + MockitoAnnotations.openMocks(this); mockWebServer = new MockWebServer(); mockWebServer.start(); } @@ -61,11 +62,11 @@ public void testRunJob() throws InterruptedException, IOException { int timeout = 1; MockResponse mockedResponse = new MockResponse(); mockedResponse.setResponseCode(200); - mockedResponse.setBody("{\"url\":\"" + url + "\", \"token\":\"abcdef\"}"); + mockedResponse.setBody("{\"url\":\"" + url + "\", \"token\":\"6chars\"}"); RancherWebSocketListener serverListener = new RancherWebSocketListener(); MockResponse upgrade = new MockResponse().withWebSocketUpgrade(serverListener); mockWebServer.enqueue(mockedResponse); - mockWebServer.enqueue(upgrade.setBody("abcdefghijklmnop")); + mockWebServer.enqueue(upgrade.setBody("6chars-plus-more")); mockWebServer.takeRequest(200, TimeUnit.MILLISECONDS); mockWebServer.enqueue(mockedResponse); doNothing().when(listener).log(anyInt(), anyString()); @@ -121,41 +122,41 @@ public void throwExceptionWhenTokenInvalid() throws IOException, InterruptedExce @Test public void testLogDockerStream() { RancherWebSocketListener subject = new RancherWebSocketListener(listener, new StringBuilder()); - byte[] bytes = "abcdef".getBytes(); + byte[] bytes = "6chars".getBytes(); doNothing().when(listener).log(anyInt(), anyString()); subject.logDockerStream(bytes); // Buffer is designed to add a line feed at end of message. - verify(listener, times(1)).log(2, "abcdef\n"); + verify(listener, times(1)).log(2, "6chars\n"); } @Test public void testLogDockerStreamStderr() { RancherWebSocketListener subject = new RancherWebSocketListener(listener, new StringBuilder()); - byte[] bytes = ("STDERR_6v9ZvwThpU1FtyrlIBf4UIC8" + "abcde\n").getBytes(); + byte[] bytes = (STDERR_TOKEN + "chars\n").getBytes(); doNothing().when(listener).log(anyInt(), anyString()); subject.logDockerStream(bytes); // Buffer is designed to add a line feed at end of message. - verify(listener, times(1)).log(1, "abcde\n"); + verify(listener, times(1)).log(1, "chars\n"); } @Test public void testLogDockerStreamMixed() { RancherWebSocketListener subject = new RancherWebSocketListener(listener, new StringBuilder()); - byte[] bytes = ("STDERR_6v9ZvwThpU1FtyrlIBf4UIC8" + "abcde\nabcde\n").getBytes(); + byte[] bytes = (STDERR_TOKEN + "chars\nchars\n").getBytes(); doNothing().when(listener).log(anyInt(), anyString()); subject.logDockerStream(bytes); // Buffer is designed to add a line feed at end of message. - verify(listener, times(1)).log(2, "abcde\n"); + verify(listener, times(1)).log(2, "chars\n"); } @Test public void testLogDockerStreamMixed2() { RancherWebSocketListener subject = new RancherWebSocketListener(listener, new StringBuilder()); - byte[] bytes = ("abcde\n" + "STDERR_6v9ZvwThpU1FtyrlIBf4UIC8" + "abcde\n").getBytes(); + byte[] bytes = ("chars\n" + STDERR_TOKEN + "chars\n").getBytes(); doNothing().when(listener).log(anyInt(), anyString()); subject.logDockerStream(bytes); // Buffer is designed to add a line feed at end of message. - verify(listener, times(1)).log(2, "abcde\n"); + verify(listener, times(1)).log(2, "chars\n"); } @Test @@ -180,8 +181,8 @@ public void testLogDockerStreamEmptyWithNoListener() { public void testLogDockerStreamStderrWithNoListener() { StringBuilder stringBuilder = new StringBuilder(); RancherWebSocketListener subject = new RancherWebSocketListener(null, stringBuilder); - byte[] bytes = ("STDERR_6v9ZvwThpU1FtyrlIBf4UIC8" + "aaa").getBytes(); + byte[] bytes = (STDERR_TOKEN + "aaa").getBytes(); subject.logDockerStream(bytes); - assertEquals("STDERR_6v9ZvwThpU1FtyrlIBf4UIC8aaa", stringBuilder.toString()); + assertEquals(STDERR_TOKEN + "aaa", stringBuilder.toString()); } } diff --git a/src/test/resources/container.json b/src/test/resources/container.json index 127ad31..683761c 100644 --- a/src/test/resources/container.json +++ b/src/test/resources/container.json @@ -32,7 +32,7 @@ "proxy": "https://rancher.example.com/v2-beta/projects/1a10/containers/1i234/?action=proxy" }, "baseType": "instance", - "name": "mysite-dev-frontend-1", + "name": "my-site-dev-frontend-1", "state": "running", "accountId": "1a10", "blkioDeviceOptions": null, @@ -58,9 +58,9 @@ "/run/secrets": "1v356188" }, "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef:/run/secrets" + "6chars6chars6chars6chars6chars6chars6chars6chars:/run/secrets" ], "dataVolumesFrom": null, "deploymentUnitUuid": "00000000-0000-0000-0000-000000000000", @@ -72,20 +72,20 @@ ], "dnsOpt": null, "dnsSearch": [ - "mysite-dev.rancher.internal", - "frontend.mysite-dev.rancher.internal", + "my-site-dev.rancher.internal", + "frontend.my-site-dev.rancher.internal", "rancher.internal" ], "domainName": null, "entryPoint": null, "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "expose": null, - "externalId": "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", + "externalId": "6chars6chars6chars6chars6chars6chars6chars6chars", "extraHosts": null, "firstRunning": "2019-12-28T05:24:56Z", "firstRunningTS": 1577510696000, @@ -120,22 +120,22 @@ "kind": "container", "labels": { "io.rancher.service.deployment.unit": "00000000-0000-0000-0000-000000000000", - "io.rancher.stack_service.name": "mysite-dev/frontend", + "io.rancher.stack_service.name": "my-site-dev/frontend", "io.rancher.service.launch.config": "io.rancher.service.primary.launch.config", "com.example.service": "frontend", - "io.rancher.project.name": "mysite-dev", - "io.rancher.project_service.name": "mysite-dev/frontend", - "com.example.description": "mysite.development.example.com", + "io.rancher.project.name": "my-site-dev", + "io.rancher.project_service.name": "my-site-dev/frontend", + "com.example.description": "my-site.development.example.com", "com.example.group": "dev", - "io.rancher.stack.name": "mysite-dev", + "io.rancher.stack.name": "my-site-dev", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.container.ip": "10.0.0.11/16", "io.rancher.container.uuid": "00000000-0000-0000-0000-000000000000", "io.rancher.cni.network": "ipsec", "io.rancher.cni.wait": "true", "io.rancher.container.mac_address": "11:22:33:44:55:66", - "io.rancher.container.name": "mysite-dev-frontend-1" + "io.rancher.container.name": "my-site-dev-frontend-1" }, "logConfig": { "type": "logConfig" @@ -150,7 +150,7 @@ { "type": "mountEntry", "volumeName": "/clientdata/shared", - "instanceName": "mysite-dev-frontend-1", + "instanceName": "my-site-dev-frontend-1", "path": "/var/shared", "permission": "ro", "instanceId": "1i234", @@ -158,8 +158,8 @@ }, { "type": "mountEntry", - "volumeName": "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", - "instanceName": "mysite-dev-frontend-1", + "volumeName": "6chars6chars6chars6chars6chars6chars6chars6chars", + "instanceName": "my-site-dev-frontend-1", "path": "/run/secrets", "permission": "rw", "instanceId": "1i234", diff --git a/src/test/resources/containers.json b/src/test/resources/containers.json index 2d6453a..b805990 100644 --- a/src/test/resources/containers.json +++ b/src/test/resources/containers.json @@ -34,7 +34,7 @@ "proxy": "https://rancher.example.com/v2-beta/projects/1a10/containers/1i234/?action=proxy" }, "baseType": "instance", - "name": "mysite-dev-frontend-1", + "name": "my-site-dev-frontend-1", "state": "running", "accountId": "1a10", "blkioDeviceOptions": null, @@ -60,9 +60,9 @@ "/run/secrets": "1v356188" }, "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef:/run/secrets" + "6chars6chars6chars6chars6chars6chars6chars6chars:/run/secrets" ], "dataVolumesFrom": null, "deploymentUnitUuid": "00000000-0000-0000-0000-000000000000", @@ -74,20 +74,20 @@ ], "dnsOpt": null, "dnsSearch": [ - "mysite-dev.rancher.internal", - "frontend.mysite-dev.rancher.internal", + "my-site-dev.rancher.internal", + "frontend.my-site-dev.rancher.internal", "rancher.internal" ], "domainName": null, "entryPoint": null, "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "expose": null, - "externalId": "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", + "externalId": "6chars6chars6chars6chars6chars6chars6chars6chars", "extraHosts": null, "firstRunning": "2019-12-28T05:24:56Z", "firstRunningTS": 1577510696000, @@ -122,22 +122,22 @@ "kind": "container", "labels": { "io.rancher.service.deployment.unit": "00000000-0000-0000-0000-000000000000", - "io.rancher.stack_service.name": "mysite-dev/frontend", + "io.rancher.stack_service.name": "my-site-dev/frontend", "io.rancher.service.launch.config": "io.rancher.service.primary.launch.config", "com.example.service": "frontend", - "io.rancher.project.name": "mysite-dev", - "io.rancher.project_service.name": "mysite-dev/frontend", - "com.example.description": "mysite.development.example.com", + "io.rancher.project.name": "my-site-dev", + "io.rancher.project_service.name": "my-site-dev/frontend", + "com.example.description": "my-site.development.example.com", "com.example.group": "dev", - "io.rancher.stack.name": "mysite-dev", + "io.rancher.stack.name": "my-site-dev", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.container.ip": "10.0.0.11/16", "io.rancher.container.uuid": "00000000-0000-0000-0000-000000000000", "io.rancher.cni.network": "ipsec", "io.rancher.cni.wait": "true", "io.rancher.container.mac_address": "11:22:33:44:55:66", - "io.rancher.container.name": "mysite-dev-frontend-1" + "io.rancher.container.name": "my-site-dev-frontend-1" }, "logConfig": { "type": "logConfig" @@ -152,7 +152,7 @@ { "type": "mountEntry", "volumeName": "/clientdata/shared", - "instanceName": "mysite-dev-frontend-1", + "instanceName": "my-site-dev-frontend-1", "path": "/var/shared", "permission": "ro", "instanceId": "1i234", @@ -160,8 +160,8 @@ }, { "type": "mountEntry", - "volumeName": "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", - "instanceName": "mysite-dev-frontend-1", + "volumeName": "6chars6chars6chars6chars6chars6chars6chars6chars", + "instanceName": "my-site-dev-frontend-1", "path": "/run/secrets", "permission": "rw", "instanceId": "1i234", @@ -279,7 +279,7 @@ "proxy": "https://rancher.example.com/v2-beta/projects/1a10/containers/1i456/?action=proxy" }, "baseType": "instance", - "name": "mysite-dev-frontend-2", + "name": "my-site-dev-frontend-2", "state": "running", "accountId": "1a10", "blkioDeviceOptions": null, @@ -305,9 +305,9 @@ "/run/secrets": "1v356188" }, "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef:/run/secrets" + "6chars6chars6chars6chars6chars6chars6chars6chars:/run/secrets" ], "dataVolumesFrom": null, "deploymentUnitUuid": "00000000-0000-0000-0000-000000000000", @@ -319,17 +319,17 @@ ], "dnsOpt": null, "dnsSearch": [ - "mysite-dev.rancher.internal", - "frontend.mysite-dev.rancher.internal", + "my-site-dev.rancher.internal", + "frontend.my-site-dev.rancher.internal", "rancher.internal" ], "domainName": null, "entryPoint": null, "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "expose": null, "externalId": "abc123abc123abc123abc123abc123abc123abc123", @@ -367,22 +367,22 @@ "kind": "container", "labels": { "io.rancher.service.deployment.unit": "00000000-0000-0000-0000-000000000000", - "io.rancher.stack_service.name": "mysite-dev/frontend", + "io.rancher.stack_service.name": "my-site-dev/frontend", "io.rancher.service.launch.config": "io.rancher.service.primary.launch.config", "com.example.service": "frontend", - "io.rancher.project.name": "mysite-dev", - "io.rancher.project_service.name": "mysite-dev/frontend", - "com.example.description": "mysite.development.example.com", + "io.rancher.project.name": "my-site-dev", + "io.rancher.project_service.name": "my-site-dev/frontend", + "com.example.description": "my-site.development.example.com", "com.example.group": "dev", - "io.rancher.stack.name": "mysite-dev", + "io.rancher.stack.name": "my-site-dev", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.container.ip": "10.0.0.11/16", "io.rancher.container.uuid": "00000000-0000-0000-0000-000000000000", "io.rancher.cni.network": "ipsec", "io.rancher.cni.wait": "true", "io.rancher.container.mac_address": "11:22:33:44:55:66", - "io.rancher.container.name": "mysite-dev-frontend-1" + "io.rancher.container.name": "my-site-dev-frontend-1" }, "logConfig": { "type": "logConfig" @@ -397,7 +397,7 @@ { "type": "mountEntry", "volumeName": "/clientdata/shared", - "instanceName": "mysite-dev-frontend-1", + "instanceName": "my-site-dev-frontend-1", "path": "/var/shared", "permission": "ro", "instanceId": "1i456", @@ -405,8 +405,8 @@ }, { "type": "mountEntry", - "volumeName": "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", - "instanceName": "mysite-dev-frontend-1", + "volumeName": "6chars6chars6chars6chars6chars6chars6chars6chars", + "instanceName": "my-site-dev-frontend-1", "path": "/run/secrets", "permission": "rw", "instanceId": "1i456", @@ -524,7 +524,7 @@ "proxy": "https://rancher.example.com/v2-beta/projects/1a10/containers/1i678/?action=proxy" }, "baseType": "instance", - "name": "mysite-dev-frontend-3", + "name": "my-site-dev-frontend-3", "state": "stopped", "accountId": "1a10", "blkioDeviceOptions": null, @@ -550,9 +550,9 @@ "/run/secrets": "1v356188" }, "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef:/run/secrets" + "6chars6chars6chars6chars6chars6chars6chars6chars:/run/secrets" ], "dataVolumesFrom": null, "deploymentUnitUuid": "00000000-0000-0000-0000-000000000000", @@ -564,17 +564,17 @@ ], "dnsOpt": null, "dnsSearch": [ - "mysite-dev.rancher.internal", - "frontend.mysite-dev.rancher.internal", + "my-site-dev.rancher.internal", + "frontend.my-site-dev.rancher.internal", "rancher.internal" ], "domainName": null, "entryPoint": null, "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "expose": null, "externalId": "123456123456123456123456123456123456123456", @@ -612,22 +612,22 @@ "kind": "container", "labels": { "io.rancher.service.deployment.unit": "00000000-0000-0000-0000-000000000000", - "io.rancher.stack_service.name": "mysite-dev/frontend", + "io.rancher.stack_service.name": "my-site-dev/frontend", "io.rancher.service.launch.config": "io.rancher.service.primary.launch.config", "com.example.service": "frontend", - "io.rancher.project.name": "mysite-dev", - "io.rancher.project_service.name": "mysite-dev/frontend", - "com.example.description": "mysite.development.example.com", + "io.rancher.project.name": "my-site-dev", + "io.rancher.project_service.name": "my-site-dev/frontend", + "com.example.description": "my-site.development.example.com", "com.example.group": "dev", - "io.rancher.stack.name": "mysite-dev", + "io.rancher.stack.name": "my-site-dev", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.container.ip": "10.0.0.11/16", "io.rancher.container.uuid": "00000000-0000-0000-0000-000000000000", "io.rancher.cni.network": "ipsec", "io.rancher.cni.wait": "true", "io.rancher.container.mac_address": "11:22:33:44:55:66", - "io.rancher.container.name": "mysite-dev-frontend-1" + "io.rancher.container.name": "my-site-dev-frontend-1" }, "logConfig": { "type": "logConfig" @@ -642,7 +642,7 @@ { "type": "mountEntry", "volumeName": "/clientdata/shared", - "instanceName": "mysite-dev-frontend-1", + "instanceName": "my-site-dev-frontend-1", "path": "/var/shared", "permission": "ro", "instanceId": "1i678", @@ -650,8 +650,8 @@ }, { "type": "mountEntry", - "volumeName": "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", - "instanceName": "mysite-dev-frontend-1", + "volumeName": "6chars6chars6chars6chars6chars6chars6chars6chars", + "instanceName": "my-site-dev-frontend-1", "path": "/run/secrets", "permission": "rw", "instanceId": "1i678", @@ -795,9 +795,9 @@ "/run/secrets": "1v356188" }, "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef:/run/secrets" + "6chars6chars6chars6chars6chars6chars6chars6chars:/run/secrets" ], "dataVolumesFrom": null, "deploymentUnitUuid": "00000000-0000-0000-0000-000000000000", @@ -809,17 +809,17 @@ ], "dnsOpt": null, "dnsSearch": [ - "mysite-dev.rancher.internal", - "frontend.mysite-dev.rancher.internal", + "my-site-dev.rancher.internal", + "frontend.my-site-dev.rancher.internal", "rancher.internal" ], "domainName": null, "entryPoint": null, "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "expose": null, "externalId": "123456123456123456123456123456123456123456", @@ -871,7 +871,7 @@ { "type": "mountEntry", "volumeName": "/clientdata/shared", - "instanceName": "mysite-dev-frontend-1", + "instanceName": "my-site-dev-frontend-1", "path": "/var/shared", "permission": "ro", "instanceId": "1i001", @@ -879,8 +879,8 @@ }, { "type": "mountEntry", - "volumeName": "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", - "instanceName": "mysite-dev-frontend-1", + "volumeName": "6chars6chars6chars6chars6chars6chars6chars6chars", + "instanceName": "my-site-dev-frontend-1", "path": "/run/secrets", "permission": "rw", "instanceId": "1i001", @@ -1024,9 +1024,9 @@ "/run/secrets": "1v356188" }, "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef:/run/secrets" + "6chars6chars6chars6chars6chars6chars6chars6chars:/run/secrets" ], "dataVolumesFrom": null, "deploymentUnitUuid": "00000000-0000-0000-0000-000000000000", @@ -1038,17 +1038,17 @@ ], "dnsOpt": null, "dnsSearch": [ - "mysite-dev.rancher.internal", - "frontend.mysite-dev.rancher.internal", + "my-site-dev.rancher.internal", + "frontend.my-site-dev.rancher.internal", "rancher.internal" ], "domainName": null, "entryPoint": null, "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "expose": null, "externalId": "123456123456123456123456123456123456123456", @@ -1100,7 +1100,7 @@ { "type": "mountEntry", "volumeName": "/clientdata/shared", - "instanceName": "mysite-dev-frontend-1", + "instanceName": "my-site-dev-frontend-1", "path": "/var/shared", "permission": "ro", "instanceId": "1i002", @@ -1108,8 +1108,8 @@ }, { "type": "mountEntry", - "volumeName": "abcdefabcdefabcdefabcdefabcdefabcdefabcdefabcdef", - "instanceName": "mysite-dev-frontend-1", + "volumeName": "6chars6chars6chars6chars6chars6chars6chars6chars", + "instanceName": "my-site-dev-frontend-1", "path": "/run/secrets", "permission": "rw", "instanceId": "1i002", diff --git a/src/test/resources/launchConfig.json b/src/test/resources/launchConfig.json index 64c82ea..783baa3 100644 --- a/src/test/resources/launchConfig.json +++ b/src/test/resources/launchConfig.json @@ -4,9 +4,9 @@ "/source1:/mountpoint1" ], "environment": { - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "healthCheck": { "type": "instanceHealthCheck", @@ -25,9 +25,9 @@ "labels": { "com.example.group": "dev", "com.example.service": "frontend", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.description": "mysite.development.example.com" + "com.example.description": "my-site.development.example.com" }, "logConfig": { "type": "logConfig" diff --git a/src/test/resources/service.json b/src/test/resources/service.json index 5725f60..8677dbc 100644 --- a/src/test/resources/service.json +++ b/src/test/resources/service.json @@ -46,14 +46,14 @@ "launchConfig": { "type": "launchConfig", "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "/var/backups/mysql/daily/raft3_prod_mysite:/var/restore:ro" + "/var/backups/mysql/daily/raft3_prod_my-site:/var/restore:ro" ], "environment": { - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "healthCheck": { "type": "instanceHealthCheck", @@ -72,9 +72,9 @@ "labels": { "com.example.group": "dev", "com.example.service": "frontend", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.description": "mysite.development.example.com" + "com.example.description": "my-site.development.example.com" }, "logConfig": { "type": "logConfig" @@ -152,15 +152,15 @@ "launchConfig": { "type": "launchConfig", "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "/var/backups/mysql/daily/raft3_prod_mysite:/var/restore:ro" + "/var/backups/mysql/daily/raft3_prod_my-site:/var/restore:ro" ], "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "healthCheck": { "type": "instanceHealthCheck", @@ -179,9 +179,9 @@ "labels": { "com.example.group": "dev", "com.example.service": "frontend", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.description": "mysite.development.example.com" + "com.example.description": "my-site.development.example.com" }, "logConfig": { "type": "logConfig" @@ -215,15 +215,15 @@ "previousLaunchConfig": { "type": "launchConfig", "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "/var/backups/mysql/daily/raft3_prod_mysite:/var/restore:ro" + "/var/backups/mysql/daily/raft3_prod_my-site:/var/restore:ro" ], "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "healthCheck": { "type": "instanceHealthCheck", @@ -242,9 +242,9 @@ "labels": { "com.example.group": "dev", "com.example.service": "frontend", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.description": "mysite.development.example.com" + "com.example.description": "my-site.development.example.com" }, "logConfig": { "type": "logConfig" diff --git a/src/test/resources/services.json b/src/test/resources/services.json index e2adf4b..c740db4 100644 --- a/src/test/resources/services.json +++ b/src/test/resources/services.json @@ -60,15 +60,15 @@ "launchConfig": { "type": "launchConfig", "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "/var/backups/mysql/daily/raft3_prod_mysite:/var/restore:ro" + "/var/backups/mysql/daily/raft3_prod_my-site:/var/restore:ro" ], "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "healthCheck": { "type": "instanceHealthCheck", @@ -87,9 +87,9 @@ "labels": { "com.example.group": "dev", "com.example.service": "frontend", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.description": "mysite.development.example.com" + "com.example.description": "my-site.development.example.com" }, "logConfig": { "type": "logConfig" @@ -157,15 +157,15 @@ "launchConfig": { "type": "launchConfig", "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "/var/backups/mysql/daily/raft3_prod_mysite:/var/restore:ro" + "/var/backups/mysql/daily/raft3_prod_my-site:/var/restore:ro" ], "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "healthCheck": { "type": "instanceHealthCheck", @@ -184,9 +184,9 @@ "labels": { "com.example.group": "dev", "com.example.service": "frontend", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.description": "mysite.development.example.com" + "com.example.description": "my-site.development.example.com" }, "logConfig": { "type": "logConfig" @@ -220,15 +220,15 @@ "previousLaunchConfig": { "type": "launchConfig", "dataVolumes": [ - "/clientdata/mysite_dev/files:/var/www/html/sites/mysite/files", + "/clientdata/my-site_dev/files:/var/www/html/sites/my-site/files", "/clientdata/shared:/var/shared:ro", - "/var/backups/mysql/daily/raft3_prod_mysite:/var/restore:ro" + "/var/backups/mysql/daily/raft3_prod_my-site:/var/restore:ro" ], "environment": { "BASE_DOMAIN": "example.com", - "DOMAIN": "mysite.development.example.com", + "DOMAIN": "my-site.development.example.com", "ENVIRONMENT": "development", - "SITE": "mysite" + "SITE": "my-site" }, "healthCheck": { "type": "instanceHealthCheck", @@ -247,9 +247,9 @@ "labels": { "com.example.group": "dev", "com.example.service": "frontend", - "com.example.site": "mysite", + "com.example.site": "my-site", "io.rancher.service.hash": "0123456789012345678901234567890123456789", - "com.example.description": "mysite.development.example.com" + "com.example.description": "my-site.development.example.com" }, "logConfig": { "type": "logConfig"