Skip to content

Commit

Permalink
fix[ENTESB-12540]: #40 Switch runtime to Maven
Browse files Browse the repository at this point in the history
Switching YAKS runtime to Maven instead of running plain JVM jar for executing tests. This enables us to use Maven dependency resolving for additional components used in tests.

- Refactor YAKS Docker image to use Maven build instead of jar execution
- Add local m2 repository to YAKS Docker image holding all dependencies and required plugins to run a test
- Tidy up Maven dependencies and dependency management
- Move TestReporter to yaks-testing-standard module
- Refactor yaks-testing module to represent the new YAKS runtime using Maven
  • Loading branch information
christophd committed Feb 14, 2020
1 parent 245c8a5 commit bcaf03e
Show file tree
Hide file tree
Showing 29 changed files with 223 additions and 261 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

.DS_Store

build/_maven_dependencies
build/_maven_*
build/_output

/yaks
Expand Down
1 change: 0 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ cross-compile:
./hack/cross_compile.sh $(VERSION)

docker-image:
mkdir -p build/_maven_dependencies
mkdir -p build/_output/bin
operator-sdk build $(IMAGE_NAME):$(VERSION)

Expand Down
18 changes: 14 additions & 4 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,22 +1,32 @@
#FROM registry.access.redhat.com/ubi7/ubi-minimal:latest
FROM fabric8/s2i-java:3.0-java8

ENV OPERATOR=/usr/local/bin/yaks \
OPERATOR_ARGS=operator \
USER_UID=1001 \
USER_NAME=yaks \
HOME=/root
HOME=/root \
APP_DIR=/deployments/data/yaks-testing \
APP_LIBS=/deployments/artifacts/m2

# install operator binary
COPY build/_output/bin/yaks ${OPERATOR}

COPY build/bin /usr/local/bin

# TODO create a more efficient way to manage dependencies than to hardcode them
COPY build/_maven_repository ${APP_LIBS}

# add YAKS runtime
COPY build/_maven_project/yaks-testing ${APP_DIR}

USER 0
RUN /usr/local/bin/user_setup

# TODO create a more efficient way to manage dependencies than to hardcode them
ADD build/_maven_dependencies /deployments/dependencies
RUN chgrp -R 0 ${APP_LIBS} && \
chmod -R g=u ${APP_LIBS}

RUN chgrp -R 0 ${APP_DIR} && \
chmod -R g=u ${APP_DIR}

# Let's not use ENTRYPOINT so we can override libs in the base image

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
module github.com/jboss-fuse/yaks

require (
github.com/NYTimes/gziphandler v1.0.1 // indirect
github.com/fatih/color v1.7.0
github.com/go-logr/logr v0.1.0
github.com/mattn/go-colorable v0.1.2 // indirect
Expand Down Expand Up @@ -37,3 +36,5 @@ replace (
)

replace github.com/operator-framework/operator-sdk => github.com/operator-framework/operator-sdk v0.9.0

go 1.13
10 changes: 7 additions & 3 deletions hack/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ if [ "$#" -ne 0 ]; then
exit 1
fi

cd ${location}/../java
cd ${location}/../build

rm -rf $PWD/../build/_maven_dependencies
rm -rf $PWD/../build/_output
rm -rf _maven_repository
mkdir -p _maven_repository
rm -rf _maven_project
mkdir -p _maven_project
rm -rf _output
mkdir -p _output
2 changes: 1 addition & 1 deletion hack/cross_compile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# limitations under the License.

location=$(dirname $0)
rootdir=$(realpath ${location}/..)
rootdir=${location}/..

basename=yaks

Expand Down
49 changes: 41 additions & 8 deletions hack/package_maven_artifacts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,51 @@ location=$(dirname $0)

cd ${location}/../java

mkdir -p $PWD/../build/_maven_dependencies
mkdir -p $PWD/../build/_maven_repository
mkdir -p $PWD/../build/_maven_project

./mvnw clean install $@
# copy YAKS Maven project to image, this will be the runtime for the tests
echo Copy YAKS runtime ...

rm -rf $PWD/../build/_maven_dependencies/*
./mvnw \
--quiet \
-f yaks-testing/pom.xml \
clean

cp -r yaks-testing $PWD/../build/_maven_project

# fresh build YAKS java modules
echo Build YAKS modules ...

./mvnw \
--quiet \
clean install $@

# copy all dependencies to image m2 repository
echo Copy project dependencies ...

./mvnw \
clean \
--quiet \
-f yaks-testing/pom.xml \
-DoutputDirectory=$PWD/../build/_maven_dependencies \
-DskipTests \
dependency:copy-dependencies \
install
-DoutputDirectory=$PWD/../build/_maven_repository \
dependency:copy-dependencies

cp $PWD/yaks-testing/target/*.jar $PWD/../build/_maven_dependencies
# install YAKS artifacts to image m2 repository
echo Install Yaks artifacts ...

./mvnw \
--quiet \
-DskipTests \
-Dmaven.repo.local=$PWD/../build/_maven_repository \
jar:jar \
install:install

# preload Maven plugins so they are part of the image
echo Load project plugins ...

./mvnw \
--quiet \
-f yaks-testing/pom.xml \
-Dmaven.repo.local=$PWD/../build/_maven_repository \
test
57 changes: 35 additions & 22 deletions java/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@

<maven-compiler-plugin.version>3.8.1</maven-compiler-plugin.version>
<maven-surefire-plugin.version>2.22.2</maven-surefire-plugin.version>
<maven-remote-resources-plugin.version>1.5</maven-remote-resources-plugin.version>
<maven-failsafe-plugin.version>2.22.2</maven-failsafe-plugin.version>
<maven-remote-resources-plugin.version>1.5</maven-remote-resources-plugin.version>
<versions-maven-plugin.version>2.7</versions-maven-plugin.version>
<directory-maven-plugin.version>0.3.1</directory-maven-plugin.version>
<exec-maven-plugin.version>1.6.0</exec-maven-plugin.version>
Expand All @@ -67,40 +67,53 @@

<dependencyManagement>
<dependencies>
<!-- Citrus -->
<dependency>
<groupId>dev.yaks</groupId>
<artifactId>yaks-testing</artifactId>
<version>${project.version}</version>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-core</artifactId>
<version>${citrus.version}</version>
</dependency>
<dependency>
<groupId>dev.yaks</groupId>
<artifactId>yaks-testing-camel</artifactId>
<version>${project.version}</version>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-java-dsl</artifactId>
<version>${citrus.version}</version>
</dependency>
<dependency>
<groupId>dev.yaks</groupId>
<artifactId>yaks-testing-camel-k</artifactId>
<version>${project.version}</version>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-http</artifactId>
<version>${citrus.version}</version>
</dependency>
<dependency>
<groupId>dev.yaks</groupId>
<artifactId>yaks-testing-jdbc</artifactId>
<version>${project.version}</version>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-cucumber</artifactId>
<version>${citrus.version}</version>
</dependency>
<dependency>
<groupId>dev.yaks</groupId>
<artifactId>yaks-testing-http</artifactId>
<version>${project.version}</version>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-camel</artifactId>
<version>${citrus.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Cucumber -->
<dependency>
<groupId>dev.yaks</groupId>
<artifactId>yaks-testing-swagger</artifactId>
<version>${project.version}</version>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>
<dependency>
<groupId>dev.yaks</groupId>
<artifactId>yaks-testing-standard</artifactId>
<version>${project.version}</version>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
</dependency>

<!-- Logging -->
Expand Down
1 change: 0 additions & 1 deletion java/yaks-testing-camel-k/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>

<dependency>
Expand Down
19 changes: 0 additions & 19 deletions java/yaks-testing-camel/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,35 +33,19 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>

<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-core</artifactId>
<version>${citrus.version}</version>
</dependency>

<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-java-dsl</artifactId>
<version>${citrus.version}</version>
</dependency>

<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-camel</artifactId>
<version>${citrus.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.camel</groupId>
<artifactId>camel-spring</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down Expand Up @@ -100,21 +84,18 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-cucumber</artifactId>
<version>${citrus.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
<scope>test</scope>
</dependency>

</dependencies>

</project>
8 changes: 0 additions & 8 deletions java/yaks-testing-http/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,25 +33,19 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>

<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-core</artifactId>
<version>${citrus.version}</version>
</dependency>

<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-java-dsl</artifactId>
<version>${citrus.version}</version>
</dependency>

<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-http</artifactId>
<version>${citrus.version}</version>
</dependency>

<!-- Test scope -->
Expand All @@ -63,13 +57,11 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-cucumber</artifactId>
<version>${citrus.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
6 changes: 0 additions & 6 deletions java/yaks-testing-jdbc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,15 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber.version}</version>
</dependency>

<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-core</artifactId>
<version>${citrus.version}</version>
</dependency>

<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-java-dsl</artifactId>
<version>${citrus.version}</version>
</dependency>

<dependency>
Expand All @@ -63,13 +59,11 @@
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>${cucumber.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.consol.citrus</groupId>
<artifactId>citrus-cucumber</artifactId>
<version>${citrus.version}</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Loading

0 comments on commit bcaf03e

Please sign in to comment.