From dae2a65e8b5675a3070c82cc902d7882a969067a Mon Sep 17 00:00:00 2001 From: Arthur Barr Date: Wed, 13 Jun 2018 14:13:43 +0100 Subject: [PATCH 1/4] change tests to use Maven instead of Gradle --- test/messaging/Dockerfile | 24 ++++++------- test/messaging/build.gradle | 39 --------------------- test/messaging/pom.xml | 69 +++++++++++++++++++++++++++++++++++++ 3 files changed, 80 insertions(+), 52 deletions(-) delete mode 100644 test/messaging/build.gradle create mode 100644 test/messaging/pom.xml diff --git a/test/messaging/Dockerfile b/test/messaging/Dockerfile index c18934f..6a2d8f2 100644 --- a/test/messaging/Dockerfile +++ b/test/messaging/Dockerfile @@ -13,26 +13,24 @@ # limitations under the License. ############################################################################### -# Application build environment (Gradle) +# Application build environment (Maven) ############################################################################### -FROM gradle as builder -ENV GRADLE_OPTS="-Dorg.gradle.daemon=false" -# Change where Gradle stores its cache, so that it's not under a volume -# (and therefore gets cached by Docker) -ENV GRADLE_USER_HOME=/home/gradle/gradle -RUN mkdir -p $GRADLE_USER_HOME -COPY --chown=gradle build.gradle /app/ -WORKDIR /app +FROM maven:3-ibmjava as builder +COPY pom.xml /usr/src/mymaven/ +WORKDIR /usr/src/mymaven # Download dependencies separately, so Docker caches them -RUN gradle download +RUN mvn dependency:go-offline install # Copy source -COPY --chown=gradle src /app/src +COPY src /usr/src/mymaven/src # Run the main build -RUN gradle install +RUN mvn --offline install +# Print a list of all the files (useful for debugging) +RUN find /usr/src/mymaven ############################################################################### # Application runtime (JRE only, no build environment) ############################################################################### FROM ibmjava:sfj -COPY --from=builder /app/lib/*.jar /opt/app/ +COPY --from=builder /usr/src/mymaven/target/*.jar /opt/app/ +COPY --from=builder /usr/src/mymaven/target/lib/*.jar /opt/app/ ENTRYPOINT ["java", "-classpath", "/opt/app/*", "org.junit.platform.console.ConsoleLauncher", "-p", "com.ibm.mqcontainer.test", "--details", "verbose"] diff --git a/test/messaging/build.gradle b/test/messaging/build.gradle deleted file mode 100644 index 6fed6eb..0000000 --- a/test/messaging/build.gradle +++ /dev/null @@ -1,39 +0,0 @@ -// © Copyright IBM Corporation 2018 -// -// 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. - -apply plugin: 'java' - -repositories { - mavenCentral() -} - -dependencies { - compile group: 'com.ibm.mq', name: 'com.ibm.mq.allclient', version: '9.0.5.0' - compile "org.junit.jupiter:junit-jupiter-api:5.0.3" - runtime "org.junit.jupiter:junit-jupiter-engine:5.0.3" - runtime "org.junit.platform:junit-platform-console-standalone:1.0.3" -} - -task download(type: Exec) { - configurations.runtime.files - commandLine 'echo', 'Downloaded all dependencies' -} - -// Copy all dependencies to the lib directory -task install(type: Copy) { - dependsOn build - from configurations.runtime - from jar - into "${project.projectDir}/lib" -} \ No newline at end of file diff --git a/test/messaging/pom.xml b/test/messaging/pom.xml new file mode 100644 index 0000000..6644de3 --- /dev/null +++ b/test/messaging/pom.xml @@ -0,0 +1,69 @@ + + + 4.0.0 + com.ibm.mq.container + test-messaging + jar + dev + test-messaging + http://maven.apache.org + + + com.ibm.mq + com.ibm.mq.allclient + 9.0.5.0 + compile + + + org.junit.jupiter + junit-jupiter-api + 5.2.0 + compile + + + org.junit.jupiter + junit-jupiter-engine + 5.2.0 + runtime + + + org.junit.platform + junit-platform-console-standalone + 1.2.0 + runtime + + + + + + maven-dependency-plugin + + + install + + copy-dependencies + + + ${project.build.directory}/lib + + + + + + + From 2e3dee931c1edb7eb4e911b19c335efeb90beef2 Mon Sep 17 00:00:00 2001 From: Arthur Barr Date: Wed, 13 Jun 2018 16:41:16 +0100 Subject: [PATCH 2/4] Ignore .git in Docker context --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 8ba8eed..d1824c6 100644 --- a/.dockerignore +++ b/.dockerignore @@ -1 +1,2 @@ downloads +.git \ No newline at end of file From 63ce0b337725708354e958aac86b802c8d7a4d36 Mon Sep 17 00:00:00 2001 From: Arthur Barr Date: Wed, 13 Jun 2018 16:42:00 +0100 Subject: [PATCH 3/4] Add timeout while waiting for ready in tests --- test/docker/devconfig_test_util.go | 29 ++++++++++++++--------------- test/docker/docker_api_test_util.go | 16 ++++++++++++---- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/test/docker/devconfig_test_util.go b/test/docker/devconfig_test_util.go index 2215e92..c89e458 100644 --- a/test/docker/devconfig_test_util.go +++ b/test/docker/devconfig_test_util.go @@ -51,23 +51,22 @@ func waitForWebReady(t *testing.T, cli *client.Client, ID string, tlsConfig *tls }, } url := fmt.Sprintf("https://localhost:%s/ibmmq/rest/v1/admin/installation", getPort(t, cli, ID, 9443)) + ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) + defer cancel() + for { - req, err := http.NewRequest("GET", url, nil) - req.SetBasicAuth("admin", devAdminPassword) - resp, err := httpClient.Do(req) - if err == nil && resp.StatusCode == http.StatusOK { - t.Log("MQ web server is ready") - return + select { + case <-time.After(1 * time.Second): + req, err := http.NewRequest("GET", url, nil) + req.SetBasicAuth("admin", devAdminPassword) + resp, err := httpClient.Do(req.WithContext(ctx)) + if err == nil && resp.StatusCode == http.StatusOK { + t.Log("MQ web server is ready") + return + } + case <-ctx.Done(): + t.Fatal("Timed out waiting for web server to become ready") } - // conn, err := tls.Dial("tcp", a, &config) - // if err == nil { - // conn.Close() - // // Extra sleep to allow web apps to start - // time.Sleep(5 * time.Second) - // t.Log("MQ web server is ready") - // return - // } - time.Sleep(1 * time.Second) } } diff --git a/test/docker/docker_api_test_util.go b/test/docker/docker_api_test_util.go index dc3a989..62be807 100644 --- a/test/docker/docker_api_test_util.go +++ b/test/docker/docker_api_test_util.go @@ -387,11 +387,19 @@ rerun: } func waitForReady(t *testing.T, cli *client.Client, ID string) { + ctx, cancel := context.WithTimeout(context.Background(), time.Minute) + defer cancel() + for { - rc, _ := execContainer(t, cli, ID, "mqm", []string{"chkmqready"}) - if rc == 0 { - t.Log("MQ is ready") - return + select { + case <-time.After(1 * time.Second): + rc, _ := execContainer(t, cli, ID, "mqm", []string{"chkmqready"}) + if rc == 0 { + t.Log("MQ is ready") + return + } + case <-ctx.Done(): + t.Fatal("Timed out waiting for container to become ready") } } } From 9805c1eaf8c9bd81bb4ef6c2a1bf7a8d72b52d15 Mon Sep 17 00:00:00 2001 From: Arthur Barr Date: Wed, 13 Jun 2018 16:46:26 +0100 Subject: [PATCH 4/4] Add fat manifests for Docker Hub --- manifests/README.md | 10 ++++++++++ manifests/manifest-9-cd.yaml | 29 +++++++++++++++++++++++++++++ manifests/manifest-9.yaml | 29 +++++++++++++++++++++++++++++ manifests/manifest-cd.yaml | 29 +++++++++++++++++++++++++++++ manifests/manifest-latest.yaml | 29 +++++++++++++++++++++++++++++ 5 files changed, 126 insertions(+) create mode 100644 manifests/README.md create mode 100644 manifests/manifest-9-cd.yaml create mode 100644 manifests/manifest-9.yaml create mode 100644 manifests/manifest-cd.yaml create mode 100644 manifests/manifest-latest.yaml diff --git a/manifests/README.md b/manifests/README.md new file mode 100644 index 0000000..8810c82 --- /dev/null +++ b/manifests/README.md @@ -0,0 +1,10 @@ +Fat manifests +============= + +These are the fat manifests used by Docker Hub to handle images with multiple CPU architectures. + +They are used in conjunction with [manifest-tool](https://github.com/estesp/manifest-tool), for example: + +```sh +manifest-tool push from-spec manifest-latest.yaml +``` diff --git a/manifests/manifest-9-cd.yaml b/manifests/manifest-9-cd.yaml new file mode 100644 index 0000000..c96b320 --- /dev/null +++ b/manifests/manifest-9-cd.yaml @@ -0,0 +1,29 @@ +# © Copyright IBM Corporation 2018 +# +# 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. + +image: ibmcom/mq:9-cd +manifests: + - image: ibmcom/mq:9.0.5.0-x86_64 + platform: + architecture: amd64 + os: linux + - image: ibmcom/mq:9.0.5.0-ppc64le + platform: + architecture: ppc64le + os: linux + - image: ibmcom/mq:9.0.5.0-s390x + platform: + architecture: s390x + os: linux + diff --git a/manifests/manifest-9.yaml b/manifests/manifest-9.yaml new file mode 100644 index 0000000..f97f076 --- /dev/null +++ b/manifests/manifest-9.yaml @@ -0,0 +1,29 @@ +# © Copyright IBM Corporation 2018 +# +# 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. + +image: ibmcom/mq:9 +manifests: + - image: ibmcom/mq:9.0.5.0-x86_64 + platform: + architecture: amd64 + os: linux + - image: ibmcom/mq:9.0.5.0-ppc64le + platform: + architecture: ppc64le + os: linux + - image: ibmcom/mq:9.0.5.0-s390x + platform: + architecture: s390x + os: linux + diff --git a/manifests/manifest-cd.yaml b/manifests/manifest-cd.yaml new file mode 100644 index 0000000..6cb173c --- /dev/null +++ b/manifests/manifest-cd.yaml @@ -0,0 +1,29 @@ +# © Copyright IBM Corporation 2018 +# +# 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. + +image: ibmcom/mq:cd +manifests: + - image: ibmcom/mq:9.0.5.0-x86_64 + platform: + architecture: amd64 + os: linux + - image: ibmcom/mq:9.0.5.0-ppc64le + platform: + architecture: ppc64le + os: linux + - image: ibmcom/mq:9.0.5.0-s390x + platform: + architecture: s390x + os: linux + diff --git a/manifests/manifest-latest.yaml b/manifests/manifest-latest.yaml new file mode 100644 index 0000000..db5eb53 --- /dev/null +++ b/manifests/manifest-latest.yaml @@ -0,0 +1,29 @@ +# © Copyright IBM Corporation 2018 +# +# 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. + +image: ibmcom/mq:latest +manifests: + - image: ibmcom/mq:9.0.5.0-x86_64 + platform: + architecture: amd64 + os: linux + - image: ibmcom/mq:9.0.5.0-ppc64le + platform: + architecture: ppc64le + os: linux + - image: ibmcom/mq:9.0.5.0-s390x + platform: + architecture: s390x + os: linux +