Created
April 21, 2020 13:59
-
-
Save zregvart/b16f98a6e31cce3f1693cdbd578b34e1 to your computer and use it in GitHub Desktop.
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
From cc2c6da10b87bd240a600e6e64f22cfed62c8556 Mon Sep 17 00:00:00 2001 | |
From: Zoran Regvart <[email protected]> | |
Date: Tue, 21 Apr 2020 15:45:26 +0200 | |
Subject: [PATCH] chore: x | |
--- | |
app/s2i/src/main/docker/Dockerfile | 7 +++-- | |
.../src/test/resources/logback-test.xml | 11 +------ | |
.../SyndesisIntegrationRuntimeContainer.java | 15 ++++++---- | |
.../s2i/SyndesisS2iAssemblyContainer.java | 8 +++-- | |
.../project/AbstractMavenProjectBuilder.java | 11 +++++-- | |
.../src/test/resources/logback-test.xml | 30 +++++++++++++++++++ | |
6 files changed, 61 insertions(+), 21 deletions(-) | |
create mode 100644 app/test/test-support/src/test/resources/logback-test.xml | |
diff --git a/app/s2i/src/main/docker/Dockerfile b/app/s2i/src/main/docker/Dockerfile | |
index ae8fee8660..ba5a8e3a6e 100644 | |
--- a/app/s2i/src/main/docker/Dockerfile | |
+++ b/app/s2i/src/main/docker/Dockerfile | |
@@ -11,12 +11,15 @@ ADD settings.xml /tmp/settings.xml | |
# so you cannot change the location of the local repo! | |
ADD repository /tmp/artifacts/m2 | |
-RUN chgrp -R 0 /tmp/artifacts/m2 \ | |
- && chmod -R g=u /tmp/artifacts/m2 | |
+RUN chgrp -R 0 /tmp/artifacts \ | |
+ && chmod -R 777 /tmp/artifacts | |
# Copy licenses | |
RUN mkdir -p /opt/ipaas/ | |
ADD licenses* /opt/ipaas/ | |
+RUN mkdir -p /deployments \ | |
+ && chmod 777 /deployments | |
+ | |
USER 1000 | |
diff --git a/app/test/integration-test/src/test/resources/logback-test.xml b/app/test/integration-test/src/test/resources/logback-test.xml | |
index 175b4c58e7..59a83750b8 100644 | |
--- a/app/test/integration-test/src/test/resources/logback-test.xml | |
+++ b/app/test/integration-test/src/test/resources/logback-test.xml | |
@@ -16,12 +16,6 @@ | |
<configuration> | |
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | |
- <encoder> | |
- <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern> | |
- </encoder> | |
- </appender> | |
- | |
<appender name="FILE" class="ch.qos.logback.core.FileAppender"> | |
<encoder> | |
<pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n</pattern> | |
@@ -53,17 +47,14 @@ | |
<logger name="org.hibernate.validator" level="WARN"/> | |
<logger name="INTEGRATION_RUNTIME_CONTAINER" level="INFO"> | |
- <!--appender-ref ref="STDOUT"/--> | |
<appender-ref ref="INTEGRATION_RUNTIME_FILE"/> | |
</logger> | |
<logger name="SERVER_CONTAINER" level="INFO"> | |
- <!--appender-ref ref="STDOUT"/--> | |
<appender-ref ref="SERVER_CONTAINER_FILE"/> | |
</logger> | |
- <root level="DEBUG"> | |
- <!--appender-ref ref="STDOUT"/--> | |
+ <root level="WARN"> | |
<appender-ref ref="FILE"/> | |
</root> | |
diff --git a/app/test/test-support/src/main/java/io/syndesis/test/container/integration/SyndesisIntegrationRuntimeContainer.java b/app/test/test-support/src/main/java/io/syndesis/test/container/integration/SyndesisIntegrationRuntimeContainer.java | |
index f805e3758a..6c95e55ee7 100644 | |
--- a/app/test/test-support/src/main/java/io/syndesis/test/container/integration/SyndesisIntegrationRuntimeContainer.java | |
+++ b/app/test/test-support/src/main/java/io/syndesis/test/container/integration/SyndesisIntegrationRuntimeContainer.java | |
@@ -70,6 +70,13 @@ public class SyndesisIntegrationRuntimeContainer extends GenericContainer<Syndes | |
private String internalHostIp; | |
+ private SyndesisIntegrationRuntimeContainer(final String integrationName, final SyndesisDockerfileBuilder builder) { | |
+ super(builder); | |
+ | |
+ withCreateContainerCmdModifier(createContainerCmd -> createContainerCmd.withName(integrationName)); | |
+ withCreateContainerCmdModifier(c -> c.withUser("110779:110779")); | |
+ } | |
+ | |
/** | |
* Uses Spring Boot Maven build to run the integration project. Much faster as S2i build because we can directly use the project sources. | |
* | |
@@ -82,7 +89,7 @@ public class SyndesisIntegrationRuntimeContainer extends GenericContainer<Syndes | |
*/ | |
protected SyndesisIntegrationRuntimeContainer(String imageTag, String integrationName, Path projectDir, | |
Map<String, String> envProperties, String runCommand, boolean deleteOnExit) { | |
- super(new SyndesisDockerfileBuilder(integrationName, deleteOnExit) | |
+ this(integrationName, new SyndesisDockerfileBuilder(integrationName, deleteOnExit) | |
.from("syndesis/syndesis-s2i", imageTag) | |
.projectSource("projectDir") | |
.projectDestination(SyndesisTestEnvironment.getProjectMountPath()) | |
@@ -93,7 +100,6 @@ public class SyndesisIntegrationRuntimeContainer extends GenericContainer<Syndes | |
.build()); | |
LOG.info("Binding project folder: " + projectDir.toAbsolutePath()); | |
- withCreateContainerCmdModifier(createContainerCmd -> createContainerCmd.withName(integrationName)); | |
} | |
/** | |
@@ -107,7 +113,7 @@ public class SyndesisIntegrationRuntimeContainer extends GenericContainer<Syndes | |
*/ | |
protected SyndesisIntegrationRuntimeContainer(String imageTag, String integrationName, Path projectDir, File projectJar, | |
Map<String, String> envProperties, String runCommand, boolean deleteOnExit) { | |
- super(new SyndesisDockerfileBuilder(integrationName, deleteOnExit) | |
+ this(integrationName, new SyndesisDockerfileBuilder(integrationName, deleteOnExit) | |
.from("syndesis/syndesis-s2i", imageTag) | |
.projectSource("integration-runtime.jar") | |
.projectDestination("/deployments/integration-runtime.jar") | |
@@ -119,7 +125,6 @@ public class SyndesisIntegrationRuntimeContainer extends GenericContainer<Syndes | |
.build()); | |
LOG.info("Binding project jar file: " + projectJar.toPath().toAbsolutePath()); | |
- withCreateContainerCmdModifier(createContainerCmd -> createContainerCmd.withName(integrationName)); | |
} | |
public static class Builder { | |
@@ -366,7 +371,7 @@ public class SyndesisIntegrationRuntimeContainer extends GenericContainer<Syndes | |
} | |
private static String getDebugJvmArguments() { | |
- return String.format("-Dspring-boot.run.jvmArguments=\"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%s\"", SyndesisTestEnvironment.getDebugPort()); | |
+ return String.format("-Drun.jvmArguments=\"-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=%s\"", SyndesisTestEnvironment.getDebugPort()); | |
} | |
} | |
diff --git a/app/test/test-support/src/main/java/io/syndesis/test/container/s2i/SyndesisS2iAssemblyContainer.java b/app/test/test-support/src/main/java/io/syndesis/test/container/s2i/SyndesisS2iAssemblyContainer.java | |
index 332c6feeb5..6eda2ea075 100644 | |
--- a/app/test/test-support/src/main/java/io/syndesis/test/container/s2i/SyndesisS2iAssemblyContainer.java | |
+++ b/app/test/test-support/src/main/java/io/syndesis/test/container/s2i/SyndesisS2iAssemblyContainer.java | |
@@ -20,8 +20,10 @@ import java.nio.file.Path; | |
import java.time.Duration; | |
import io.syndesis.test.SyndesisTestEnvironment; | |
+ | |
import org.testcontainers.containers.BindMode; | |
import org.testcontainers.containers.GenericContainer; | |
+import org.testcontainers.containers.SelinuxContext; | |
import org.testcontainers.containers.wait.strategy.LogMessageWaitStrategy; | |
import org.testcontainers.images.builder.ImageFromDockerfile; | |
@@ -45,9 +47,11 @@ public class SyndesisS2iAssemblyContainer extends GenericContainer<SyndesisS2iAs | |
.cmd(S2I_ASSEMBLE_SCRIPT) | |
.build())); | |
- withFileSystemBind(projectDir.toAbsolutePath().toString(), SRC_DIR, BindMode.READ_WRITE); | |
+ addFileSystemBind(projectDir.toAbsolutePath().toString(), SRC_DIR, BindMode.READ_WRITE, SelinuxContext.SINGLE); | |
- waitingFor(new LogMessageWaitStrategy().withRegEx(".*\\.\\.\\. done.*\\s") | |
+ setWaitStrategy(new LogMessageWaitStrategy().withRegEx(".*\\.\\.\\. done.*\\s") | |
.withStartupTimeout(Duration.ofSeconds(SyndesisTestEnvironment.getContainerStartupTimeout()))); | |
+ | |
+ withCreateContainerCmdModifier(c -> c.withUser("110779:110779")); | |
} | |
} | |
diff --git a/app/test/test-support/src/main/java/io/syndesis/test/integration/project/AbstractMavenProjectBuilder.java b/app/test/test-support/src/main/java/io/syndesis/test/integration/project/AbstractMavenProjectBuilder.java | |
index 2438384aa4..62fd9e23df 100644 | |
--- a/app/test/test-support/src/main/java/io/syndesis/test/integration/project/AbstractMavenProjectBuilder.java | |
+++ b/app/test/test-support/src/main/java/io/syndesis/test/integration/project/AbstractMavenProjectBuilder.java | |
@@ -26,10 +26,15 @@ import java.nio.file.Files; | |
import java.nio.file.Path; | |
import java.nio.file.Paths; | |
import java.nio.file.StandardOpenOption; | |
+import java.nio.file.attribute.FileAttribute; | |
+import java.nio.file.attribute.PosixFilePermission; | |
+import java.nio.file.attribute.PosixFilePermissions; | |
import java.util.Collections; | |
+import java.util.EnumSet; | |
import java.util.List; | |
import java.util.Optional; | |
import java.util.Properties; | |
+import java.util.Set; | |
import io.syndesis.common.model.connection.Connector; | |
import io.syndesis.common.model.extension.Extension; | |
@@ -51,6 +56,8 @@ import org.slf4j.LoggerFactory; | |
*/ | |
public abstract class AbstractMavenProjectBuilder<T extends AbstractMavenProjectBuilder<T>> implements ProjectBuilder { | |
+ private static final FileAttribute<Set<PosixFilePermission>> DIRECTORY_PERMISSIONS = PosixFilePermissions.asFileAttribute(EnumSet.allOf(PosixFilePermission.class)); | |
+ | |
/** Logger */ | |
private static final Logger LOG = LoggerFactory.getLogger(AbstractMavenProjectBuilder.class); | |
@@ -70,7 +77,7 @@ public abstract class AbstractMavenProjectBuilder<T extends AbstractMavenProject | |
@Override | |
public Project build(IntegrationSource source) { | |
try { | |
- Path projectDir = Files.createTempDirectory(outputDir, name); | |
+ Path projectDir = Files.createTempDirectory(outputDir, name, DIRECTORY_PERMISSIONS); | |
LOG.info(String.format("Building integration project in directory: '%s'", projectDir.toAbsolutePath())); | |
@@ -153,7 +160,7 @@ public abstract class AbstractMavenProjectBuilder<T extends AbstractMavenProject | |
public final T withOutputDirectory(String tmpDir) { | |
try { | |
- this.outputDir = Files.createDirectories(Paths.get(tmpDir)); | |
+ this.outputDir = Files.createDirectories(Paths.get(tmpDir), DIRECTORY_PERMISSIONS); | |
} catch (IOException e) { | |
throw new IllegalStateException("Failed to create temp directory", e); | |
} | |
diff --git a/app/test/test-support/src/test/resources/logback-test.xml b/app/test/test-support/src/test/resources/logback-test.xml | |
new file mode 100644 | |
index 0000000000..a6f0f430af | |
--- /dev/null | |
+++ b/app/test/test-support/src/test/resources/logback-test.xml | |
@@ -0,0 +1,30 @@ | |
+<!-- | |
+ ~ Copyright (C) 2016 Red Hat, Inc. | |
+ ~ | |
+ ~ Licensed under the Apache License, Version 2.0 (the "License"); | |
+ ~ you may not use this file except in compliance with the License. | |
+ ~ You may obtain a copy of the License at | |
+ ~ | |
+ ~ http://www.apache.org/licenses/LICENSE-2.0 | |
+ ~ | |
+ ~ Unless required by applicable law or agreed to in writing, software | |
+ ~ distributed under the License is distributed on an "AS IS" BASIS, | |
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
+ ~ See the License for the specific language governing permissions and | |
+ ~ limitations under the License. | |
+ --> | |
+ | |
+<configuration> | |
+ | |
+ <appender name="FILE" class="ch.qos.logback.core.FileAppender"> | |
+ <encoder> | |
+ <pattern>%d{HH:mm:ss.SSS} [%-15.15thread] %-5level %-30.30logger - %msg%n</pattern> | |
+ </encoder> | |
+ <file>target/test.log</file> | |
+ </appender> | |
+ | |
+ <root level="DEBUG"> | |
+ <appender-ref ref="FILE"/> | |
+ </root> | |
+ | |
+</configuration> | |
-- | |
2.25.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment