Skip to content

Commit

Permalink
Run simple tests with distroless variant (#14944)
Browse files Browse the repository at this point in the history
* Run simple test with distroless images

Co-authored-by: Jakob Schmid <jakob.schmid@sap.com>

* Add comment to set_image_vars

* Use e2e-simpleTest.sh to run distroless test

Co-authored-by: Jakob Schmid <jakob.schmid@sap.com>

* Use mini-kube for distroless tests

Co-authored-by: Jakob Schmid <jakob.schmid@sap.com>

* Add distroless test to circle-ci

Co-authored-by: Jakob Schmid <jakob.schmid@sap.com>

* Make tests for distroless work

Co-authored-by: Jakob Schmid <jakob.schmid@sap.com>

* Migrate e2e_simple distroless test from circle ci to prow

Co-authored-by: Ulrich Kramer <u.kramer@sap.com>

* Rename test_tag to app_tag and test_hub to app_hub

Co-authored-by: Philipp Stehle <philipp.stehle@sap.com>

* Fix building docker images for distroless variant

Co-authored-by: Ulrich Kramer <u.kramer@sap.com>
  • Loading branch information
kramerul authored and istio-testing committed Jun 27, 2019
1 parent 436d2df commit 2b86b66
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 27 deletions.
13 changes: 10 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ ifeq ($(TAG),)
$(error "TAG cannot be empty")
endif

VARIANT :=
ifeq ($(VARIANT),)
TAG_VARIANT:=${TAG}
else
TAG_VARIANT:=${TAG}-${VARIANT}
endif

PULL_POLICY ?= IfNotPresent
ifeq ($(TAG),latest)
PULL_POLICY = Always
Expand Down Expand Up @@ -686,7 +693,7 @@ istio-init.yaml: $(HELM) $(HOME)/.helm
cat install/kubernetes/namespace.yaml > install/kubernetes/$@
cat install/kubernetes/helm/istio-init/files/crd-* >> install/kubernetes/$@
$(HELM) template --name=istio --namespace=istio-system \
--set global.tag=${TAG} \
--set global.tag=${TAG_VARIANT} \
--set global.hub=${HUB} \
install/kubernetes/helm/istio-init >> install/kubernetes/$@

Expand All @@ -702,7 +709,7 @@ istio-demo.yaml istio-demo-auth.yaml istio-remote.yaml istio-minimal.yaml: $(HEL
$(HELM) template \
--name=istio \
--namespace=istio-system \
--set global.tag=${TAG} \
--set global.tag=${TAG_VARIANT} \
--set global.hub=${HUB} \
--set global.imagePullPolicy=$(PULL_POLICY) \
--set global.proxy.enableCoreDump=${ENABLE_COREDUMP} \
Expand Down Expand Up @@ -739,7 +746,7 @@ $(e2e_files): $(HELM) $(HOME)/.helm istio-init.yaml
$(HELM) template \
--name=istio \
--namespace=istio-system \
--set global.tag=${TAG} \
--set global.tag=${TAG_VARIANT} \
--set global.hub=${HUB} \
--set global.imagePullPolicy=$(PULL_POLICY) \
--set global.proxy.enableCoreDump=${ENABLE_COREDUMP} \
Expand Down
32 changes: 32 additions & 0 deletions prow/e2e-simpleTests-distroless.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/bin/bash

# Copyright 2018 Istio Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


#######################################
# #
# e2e-suite #
# #
#######################################

# Exit immediately for non zero status
set -e
# Check unset variables
set -u
# Print commands
set -x

echo 'Running Simple test with rbac, auth Tests and distroless'
./prow/e2e-suite.sh --auth_enable --single_test e2e_simple --installer helm --variant distroless "$@"
8 changes: 5 additions & 3 deletions prow/e2e-suite.sh
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ export PILOT_CLUSTER="${PILOT_CLUSTER:-}"
export USE_MASON_RESOURCE="${USE_MASON_RESOURCE:-True}"
export CLEAN_CLUSTERS="${CLEAN_CLUSTERS:-True}"
export HUB=${HUB:-"gcr.io/istio-testing"}

# shellcheck source=prow/lib.sh
source "${ROOT}/prow/lib.sh"
if [[ $HUB == *"istio-testing"* ]]; then
Expand All @@ -61,6 +60,9 @@ for ((i=1; i<=$#; i++)); do
--timeout) ((i++)); E2E_TIMEOUT=${!i}
continue
;;
--variant) ((i++)); VARIANT="${!i}"
continue
;;
esac
E2E_ARGS+=( "${!i}" )
done
Expand All @@ -75,7 +77,7 @@ make init

if [[ $HUB == *"istio-testing"* ]]; then
# upload images
time ISTIO_DOCKER_HUB="${HUB}" make push HUB="${HUB}" TAG="${TAG}"
time ISTIO_DOCKER_HUB="${HUB}" make push HUB="${HUB}" TAG="${TAG}" DOCKER_BUILD_VARIANTS="${VARIANT:-default}"
fi

setup_e2e_cluster
Expand All @@ -91,4 +93,4 @@ E2E_ARGS+=("--skip_cleanup")
time ISTIO_DOCKER_HUB=$HUB \
E2E_ARGS="${E2E_ARGS[*]}" \
JUNIT_E2E_XML="${ARTIFACTS_DIR}/junit.xml" \
make with_junit_report TARGET="${SINGLE_TEST}" ${E2E_TIMEOUT:+ E2E_TIMEOUT="${E2E_TIMEOUT}"}
make with_junit_report TARGET="${SINGLE_TEST}" ${VARIANT:+ VARIANT="${VARIANT}"} ${E2E_TIMEOUT:+ E2E_TIMEOUT="${E2E_TIMEOUT}"}
5 changes: 3 additions & 2 deletions release/gcb/docker_tag_push_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,11 @@ function set_image_vars() {
TAR_NAME="${BASE_NAME%.*}"
IMAGE_NAME="${TAR_NAME%.*}"
VARIANT_NAME=""
#check if it is a build variant (e.g. distroless)
#check if it is a build variant (e.g. sidecar_injector-distroless)
case "${IMAGE_NAME}" in
*-distroless)
VARIANT_NAME="-${IMAGE_NAME##*-}"
# in case of a distroless tar file, we remove the "-distroless" from the image name
VARIANT_NAME="-distroless"
IMAGE_NAME="${IMAGE_NAME%${VARIANT_NAME}}"
;;
esac
Expand Down
14 changes: 13 additions & 1 deletion tests/e2e/framework/kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import (
"testing"
"time"

"github.com/hashicorp/go-multierror"
multierror "github.com/hashicorp/go-multierror"
"github.com/pkg/errors"

testKube "istio.io/istio/pkg/test/kube"
Expand Down Expand Up @@ -100,6 +100,8 @@ var (
mixerTag = flag.String("mixer_tag", os.Getenv("TAG"), "Mixer tag")
pilotHub = flag.String("pilot_hub", os.Getenv("HUB"), "Pilot hub")
pilotTag = flag.String("pilot_tag", os.Getenv("TAG"), "Pilot tag")
appHub = flag.String("app_hub", os.Getenv("HUB"), "Test application hub")
appTag = flag.String("app_tag", os.Getenv("TAG"), "Test application tag")
proxyHub = flag.String("proxy_hub", os.Getenv("HUB"), "Proxy hub")
proxyTag = flag.String("proxy_tag", os.Getenv("TAG"), "Proxy tag")
caHub = flag.String("ca_hub", os.Getenv("HUB"), "Ca hub")
Expand Down Expand Up @@ -433,6 +435,16 @@ func (k *KubeInfo) PilotTag() string {
return *pilotTag
}

// AppHub exposes the Docker hub used for the test application image.
func (k *KubeInfo) AppHub() string {
return *appHub
}

// AppTag exposes the Docker tag used for the test application image.
func (k *KubeInfo) AppTag() string {
return *appTag
}

// ProxyHub exposes the Docker hub used for the proxy image.
func (k *KubeInfo) ProxyHub() string {
return *proxyHub
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/tests/pilot/pilot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ func getApp(deploymentName, serviceName string, replicas, port1, port2, port3, p
return framework.App{
AppYamlTemplate: "testdata/app.yaml.tmpl",
Template: map[string]string{
"Hub": tc.Kube.PilotHub(),
"Tag": tc.Kube.PilotTag(),
"Hub": tc.Kube.AppHub(),
"Tag": tc.Kube.AppTag(),
"service": serviceName,
"deployment": deploymentName,
"replicas": strconv.Itoa(replicas),
Expand Down
6 changes: 3 additions & 3 deletions tests/e2e/tests/simple/nginx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
"testing"
"time"

"github.com/hashicorp/go-multierror"
multierror "github.com/hashicorp/go-multierror"

"istio.io/istio/tests/e2e/framework"
"istio.io/istio/tests/util"
Expand Down Expand Up @@ -134,8 +134,8 @@ func getApp(deploymentName, serviceName string, port1, port2, port3, port4, port
AppYamlTemplate: util.GetResourcePath(appYamlTmpl),
KubeInject: injectProxy,
Template: map[string]string{
"Hub": tc.Kube.PilotHub(),
"Tag": tc.Kube.PilotTag(),
"Hub": tc.Kube.AppHub(),
"Tag": tc.Kube.AppTag(),
"service": serviceName,
"perServiceAuth": strconv.FormatBool(perServiceAuth),
"deployment": deploymentName,
Expand Down
21 changes: 13 additions & 8 deletions tests/istio.mk
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,28 @@ endif

E2E_TIMEOUT ?= 25


# If set outside, it appears it is not possible to modify the variable.
E2E_ARGS ?=

ISTIOCTL_BIN ?= ${ISTIO_OUT}/istioctl

DEFAULT_EXTRA_E2E_ARGS = ${MINIKUBE_FLAGS}
DEFAULT_EXTRA_E2E_ARGS += --istioctl=${ISTIOCTL_BIN}
DEFAULT_EXTRA_E2E_ARGS += --mixer_tag=${TAG}
DEFAULT_EXTRA_E2E_ARGS += --pilot_tag=${TAG}
DEFAULT_EXTRA_E2E_ARGS += --proxy_tag=${TAG}
DEFAULT_EXTRA_E2E_ARGS += --ca_tag=${TAG}
DEFAULT_EXTRA_E2E_ARGS += --galley_tag=${TAG}
DEFAULT_EXTRA_E2E_ARGS += --mixer_tag=${TAG_VARIANT}
DEFAULT_EXTRA_E2E_ARGS += --pilot_tag=${TAG_VARIANT}
DEFAULT_EXTRA_E2E_ARGS += --proxy_tag=${TAG_VARIANT}
DEFAULT_EXTRA_E2E_ARGS += --ca_tag=${TAG_VARIANT}
DEFAULT_EXTRA_E2E_ARGS += --galley_tag=${TAG_VARIANT}
DEFAULT_EXTRA_E2E_ARGS += --sidecar_injector_tag=${TAG_VARIANT}
DEFAULT_EXTRA_E2E_ARGS += --app_tag=${TAG}
DEFAULT_EXTRA_E2E_ARGS += --mixer_hub=${HUB}
DEFAULT_EXTRA_E2E_ARGS += --pilot_hub=${HUB}
DEFAULT_EXTRA_E2E_ARGS += --proxy_hub=${HUB}
DEFAULT_EXTRA_E2E_ARGS += --ca_hub=${HUB}
DEFAULT_EXTRA_E2E_ARGS += --galley_hub=${HUB}
DEFAULT_EXTRA_E2E_ARGS += --sidecar_injector_hub=${HUB}
DEFAULT_EXTRA_E2E_ARGS += --app_hub=${HUB}

EXTRA_E2E_ARGS ?= ${DEFAULT_EXTRA_E2E_ARGS}

Expand Down Expand Up @@ -252,15 +257,15 @@ helm/install:
install/kubernetes/helm/istio-init \
--name istio-system-init --namespace istio-system \
--set global.hub=${HUB} \
--set global.tag=${TAG} \
--set global.tag=${TAG_VARIANT} \
--set global.imagePullPolicy=Always \
${HELM_ARGS}
sleep 10
${HELM} install \
install/kubernetes/helm/istio \
--name istio-system --namespace istio-system \
--set global.hub=${HUB} \
--set global.tag=${TAG} \
--set global.tag=${TAG_VARIANT} \
--set global.imagePullPolicy=Always \
${HELM_ARGS}

Expand All @@ -269,7 +274,7 @@ helm/install:
helm/upgrade:
${HELM} upgrade \
--set global.hub=${HUB} \
--set global.tag=${TAG} \
--set global.tag=${TAG_VARIANT} \
--set global.imagePullPolicy=Always \
${HELM_ARGS} \
istio-system install/kubernetes/helm/istio
Expand Down
23 changes: 18 additions & 5 deletions tests/util/kube_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -359,12 +359,25 @@ func getServiceLoadBalancer(name, namespace, kubeconfig string) (string, error)
return "", err
}

ip = strings.Trim(ip, "'")
addr := net.ParseIP(ip)
if addr == nil {
return "", errors.New("ingress ip not available yet")
}
if ip == "" {
// This block is used for docker-desktop kubernetes
ip, err = ShellSilent(
"kubectl get svc %s -n %s -o jsonpath='{.status.loadBalancer.ingress[*].hostname}' --kubeconfig=%s",
name, namespace, kubeconfig)

if err != nil {
return "", err
}
if ip == "localhost" {
ip = "127.0.0.1"
}
} else {
ip = strings.Trim(ip, "'")
addr := net.ParseIP(ip)
if addr == nil {
return "", errors.New("ingress ip not available yet")
}
}
return ip, nil
}

Expand Down

0 comments on commit 2b86b66

Please sign in to comment.