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

Fixing integration tests. #317

Merged
merged 2 commits into from
Aug 21, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions setup-tests/Dockerfile.diffBase
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM gcr.io/gcp-runtimes/centos7:latest

# docker build . -f Dockerfile.diffBase -t gcr.io/gcp-runtimes/container-diff-tests/diff-base:latest

RUN yum -q -y install which
RUN mkdir /first && echo "First" > /first/first.txt
RUN mkdir /second && echo "Second" > /second/second.txt
RUN mkdir /third && echo "Third" > /third/third.txt
8 changes: 8 additions & 0 deletions setup-tests/Dockerfile.diffLayerBase
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM gcr.io/gcp-runtimes/ubuntu_16_0_4:latest

# docker build . -f Dockerfile.diffLayerBase -t gcr.io/gcp-runtimes/container-diff-tests/diff-layer-base:latest


RUN mkdir /first && echo "First" > /first/first.txt
RUN mkdir /second && echo "Second" > /second/second.txt
RUN mkdir /third && echo "Third" > /third/third.txt
7 changes: 7 additions & 0 deletions setup-tests/Dockerfile.diffLayerModified
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM gcr.io/gcp-runtimes/ubuntu_16_0_4:latest

# docker build . -f Dockerfile.diffLayerModified -t gcr.io/gcp-runtimes/container-diff-tests/diff-layer-modified:latest

RUN mkdir /first && echo "First" > /first/first.txt
RUN echo "No Second Layer"
RUN mkdir /modified && echo "Modified" > /modified/modified.txt
6 changes: 6 additions & 0 deletions setup-tests/Dockerfile.diffModified
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FROM gcr.io/gcp-runtimes/container-diff-tests/diff-base:latest

# docker build . -f Dockerfile.diffModified -t gcr.io/gcp-runtimes/container-diff-tests/diff-modified:latest

RUN rm -rf /second && mkdir /modified && echo "Modified" > /modified/modified.txt
RUN yum -q -y install gcc
7 changes: 7 additions & 0 deletions setup-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
These scripts and Dockerfiles are intended to help regenerate and push the
container files required by the integration tests, and then regenerate the
expected output files.

To run:
cd setup-tests
./init-tests.sh
74 changes: 74 additions & 0 deletions setup-tests/init-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/bin/bash

set +x
# Grab the container definitions from the integration test
diffBase=$(cat ../tests/integration_test.go | grep diffBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
diffModified=$(cat ../tests/integration_test.go | grep diffModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
diffLayerBase=$(cat ../tests/integration_test.go | grep diffLayerBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
diffLayerModified=$(cat ../tests/integration_test.go | grep diffLayerModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
rpmBase=$(cat ../tests/integration_test.go | grep rpmBase | grep valentinrothberg | sed -e 's/.* = //g' | sed -e 's/"//g')
rpmModified=$(cat ../tests/integration_test.go | grep rpmModified | grep valentinrothberg | sed -e 's/.* = //g' | sed -e 's/"//g')
aptBase=$(cat ../tests/integration_test.go | grep aptBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
aptModified=$(cat ../tests/integration_test.go | grep aptModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
nodeBase=$(cat ../tests/integration_test.go | grep nodeBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
nodeModified=$(cat ../tests/integration_test.go | grep nodeModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
multiBase=$(cat ../tests/integration_test.go | grep -w multiBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
multiModified=$(cat ../tests/integration_test.go | grep -w multiModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
metadataBase=$(cat ../tests/integration_test.go | grep metadataBase | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
metadataModified=$(cat ../tests/integration_test.go | grep metadataModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')
pipModified=$(cat ../tests/integration_test.go | grep pipModified | grep gcr.io | sed -e 's/.* = //g' | sed -e 's/"//g')

# Echo the container definitions.
echo diffBase=$diffBase
echo diffModified=$diffModified
echo diffLayerBase=$diffLayerBase
echo diffLayerModified=$diffLayerModified
echo rpmBase=$rpmBase
echo rpmModified=$rpmModified
echo aptBase=$aptBase
echo aptModified=$aptModified
echo nodeBase=$nodeBase
echo nodeModified=$nodeModified
echo multiBase=$multiBase
echo multiModified=$multiModified
echo metadataBase=$metadataBase
echo metadataModified=$metadataModified
echo pipModified=$pipModified

# Now generate the containers
# XXX TO-DO for now we're only generated diffBase diffModified diffLayerBase and
# diffLayerModified, eventually we should generate all of them
#

echo 'docker build . -f Dockerfile.diffBase -t $diffBase:latest'
docker build . -f Dockerfile.diffBase -t $diffBase:latest
docker push $diffBase:latest
echo 'docker build . -f Dockerfile.diffLayerBase -t $diffLayerBase:latest'
docker build . -f Dockerfile.diffLayerBase -t $diffLayerBase:latest
docker push $diffLayerBase:latest
echo 'docker build . -f Dockerfile.diffLayerModified -t $diffLayerModified:latest'
docker build . -f Dockerfile.diffLayerModified -t $diffLayerModified:latest
docker push $diffLayerModified:latest
echo 'docker build . -f Dockerfile.diffModified -t $diffModified:latest'
docker build . -f Dockerfile.diffModified -t $diffModified:latest
docker push $diffModified:latest

#Now generate expected outputs. Do NOT commit these without reviewing them for reasonableness
container-diff diff --no-cache -j --type=file $diffBase $diffModified > ../tests/file_diff_expected.json
container-diff diff --no-cache -j --type=layer $diffLayerBase $diffLayerModified > ../tests/file_layer_diff_expected.json
container-diff diff --no-cache -j --type=size $diffLayerBase $diffLayerModified > ../tests/size_diff_expected.json
container-diff diff --no-cache -j --type=sizelayer $diffLayerBase $diffLayerModified > ../tests/size_layer_diff_expected.json
container-diff diff --no-cache -j --type=apt $aptBase $aptModified > ../tests/apt_diff_expected.json
container-diff diff --no-cache -j --type=node $nodeBase $nodeModified > ../tests/node_diff_order_expected.json
container-diff diff --no-cache -j --type=node --type=pip --type=apt $multiBase $multiModified > ../tests/multi_diff_expected.json
container-diff diff --no-cache -j --type=history $diffBase $diffModified > ../tests/hist_diff_expected.json
container-diff diff --no-cache -j --type=metadata $metadataBase $metadataModified > ../tests/metadata_diff_expected.json
container-diff diff --no-cache -j --type=apt -o $aptBase $aptModified > ../tests/apt_sorted_diff_expected.json
container-diff analyze --no-cache -j --type=apt $aptModified > ../tests/apt_analysis_expected.json
container-diff analyze --no-cache -j --type=file -o $diffModified > ../tests/file_sorted_analysis_expected.json
container-diff analyze --no-cache -j --type=layer $diffLayerBase > ../tests/file_layer_analysis_expected.json
container-diff analyze --no-cache -j --type=size $diffBase > ../tests/size_analysis_expected.json
container-diff analyze --no-cache -j --type=sizelayer $diffLayerBase > ../tests/size_layer_analysis_expected.json
container-diff analyze --no-cache -j --type=pip $pipModified > ../tests/pip_analysis_expected.json
container-diff analyze --no-cache -j --type=node $nodeModified > ../tests/node_analysis_expected.json

2 changes: 1 addition & 1 deletion test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fi


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

# Check boilerplate
echo "Checking boilerplate..."
Expand Down
2 changes: 1 addition & 1 deletion tests/apt_analysis_expected.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[
{
"Image": "gcr.io/gcp-runtimes/apt-modified",
"Image": "gcr.io/gcp-runtimes/container-diff-tests/apt-modified",
"AnalyzeType": "Apt",
"Analysis": [
{
Expand Down
4 changes: 2 additions & 2 deletions tests/apt_diff_expected.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"Image1": "gcr.io/gcp-runtimes/apt-base",
"Image2": "gcr.io/gcp-runtimes/apt-modified",
"Image1": "gcr.io/gcp-runtimes/container-diff-tests/apt-base",
"Image2": "gcr.io/gcp-runtimes/container-diff-tests/apt-modified",
"DiffType": "Apt",
"Diff": {
"Packages1": [
Expand Down
4 changes: 2 additions & 2 deletions tests/apt_sorted_diff_expected.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[
{
"Image1": "gcr.io/gcp-runtimes/apt-base",
"Image2": "gcr.io/gcp-runtimes/apt-modified",
"Image1": "gcr.io/gcp-runtimes/container-diff-tests/apt-base",
"Image2": "gcr.io/gcp-runtimes/container-diff-tests/apt-modified",
"DiffType": "Apt",
"Diff": {
"Packages1": [
Expand Down
Loading