refactor: simpler local integration tests (#2110)

* tests(integration): add fake gcs server and use sdk instead of gsutil

* tests(integration): add flag to run tests for a subset of dockerfiles

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* tests(integration): conditionally create gcs client

* refactor: create package for gcs bucket interaction

* tests(integration): use util.Tar for integration tarball creation

* refactor: create TarballOfDirectory func

* chore: add dockerignore for faster builds

* docs: add docs for dockerfile pattern

* fix: issue during personal review

* chore: cleanup

Signed-off-by: Höhl, Lukas <lukas.hoehl@accso.de>

* fix(integration-tests): remove default bucket

Signed-off-by: Lukas Hoehl <ludi.origin@gmail.com>
This commit is contained in:
Lukas
2022-06-14 13:38:01 -04:00
committed by GitHub
parent 9f57952214
commit 679c71c907
17 changed files with 377 additions and 178 deletions
+35 -3
View File
@@ -13,9 +13,19 @@
# See the License for the specific language governing permissions and
# limitations under the License.
set -ex
set -e
function start_local_registry {
docker start registry || docker run --name registry -d -p 5000:5000 registry:2
}
# TODO: to get this working, we need a way to override the gcs endpoint of kaniko at runtime
# If this is done, integration test main includes flags --gcs-endpoint and --disable-gcs-auth
# to mock the gcs endpoints and upload files to the fake-gcs-server
function start_fake_gcs_server {
docker start fake-gcs-server || docker run -d -p 4443:4443 --name fake-gcs-server fsouza/fake-gcs-server -scheme http
}
GCS_BUCKET="${GCS_BUCKET:-gs://kaniko-test-bucket}"
IMAGE_REPO="${IMAGE_REPO:-gcr.io/kaniko-test}"
docker version
@@ -23,4 +33,26 @@ docker version
echo "Running integration tests..."
make out/executor
make out/warmer
go test ./integration/... --bucket "${GCS_BUCKET}" --repo "${IMAGE_REPO}" --timeout 50m "$@"
FLAGS=(
"--timeout=50m"
)
if [[ -n $DOCKERFILE_PATTERN ]]; then
FLAGS+=("--dockerfiles-pattern=$DOCKERFILE_PATTERN")
fi
if [[ -n $LOCAL ]]; then
echo "running in local mode, mocking registry and gcs bucket..."
start_local_registry
IMAGE_REPO="localhost:5000/kaniko-test"
GCS_BUCKET=""
fi
FLAGS+=(
"--bucket=${GCS_BUCKET}"
"--repo=${IMAGE_REPO}"
)
go test ./integration/... "${FLAGS[@]}" "$@"