Skip to content

Commit

Permalink
test(openssl): use the parent test scripts as a sanity check pre and …
Browse files Browse the repository at this point in the history
…post isntallation
  • Loading branch information
hutchic committed Dec 8, 2022
1 parent 991aeb4 commit 22c2947
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 13 deletions.
23 changes: 16 additions & 7 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ ARG DOCKER_REGISTRY=ghcr.io
ARG DOCKER_IMAGE_NAME

# List out all image permutations to trick dependabot
FROM --platform=linux/amd64 ghcr.io/kong/kong-openssl:1.1.3-x86_64-linux-musl as x86_64-linux-musl
FROM --platform=linux/amd64 ghcr.io/kong/kong-openssl:1.1.3-x86_64-linux-gnu as x86_64-linux-gnu
FROM --platform=linux/arm64 ghcr.io/kong/kong-openssl:1.1.3-aarch64-linux-musl as aarch64-linux-musl
FROM --platform=linux/arm64 ghcr.io/kong/kong-openssl:1.1.3-aarch64-linux-gnu as aarch64-linux-gnu
FROM --platform=linux/amd64 ghcr.io/kong/kong-openssl:1.1.5-x86_64-linux-musl as x86_64-linux-musl
FROM --platform=linux/amd64 ghcr.io/kong/kong-openssl:1.1.5-x86_64-linux-gnu as x86_64-linux-gnu
FROM --platform=linux/arm64 ghcr.io/kong/kong-openssl:1.1.5-aarch64-linux-musl as aarch64-linux-musl
FROM --platform=linux/arm64 ghcr.io/kong/kong-openssl:1.1.5-aarch64-linux-gnu as aarch64-linux-gnu


# Run the build script
Expand All @@ -16,9 +16,18 @@ FROM $ARCHITECTURE-$OSTYPE as build
COPY . /tmp
WORKDIR /tmp

RUN /tmp/build.sh

RUN /tmp/test.sh
# Run our predecessor tests
# Configure, build, and install
# Run our own tests
# Re-run our predecessor tests
RUN /test/*/test.sh && \
/tmp/build.sh && \
/tmp/test.sh && \
/test/*/test.sh

# Test scripts left where downstream images can run them
COPY test.sh /test/kong-runtime/test.sh
COPY .env /test/kong-runtime/.env

# Copy the build result to scratch so we can export the result
FROM scratch as package
Expand Down
6 changes: 6 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
export $(grep -v '^#' $SCRIPT_DIR/.env | xargs)

function main() {
echo '--- installing kong runtime ---'
with_backoff curl --fail -sSLo pcre.tar.gz "https://downloads.sourceforge.net/project/pcre/pcre/${PCRE_VERSION}/pcre-${PCRE_VERSION}.tar.gz"
tar -xzvf pcre.tar.gz
ln -s pcre-${PCRE_VERSION} pcre
Expand Down Expand Up @@ -39,6 +40,7 @@ function main() {
popd

pushd openresty-${OPENRESTY_VERSION}
echo '--- installing openresty ---'
OPENRESTY_OPTS=(
"--prefix=/usr/local/openresty"
"--with-pcre-jit"
Expand Down Expand Up @@ -79,15 +81,18 @@ function main() {
pushd /tmp/lua-resty-events
make install LUA_LIB_DIR=/tmp/build/usr/local/openresty/lualib
popd
echo '--- installed openresty ---'

pushd /tmp/luarocks-${LUAROCKS_VERSION}
echo '--- installing luarocks ---'
./configure \
--prefix=/usr/local \
--with-lua=/tmp/build/usr/local/openresty/luajit \
--with-lua-include=/tmp/build/usr/local/openresty/luajit/include/luajit-2.1

make build -j2
make install DESTDIR=/tmp/build
echo '--- installed luarocks ---'
popd

arch=$(uname -m)
Expand All @@ -105,6 +110,7 @@ function main() {
mkdir -p /tmp/build/usr/local/lib/lua

sed -i 's/\/tmp\/build//' `grep -l -I -r '\/tmp\/build' /tmp/build/`
echo '--- installed kong runtime ---'
}

# Retries a command a configurable number of times with backoff.
Expand Down
11 changes: 5 additions & 6 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,15 @@ SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
export $(grep -v '^#' $SCRIPT_DIR/.env | xargs)

function test() {
echo '--- testing kong runtime (openresty, luarocks) ---'
cp -R /tmp/build/* /
mv /tmp/build /tmp/buffer # Check we didn't link dependencies to `/tmp/build/...`

/usr/local/kong/bin/openssl version # From kong-openssl test.sh
ls -la /usr/local/kong/lib/libyaml.so # From kong-openssl test.sh
ldd /usr/local/kong/lib/libyaml.so
ldd /usr/local/kong/bin/openssl

/usr/local/openresty/bin/openresty -v 2>&1 | grep -q ${OPENRESTY_VERSION}
/usr/local/openresty/bin/openresty -V 2>&1 | grep -q pcre
ldd /usr/local/openresty/bin/openresty
/usr/local/openresty/bin/openresty -V 2>&1 | grep -q lua-kong-nginx-module
/usr/local/openresty/bin/openresty -V 2>&1 | grep -q lua-resty-lmdb
/usr/local/openresty/bin/openresty -V 2>&1 | grep -q lua-resty-events
/usr/local/openresty/bin/resty -e 'print(jit.version)' | grep -q 'LuaJIT[[:space:]][[:digit:]]\+.[[:digit:]]\+.[[:digit:]]\+-[[:digit:]]\{8\}'

ls -l /usr/local/openresty/lualib/resty/websocket/*.lua
Expand All @@ -30,6 +28,7 @@ function test() {
ldd /usr/local/openresty/lualib/libatc_router.so

mv /tmp/buffer /tmp/build
echo '--- tested kong runtime ---'
}

test

0 comments on commit 22c2947

Please sign in to comment.