From 7fed47746d226e0f1ec1fee01bd4be7b2c72a5bd Mon Sep 17 00:00:00 2001 From: fanzhangio <fanz@vmware.com> Date: Thu, 12 Jul 2018 16:30:08 -0700 Subject: [PATCH] Speed up tests by caching deps --- common.sh | 17 +++++++++++++++++ testv1.sh | 15 +++++++++------ 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/common.sh b/common.sh index ca3d70bfde..31839c1358 100644 --- a/common.sh +++ b/common.sh @@ -146,4 +146,21 @@ function setup_envs { export TEST_ASSET_KUBECTL=/tmp/kubebuilder/bin/kubectl export TEST_ASSET_KUBE_APISERVER=/tmp/kubebuilder/bin/kube-apiserver export TEST_ASSET_ETCD=/tmp/kubebuilder/bin/etcd + export TEST_DEP=/tmp/kubebuilder/init_project +} + +function cache_dep { + header_text "caching inited projects" + if [ -d "$TEST_DEP" ]; then + rm -rf "$TEST_DEP" + fi + mkdir -p "$TEST_DEP" + cp -r $PWD/* $TEST_DEP +} + +function dump_cache { + header_text "dump cached project and deps" + if [ -d "$TEST_DEP" ]; then + cp -r $TEST_DEP/* . + fi } \ No newline at end of file diff --git a/testv1.sh b/testv1.sh index dc669ee0cd..d7ed9ffc95 100755 --- a/testv1.sh +++ b/testv1.sh @@ -23,8 +23,11 @@ function test_init_project { header_text "performing init project" kubebuilder init --project-version=v1 --domain example.com <<< "y" make + cache_dep } + + function test_init_project_manual_dep_ensure { header_text "performing init project w/o dep ensure" kubebuilder init --project-version=v1 --domain example.com <<< "n" @@ -101,27 +104,27 @@ prepare_testdir_under_gopath test_init_project_manual_dep_ensure prepare_testdir_under_gopath -test_init_project +dump_cache test_create_api_controller prepare_testdir_under_gopath -test_init_project +dump_cache test_create_namespaced_api_controller prepare_testdir_under_gopath -test_init_project +dump_cache test_create_api_only prepare_testdir_under_gopath -test_init_project +dump_cache test_create_namespaced_api_only prepare_testdir_under_gopath -test_init_project +dump_cache test_create_coretype_controller prepare_testdir_under_gopath -test_init_project +dump_cache test_create_namespaced_coretype_controller exit $rc