From 176b243a15753493ec6d935e58e8f026361a8538 Mon Sep 17 00:00:00 2001 From: Erik Merkle Date: Tue, 10 Oct 2023 12:36:04 -0500 Subject: [PATCH] Ensure curl and wget are installed in images --- .github/workflows/ci.yaml | 4 +- CHANGELOG.md | 1 + Dockerfile-4_0.ubi8 | 2 +- Dockerfile-4_1.ubi8 | 2 +- Dockerfile-oss.ubi8 | 2 +- cassandra-trunk/Dockerfile.ubi8 | 2 +- dse-68/Dockerfile.ubi8 | 2 +- .../com/datastax/mgmtapi/DockerImageIT.java | 53 +++++++++++++++++++ 8 files changed, 61 insertions(+), 7 deletions(-) create mode 100644 management-api-server/src/test/java/com/datastax/mgmtapi/DockerImageIT.java diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8d3d9b49..b326d276 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -11,7 +11,7 @@ jobs: fail-fast: false matrix: cassandra-version: ['3.11', '4.0', '4.1', '3.11_ubi', '4.0_ubi', '4.1_ubi'] - itTest : ['LifecycleIT', 'KeepAliveIT', 'NonDestructiveOpsIT', 'DestructiveOpsIT', 'NonDestructiveOpsResourcesV2IT'] + itTest : ['LifecycleIT', 'KeepAliveIT', 'NonDestructiveOpsIT', 'DestructiveOpsIT', 'NonDestructiveOpsResourcesV2IT', 'DockerImageIT'] include: - cassandra-version: '3.11' run311tests: true @@ -94,7 +94,7 @@ jobs: fail-fast: false matrix: platform-version: ['jdk8', 'ubi'] - itTest : ['LifecycleIT', 'KeepAliveIT', 'NonDestructiveOpsIT', 'DestructiveOpsIT', 'DSESpecificIT', 'NonDestructiveOpsResourcesV2IT'] + itTest : ['LifecycleIT', 'KeepAliveIT', 'NonDestructiveOpsIT', 'DestructiveOpsIT', 'DSESpecificIT', 'NonDestructiveOpsResourcesV2IT', 'DockerImageIT'] include: - platform-version: 'jdk8' runDSEtests: true diff --git a/CHANGELOG.md b/CHANGELOG.md index 64bfc5c6..4d520ef9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Changelog for Management API, new PRs should update the `main / unreleased` sect ``` ## unreleased +* [CHANGE] [#400](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/400) Ensure curl and wget are installed in images * [FEATURE] [#326](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/326) Provide topology endpoints in OpenAPI client * [FEATURE] [#345](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/345) Implement host related methods * [FEATURE] [#361](https://github.com/k8ssandra/management-api-for-apache-cassandra/issues/361) Add new listTables operation with more detailed response diff --git a/Dockerfile-4_0.ubi8 b/Dockerfile-4_0.ubi8 index 6fea3177..49ff8c8f 100644 --- a/Dockerfile-4_0.ubi8 +++ b/Dockerfile-4_0.ubi8 @@ -118,7 +118,7 @@ ENV CASSANDRA_DATA_DIR /var/lib/cassandra # Update base layer RUN microdnf update && rm -rf /var/cache/yum \ # Install packages needed during install process - && microdnf install --nodocs java-11-openjdk-headless tzdata-java python3 zlib findutils which hostname iproute shadow-utils procps util-linux glibc-langpack-en \ + && microdnf install --nodocs java-11-openjdk-headless tzdata-java python3 zlib findutils which hostname iproute shadow-utils procps util-linux glibc-langpack-en wget \ && microdnf clean all \ # Add Cassandra user && groupadd -r cassandra --gid=999 \ diff --git a/Dockerfile-4_1.ubi8 b/Dockerfile-4_1.ubi8 index 1f4199d6..c6671f82 100644 --- a/Dockerfile-4_1.ubi8 +++ b/Dockerfile-4_1.ubi8 @@ -119,7 +119,7 @@ ENV CASSANDRA_DATA_DIR /var/lib/cassandra # Update base layer RUN microdnf update && rm -rf /var/cache/yum \ # Install packages needed during install process - && microdnf install --nodocs java-11-openjdk-headless tzdata-java python3 zlib findutils which hostname iproute shadow-utils procps util-linux glibc-langpack-en \ + && microdnf install --nodocs java-11-openjdk-headless tzdata-java python3 zlib findutils which hostname iproute shadow-utils procps util-linux glibc-langpack-en wget \ && microdnf clean all \ # Add Cassandra user && groupadd -r cassandra --gid=999 \ diff --git a/Dockerfile-oss.ubi8 b/Dockerfile-oss.ubi8 index 304aeb90..0ce5e67c 100644 --- a/Dockerfile-oss.ubi8 +++ b/Dockerfile-oss.ubi8 @@ -118,7 +118,7 @@ ENV CASSANDRA_DATA_DIR /var/lib/cassandra # Update base layer RUN microdnf update && rm -rf /var/cache/yum \ # Install packages needed during install process - && microdnf install --nodocs java-1.8.0-openjdk-headless python3 zlib findutils which hostname iproute shadow-utils procps util-linux glibc-langpack-en \ + && microdnf install --nodocs java-1.8.0-openjdk-headless python3 zlib findutils which hostname iproute shadow-utils procps util-linux glibc-langpack-en wget \ && microdnf clean all \ # Add Cassandra user && groupadd -r cassandra --gid=999 \ diff --git a/cassandra-trunk/Dockerfile.ubi8 b/cassandra-trunk/Dockerfile.ubi8 index 9b31b8ee..b5b0d106 100644 --- a/cassandra-trunk/Dockerfile.ubi8 +++ b/cassandra-trunk/Dockerfile.ubi8 @@ -142,7 +142,7 @@ ENV CASSANDRA_FILES_PATH /opt/cassandra_files # Update base layer RUN microdnf update && rm -rf /var/cache/yum \ # Install packages needed during install process - && microdnf install --nodocs java-11-openjdk-headless tzdata-java python3 zlib findutils which hostname iproute shadow-utils procps util-linux glibc-langpack-en \ + && microdnf install --nodocs java-11-openjdk-headless tzdata-java python3 zlib findutils which hostname iproute shadow-utils procps util-linux glibc-langpack-en wget \ && microdnf clean all \ # Add Cassandra user && groupadd -r cassandra --gid=999 \ diff --git a/dse-68/Dockerfile.ubi8 b/dse-68/Dockerfile.ubi8 index e823b583..03162061 100644 --- a/dse-68/Dockerfile.ubi8 +++ b/dse-68/Dockerfile.ubi8 @@ -66,7 +66,7 @@ ENV LANG='en_US.UTF-8' LANGUAGE='en_US:en' LC_ALL='en_US.UTF-8' # Install runtime dependencies and updates RUN microdnf update && rm -rf /var/cache/yum && \ - microdnf install --nodocs -y java-1.8.0-openjdk-headless java-1.8.0-openjdk-devel python2 zlib libaio which findutils hostname iproute shadow-utils procps util-linux glibc-langpack-en && microdnf clean all + microdnf install --nodocs -y java-1.8.0-openjdk-headless java-1.8.0-openjdk-devel python2 zlib libaio which findutils hostname iproute shadow-utils procps util-linux glibc-langpack-en wget && microdnf clean all WORKDIR $HOME diff --git a/management-api-server/src/test/java/com/datastax/mgmtapi/DockerImageIT.java b/management-api-server/src/test/java/com/datastax/mgmtapi/DockerImageIT.java new file mode 100644 index 00000000..94f1afc8 --- /dev/null +++ b/management-api-server/src/test/java/com/datastax/mgmtapi/DockerImageIT.java @@ -0,0 +1,53 @@ +/* + * Copyright DataStax, Inc. + * + * Please see the included license file for details. + */ +package com.datastax.mgmtapi; + +import static org.junit.Assert.fail; +import static org.junit.Assume.assumeTrue; + +import com.datastax.mgmtapi.helpers.IntegrationTestUtils; +import java.io.IOException; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class DockerImageIT extends BaseDockerIntegrationTest { + + public DockerImageIT(String version) throws IOException { + super(version); + } + + @Test + public void testCurlExists() { + assumeTrue(IntegrationTestUtils.shouldRun()); + // see if curl is installed + try { + testCommandExists("curl"); + } catch (Throwable t) { + // this is expected, ensure the message indicates a process error code + fail( + "\"curl\" was not found in the image. Please ensure it has been added to the Dockerfile"); + } + } + + @Test + public void testWgetExists() { + assumeTrue(IntegrationTestUtils.shouldRun()); + // ensure wget is installed + try { + testCommandExists("wget"); + } catch (Throwable t) { + fail( + "\"wget\" was not found in the image. Please ensure it has been added to the Dockerfile"); + } + } + + private void testCommandExists(String cmd) { + String execId = docker.runCommand("which", "wget"); + docker.waitTillFinished(execId); + } +}