Skip to content

Commit de0379a

Browse files
aalexandnolanmar511
authored andcommitted
Example system test using Dockerfile files. (#23)
1 parent a8ea3ca commit de0379a

File tree

8 files changed

+130
-263
lines changed

8 files changed

+130
-263
lines changed

system-test/Dockerfile.linux

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
FROM golang:1.12-stretch as builder
2+
RUN apt-get update && apt-get install -y \
3+
git \
4+
&& rm -rf /var/lib/apt/lists/*
5+
WORKDIR /root/
6+
RUN go get github.com/google/pprof
7+
8+
FROM debian:stretch
9+
10+
RUN apt-get update && apt-get install -y \
11+
curl \
12+
python \
13+
make \
14+
g++ \
15+
&& rm -rf /var/lib/apt/lists/*
16+
17+
ENV NVM_DIR /root/.nvm
18+
RUN mkdir -p $NVM_DIR
19+
20+
ARG NODE_VERSION
21+
ARG NVM_NODEJS_ORG_MIRROR
22+
23+
# Install nvm with node and npm
24+
RUN curl https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash \
25+
&& . $NVM_DIR/nvm.sh \
26+
&& nvm install $NODE_VERSION
27+
28+
ENV BASH_ENV /root/.bashrc
29+
30+
WORKDIR /root/
31+
COPY --from=0 /go/bin/pprof /bin

system-test/Dockerfile.node10-alpine

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM golang:1.12-alpine as builder
2+
RUN apk update && apk upgrade && apk add --no-cache git
3+
WORKDIR /root/
4+
RUN go get github.com/google/pprof
5+
6+
FROM node:10-alpine
7+
RUN apk update && apk upgrade && apk add --no-cache bash python g++ make
8+
WORKDIR /root/
9+
COPY --from=0 /go/bin/pprof /bin
10+
RUN chmod a+x /bin/pprof

system-test/Dockerfile.node11-alpine

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM golang:1.12-alpine as builder
2+
RUN apk update && apk upgrade && apk add --no-cache git
3+
WORKDIR /root/
4+
RUN go get github.com/google/pprof
5+
6+
FROM node:11-alpine
7+
RUN apk update && apk upgrade && apk add --no-cache bash python g++ make
8+
WORKDIR /root/
9+
COPY --from=0 /go/bin/pprof /bin
10+
RUN chmod a+x /bin/pprof

system-test/Dockerfile.node6-alpine

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM golang:1.12-alpine as builder
2+
RUN apk update && apk upgrade && apk add --no-cache git
3+
WORKDIR /root/
4+
RUN go get github.com/google/pprof
5+
6+
FROM node:6-alpine
7+
RUN apk update && apk upgrade && apk add --no-cache bash python g++ make
8+
WORKDIR /root/
9+
COPY --from=0 /go/bin/pprof /bin
10+
RUN chmod a+x /bin/pprof

system-test/Dockerfile.node8-alpine

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
FROM golang:1.12-alpine as builder
2+
RUN apk update && apk upgrade && apk add --no-cache git
3+
WORKDIR /root/
4+
RUN go get github.com/google/pprof
5+
6+
FROM node:8-alpine
7+
RUN apk update && apk upgrade && apk add --no-cache bash python g++ make
8+
WORKDIR /root/
9+
COPY --from=0 /go/bin/pprof /bin
10+
RUN chmod a+x /bin/pprof

system-test/system_test.go

Lines changed: 0 additions & 232 deletions
This file was deleted.

system-test/system_test.sh

Lines changed: 17 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,24 @@
11
#!/bin/bash
22

3-
retry() {
4-
for i in {1..3}; do
5-
"${@}" && return 0
6-
done
7-
return 1
8-
}
9-
10-
# Fail on any error.
11-
set -eo pipefail
12-
13-
# Display commands being run.
14-
set -x
3+
# Trap all errors.
4+
trap "echo '** AT LEAST ONE OF TESTS FAILED **'" ERR
155

16-
# Record directory of pprof-nodejs.
17-
cd $(dirname $0)/..
18-
BASE_DIR=$(pwd)
6+
# Fail on any error, show commands run.
7+
set -eox pipefail
198

20-
RUN_ONLY_V8_CANARY_TEST="${RUN_ONLY_V8_CANARY_TEST:-false}"
21-
echo "$RUN_ONLY_V8_CANARY_TEST"
22-
23-
# Install nvm.
24-
retry curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash &>/dev/null
25-
export NVM_DIR="$HOME/.nvm" &>/dev/null
26-
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" &>/dev/null
9+
retry() {
10+
"${@}" || "${@}" || "${@}" || exit $?
11+
}
2712

28-
# Move system test to separate directory to run.
29-
TESTDIR="$BASE_DIR/run-system-test"
30-
cp -R "system-test" "$TESTDIR"
13+
cd $(dirname $0)
3114

32-
# Run test.
33-
cd "$TESTDIR"
34-
retry go get -t -d .
35-
go test -v -timeout=10m -run TestAgentIntegration -pprof_nodejs_path="$BASE_DIR" -run_only_v8_canary_test="$RUN_ONLY_V8_CANARY_TEST" -binary_host="$BINARY_HOST"
15+
for i in 6 8 10 11; do
16+
# Test Linux support for the given node version.
17+
retry docker build -f Dockerfile.linux --build-arg NODE_VERSION=$i -t node$i-linux .
18+
docker run -v $PWD/..:/src node$i-linux /src/system-test/test.sh
19+
# Test Alpine support for the given node version.
20+
docker build -f Dockerfile.node$i-alpine -t node$i-alpine .
21+
docker run -v $PWD/..:/src node$i-alpine /src/system-test/test.sh
22+
done
3623

37-
# Remove directory where test was run.
38-
rm -r $TESTDIR
24+
echo '** ALL TESTS PASSED **'

0 commit comments

Comments
 (0)