Skip to content
This repository was archived by the owner on Mar 27, 2024. It is now read-only.

Commit 640f66f

Browse files
committed
Fixing integration tests. Updating containers used for tests. Adding test initialization script and Dockerfiles.
1 parent 97b57b4 commit 640f66f

26 files changed

+84463
-1993
lines changed

setup-tests/Dockerfile.diffBase

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM gcr.io/gcp-runtimes/centos7:latest
2+
3+
# docker build . -f Dockerfile.diffBase -t gcr.io/gcp-runtimes/container-diff-tests/diff-base:latest
4+
5+
RUN yum -q -y install which
6+
RUN mkdir /first && echo "First" > /first/first.txt
7+
RUN mkdir /second && echo "Second" > /second/second.txt
8+
RUN mkdir /third && echo "Third" > /third/third.txt

setup-tests/Dockerfile.diffLayerBase

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
FROM gcr.io/gcp-runtimes/ubuntu_16_0_4:latest
2+
3+
# docker build . -f Dockerfile.diffLayerBase -t gcr.io/gcp-runtimes/container-diff-tests/diff-layer-base:latest
4+
5+
6+
RUN mkdir /first && echo "First" > /first/first.txt
7+
RUN mkdir /second && echo "Second" > /second/second.txt
8+
RUN mkdir /third && echo "Third" > /third/third.txt
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM gcr.io/gcp-runtimes/ubuntu_16_0_4:latest
2+
3+
# docker build . -f Dockerfile.diffLayerModified -t gcr.io/gcp-runtimes/container-diff-tests/diff-layer-modified:latest
4+
5+
RUN mkdir /first && echo "First" > /first/first.txt
6+
RUN echo "No Second Layer"
7+
RUN mkdir /modified && echo "Modified" > /modified/modified.txt

setup-tests/Dockerfile.diffModified

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM gcr.io/gcp-runtimes/container-diff-tests/diff-base:latest
2+
3+
# docker build . -f Dockerfile.diffModified -t gcr.io/gcp-runtimes/container-diff-tests/diff-modified:latest
4+
5+
RUN rm -rf /second && mkdir /modified && echo "Modified" > /modified/modified.txt
6+
RUN yum -q -y install gcc

setup-tests/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
These scripts and Dockerfiles are intended to help regenerate and push the
2+
container files required by the integration tests, and then regenerate the
3+
expected output files.
4+
5+
To run:
6+
cd setup-tests
7+
./init-tests.sh

setup-tests/init-tests.sh

+74
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/bin/bash
2+
3+
set +x
4+
# Grab the container definitions from the integration test
5+
diffBase=$(cat ../tests/integration_test.go | grep diffBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
6+
diffModified=$(cat ../tests/integration_test.go | grep diffModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
7+
diffLayerBase=$(cat ../tests/integration_test.go | grep diffLayerBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
8+
diffLayerModified=$(cat ../tests/integration_test.go | grep diffLayerModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
9+
rpmBase=$(cat ../tests/integration_test.go | grep rpmBase | grep valentinrothberg | sed -e 's/.* = //g' | sed -e 's/"//g')
10+
rpmModified=$(cat ../tests/integration_test.go | grep rpmModified | grep valentinrothberg | sed -e 's/.* = //g' | sed -e 's/"//g')
11+
aptBase=$(cat ../tests/integration_test.go | grep aptBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
12+
aptModified=$(cat ../tests/integration_test.go | grep aptModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
13+
nodeBase=$(cat ../tests/integration_test.go | grep nodeBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
14+
nodeModified=$(cat ../tests/integration_test.go | grep nodeModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
15+
multiBase=$(cat ../tests/integration_test.go | grep -w multiBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
16+
multiModified=$(cat ../tests/integration_test.go | grep -w multiModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
17+
metadataBase=$(cat ../tests/integration_test.go | grep metadataBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
18+
metadataModified=$(cat ../tests/integration_test.go | grep metadataModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
19+
pipModified=$(cat ../tests/integration_test.go | grep pipModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
20+
21+
# Echo the container definitions.
22+
echo diffBase=$diffBase
23+
echo diffModified=$diffModified
24+
echo diffLayerBase=$diffLayerBase
25+
echo diffLayerModified=$diffLayerModified
26+
echo rpmBase=$rpmBase
27+
echo rpmModified=$rpmModified
28+
echo aptBase=$aptBase
29+
echo aptModified=$aptModified
30+
echo nodeBase=$nodeBase
31+
echo nodeModified=$nodeModified
32+
echo multiBase=$multiBase
33+
echo multiModified=$multiModified
34+
echo metadataBase=$metadataBase
35+
echo metadataModified=$metadataModified
36+
echo pipModified=$pipModified
37+
38+
# Now generate the containers
39+
# XXX TO-DO for now we're only generated diffBase diffModified diffLayerBase and
40+
# diffLayerModified, eventually we should generate all of them
41+
#
42+
43+
echo 'docker build . -f Dockerfile.diffBase -t $diffBase:latest'
44+
docker build . -f Dockerfile.diffBase -t $diffBase:latest
45+
docker push $diffBase:latest
46+
echo 'docker build . -f Dockerfile.diffLayerBase -t $diffLayerBase:latest'
47+
docker build . -f Dockerfile.diffLayerBase -t $diffLayerBase:latest
48+
docker push $diffLayerBase:latest
49+
echo 'docker build . -f Dockerfile.diffLayerModified -t $diffLayerModified:latest'
50+
docker build . -f Dockerfile.diffLayerModified -t $diffLayerModified:latest
51+
docker push $diffLayerModified:latest
52+
echo 'docker build . -f Dockerfile.diffModified -t $diffModified:latest'
53+
docker build . -f Dockerfile.diffModified -t $diffModified:latest
54+
docker push $diffModified:latest
55+
56+
#Now generate expected outputs. Do NOT commit these without reviewing them for reasonableness
57+
container-diff diff --no-cache -j --type=file $diffBase $diffModified > ../tests/file_diff_expected.json
58+
container-diff diff --no-cache -j --type=layer $diffLayerBase $diffLayerModified > ../tests/file_layer_diff_expected.json
59+
container-diff diff --no-cache -j --type=size $diffLayerBase $diffLayerModified > ../tests/size_diff_expected.json
60+
container-diff diff --no-cache -j --type=sizelayer $diffLayerBase $diffLayerModified > ../tests/size_layer_diff_expected.json
61+
container-diff diff --no-cache -j --type=apt $aptBase $aptModified > ../tests/apt_diff_expected.json
62+
container-diff diff --no-cache -j --type=node $nodeBase $nodeModified > ../tests/node_diff_order_expected.json
63+
container-diff diff --no-cache -j --type=node --type=pip --type=apt $multiBase $multiModified > ../tests/multi_diff_expected.json
64+
container-diff diff --no-cache -j --type=history $diffBase $diffModified > ../tests/hist_diff_expected.json
65+
container-diff diff --no-cache -j --type=metadata $metadataBase $metadataModified > ../tests/metadata_diff_expected.json
66+
container-diff diff --no-cache -j --type=apt -o $aptBase $aptModified > ../tests/apt_sorted_diff_expected.json
67+
container-diff analyze --no-cache -j --type=apt $aptModified > ../tests/apt_analysis_expected.json
68+
container-diff analyze --no-cache -j --type=file -o $diffModified > ../tests/file_sorted_analysis_expected.json
69+
container-diff analyze --no-cache -j --type=layer $diffLayerBase > ../tests/file_layer_analysis_expected.json
70+
container-diff analyze --no-cache -j --type=size $diffBase > ../tests/size_analysis_expected.json
71+
container-diff analyze --no-cache -j --type=sizelayer $diffLayerBase > ../tests/size_layer_analysis_expected.json
72+
container-diff analyze --no-cache -j --type=pip $pipModified > ../tests/pip_analysis_expected.json
73+
container-diff analyze --no-cache -j --type=node $nodeModified > ../tests/node_analysis_expected.json
74+

test.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fi
3535

3636

3737
# Ignore these paths in the following tests.
38-
ignore="vendor\|out\|actions"
38+
ignore="vendor\|out\|actions\|setup-tests"
3939

4040
# Check boilerplate
4141
echo "Checking boilerplate..."

tests/apt_analysis_expected.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[
22
{
3-
"Image": "gcr.io/gcp-runtimes/apt-modified",
3+
"Image": "gcr.io/gcp-runtimes/container-diff-tests/apt-modified",
44
"AnalyzeType": "Apt",
55
"Analysis": [
66
{

tests/apt_diff_expected.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
3-
"Image1": "gcr.io/gcp-runtimes/apt-base",
4-
"Image2": "gcr.io/gcp-runtimes/apt-modified",
3+
"Image1": "gcr.io/gcp-runtimes/container-diff-tests/apt-base",
4+
"Image2": "gcr.io/gcp-runtimes/container-diff-tests/apt-modified",
55
"DiffType": "Apt",
66
"Diff": {
77
"Packages1": [

tests/apt_sorted_diff_expected.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[
22
{
3-
"Image1": "gcr.io/gcp-runtimes/apt-base",
4-
"Image2": "gcr.io/gcp-runtimes/apt-modified",
3+
"Image1": "gcr.io/gcp-runtimes/container-diff-tests/apt-base",
4+
"Image2": "gcr.io/gcp-runtimes/container-diff-tests/apt-modified",
55
"DiffType": "Apt",
66
"Diff": {
77
"Packages1": [

0 commit comments

Comments
 (0)