Skip to content
This repository has been archived by the owner on Apr 7, 2020. It is now read-only.

Commit

Permalink
Build and test improvements (istio#4092)
Browse files Browse the repository at this point in the history
* Build and test improvements

* Missed base docker file

* Add the base debug image to circle

* Move back adduser

* Better way to do junit report

* Bad user add

* Bad formatting

* Remove the delve comment - delve should be in go images, not envoy

* Extra quote...

* Run both v1 and v3 pilot tests in the auth suite

* Add test reports to simple

* Bad merge

* Wrong path

* Fix logs dir

* Create the test log directory before the test
  • Loading branch information
costinm committed Mar 10, 2018
1 parent 780a575 commit 25fd341
Show file tree
Hide file tree
Showing 14 changed files with 326 additions and 157 deletions.
85 changes: 56 additions & 29 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,16 +52,28 @@ jobs:
# Should only happen when re-running a job, and the workspace is gone
time make build test-bins
fi
make docker.tag generate_yaml
make docker.all generate_yaml
- run: bin/testEnvRootMinikube.sh wait
- run: docker images
- run: PATH=$GOPATH/bin:$PATH make e2e_simple_run E2E_ARGS="--skip_cleanup -use_local_cluster -cluster_wide -test.v"
- run: make test/minikube/noauth/e2e_simple
- run:
name: dumpsys
when: always
command: |
mkdir -p /go/out/logs
# TODO: move to a make target 'dumpsys'.
kubectl get all -o wide --all-namespaces
kubectl cluster-info dump > /go/out/logs/cluster-info.dump.txt
kubectl describe pods -n istio-system > /go/out/logs/pods-system.txt
/go/bin/go-junit-report </go/out/tests/test-report-noauth-simple.raw > /go/out/tests/test-report-noauth-simple.xml
- store_artifacts:
path: /home/circleci/logs
- store_artifacts:
path: /tmp
- store_artifacts:
path: /var/lib/localkube/
- store_test_results:
path: /go/out/tests

e2e-dashboard:
<<: *integrationDefaults
Expand Down Expand Up @@ -90,7 +102,7 @@ jobs:
# Should only happen when re-running a job, and the workspace is gone
time make build test-bins
fi
make docker.tag generate_yaml
make docker.all generate_yaml
- run: bin/testEnvRootMinikube.sh wait
- run: docker images
- run: PATH=$GOPATH/bin:$PATH make e2e_dashboard E2E_ARGS="--skip_cleanup -use_local_cluster -test.v"
Expand Down Expand Up @@ -128,7 +140,7 @@ jobs:
# Should only happen when re-running a job, and the workspace is gone
time make build test-bins
fi
make docker.tag generate_yaml
make docker.all generate_yaml
- run: bin/testEnvRootMinikube.sh wait
- run: docker images
- run:
Expand Down Expand Up @@ -167,7 +179,7 @@ jobs:
# Should only happen when re-running a job, and the workspace is gone
time make build test-bins
fi
make docker.tag generate_yaml
make docker.all generate_yaml
- run: bin/testEnvRootMinikube.sh wait
- run: docker images
- run:
Expand Down Expand Up @@ -208,25 +220,20 @@ jobs:
# Should only happen when re-running a job, and the workspace is gone
time make build test-bins
fi
make docker.tag generate_yaml
make docker.all generate_yaml
- run: bin/testEnvRootMinikube.sh wait
- run: docker images
- run:
command: |
mkdir -p /go/out/tests
#trap "go-junit-report </go/out/tests/go-test-report.out > /go/out/tests/go-test-report.xml" EXIT
# Run the tests in env similar with recommended setup.
make test/minikube/auth/e2e_pilot HUB="${HUB}" TAG="${TAG}" \
| tee -a /go/out/tests/go-test-report.out
- run: make test/minikube/noauth/e2e_pilot HUB="${HUB}" TAG="${TAG}"
- run:
name: dumpsys
when: always
command: |
# TODO: move to a make target 'dumpsys'.
kubectl get all -o wide --all-namespaces
kubectl cluster-info dump > /go/out/logs/cluster-info.dump.txt
kubectl describe pods -n istio-system > /go/out/logs/pods-system.txt
kubectl describe pods -n istio-test > /go/out/logs/pods-test.txt
kubectl describe pods -n pilot-noauth-system > /go/out/logs/pods-system.txt
kubectl describe pods -n pilot-noauth > /go/out/logs/pods-test.txt
/go/bin/go-junit-report </go/out/tests/test-report-noauth-pilot.raw > /go/out/tests/test-report-noauth-pilot.xml
- store_artifacts:
path: /go/out/tests
- store_artifacts:
Expand All @@ -237,7 +244,7 @@ jobs:
path: /go/out/tests


e2e-pilot-noauth:
e2e-pilot-auth:
<<: *integrationDefaults
environment:
- GOPATH: /go
Expand All @@ -264,12 +271,30 @@ jobs:
# Should only happen when re-running a job, and the workspace is gone
time make build test-bins
fi
make docker.tag generate_yaml
make docker.all generate_yaml
- run: bin/testEnvRootMinikube.sh wait
- run: docker images
- run: make e2e_pilot HUB="${HUB}" TAG="${TAG}" TESTOPTS="--skip-cleanup -mixer=true -auth_enable=false -errorlogsdir=/home/circleci/logs -use-sidecar-injector=false --core-files-dir=/home/circleci/logs"
- run: make test/minikube/auth/e2e_pilot HUB="${HUB}" TAG="${TAG}"
- run: make test/minikube/auth/e2e_pilot_alpha1 HUB="${HUB}" TAG="${TAG}"
- run:
name: dumpsys
when: always
command: |
# TODO: move to a make target 'dumpsys'.
kubectl get all -o wide --all-namespaces
kubectl cluster-info dump > /go/out/logs/cluster-info.dump.txt
kubectl describe pods -n pilot-auth > /go/out/logs/pods-system.txt
kubectl describe pods -n pilot-auth-system > /go/out/logs/pods-test.txt
/go/bin/go-junit-report </go/out/tests/test-report-auth-pilot.raw > /go/out/tests/test-report-auth-pilot.xml
/go/bin/go-junit-report </go/out/tests/test-report-auth-pilot-v1.raw > /go/out/tests/test-report-auth-pilot-v1.xml
- store_artifacts:
path: /home/circleci/logs
path: /go/out/tests
- store_artifacts:
path: /go/out/logs
- store_artifacts:
path: /tmp
- store_test_results:
path: /go/out/tests

e2e-pilot-v1alpha1-and-v1alpha3:
<<: *integrationDefaults
Expand Down Expand Up @@ -300,7 +325,7 @@ jobs:
# Should only happen when re-running a job, and the workspace is gone
time make build test-bins
fi
make docker.tag generate_yaml
make docker.all generate_yaml
- run: bin/testEnvRootMinikube.sh wait
- run: docker images
- run: make e2e_pilot HUB="${HUB}" TAG="${TAG}" TESTOPTS="--skip-cleanup -mixer=true -auth_enable=true -v1alpha3=true -v1alpha1=true -errorlogsdir=/home/circleci/logs -use-sidecar-injector=false --core-files-dir=/home/circleci/logs"
Expand Down Expand Up @@ -445,7 +470,7 @@ jobs:
- run:
command: |
cd /go/src/istio.io/istio
make build test-bins
make build test-bins /go/bin/go-junit-report
- persist_to_workspace:
root: /go
paths:
Expand Down Expand Up @@ -481,7 +506,7 @@ jobs:
# paths:
# - /go/pkg

docker-push:
nightly:
<<: *defaults
resource_class: xlarge
environment:
Expand All @@ -491,12 +516,14 @@ jobs:
at: /go
- setup_remote_docker:
docker_layer_caching: true
- run: make istio-archive
- run:
command: |
if [ ! -z "${DOCKER_USER}" ] ; then
echo "Pushing docker images"
docker login -u ${DOCKER_USER} -p ${DOCKER_PASS}
make docker push
# The xenail debug image is built first, will be used in the next steps
make docker.push.basedebug docker.all push
fi
goxbuild:
Expand Down Expand Up @@ -551,7 +578,7 @@ workflows:
- e2e-pilot:
requires:
- test
- e2e-pilot-noauth:
- e2e-pilot-auth:
requires:
- test
- benchcheck:
Expand All @@ -561,13 +588,13 @@ workflows:
- goxbuild:
requires:
- test
# Push to dockerhub
- docker-push:
# Nightly release
- nightly:
context: org-global
requires:
- e2e-simple
- e2e-pilot
- e2e-pilot-noauth
- e2e-pilot-auth

periodic:
triggers:
Expand Down Expand Up @@ -598,7 +625,7 @@ workflows:
- e2e-pilot-v1alpha1-and-v1alpha3:
requires:
- build
- e2e-pilot-noauth:
- e2e-pilot-auth:
requires:
- build
- benchcheck:
Expand Down Expand Up @@ -644,7 +671,7 @@ workflows:
- e2e-pilot:
requires:
- build
- e2e-pilot-noauth:
- e2e-pilot-auth:
requires:
- build
- e2e-simple:
Expand Down
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ $(SECURITY_GO_BINS):
bin/gobuild.sh $@ istio.io/istio/pkg/version ./security/cmd/$(@F)

.PHONY: build
# Build will rebuild the go binaries.
build: depend $(PILOT_GO_BINS_SHORT) mixc mixs node_agent istio_ca flexvolume multicluster_ca istioctl

# The following are convenience aliases for most of the go targets
Expand Down
24 changes: 24 additions & 0 deletions docker/Dockerfile.xenial_debug
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM ubuntu:xenial
# Base image for debug builds.
# Built manually uploaded as "istionightly/base_debug"

# Do not add more stuff to this list that isn't small or critically useful.
# If you occasionally need something on the container do
# sudo apt-get update && apt-get whichever
RUN apt-get update && \
apt-get install --no-install-recommends -y \
curl \
iptables \
iproute2 \
iputils-ping \
dnsutils \
netcat \
tcpdump \
net-tools \
libc6-dbg gdb \
elvis-tiny \
lsof \
busybox \
sudo && apt-get upgrade -y && \
rm -rf /var/lib/apt/lists/*

24 changes: 2 additions & 22 deletions pilot/docker/Dockerfile.proxy_debug
Original file line number Diff line number Diff line change
@@ -1,34 +1,14 @@
FROM ubuntu:xenial
# Do not add more stuff to this list that isn't small or critically useful.
# If you occasionally need something on the container do
# sudo apt-get update && apt-get whichever
RUN apt-get update && \
apt-get install --no-install-recommends -y \
curl \
iptables \
iproute2 \
iputils-ping \
dnsutils \
netcat \
tcpdump \
net-tools \
libc6-dbg gdb \
elvis-tiny \
lsof \
busybox \
sudo && \
rm -rf /var/lib/apt/lists/*
FROM istionightly/base_debug

# Install Envoy.
ADD envoy-debug /usr/local/bin/envoy
ADD envoy /usr/local/bin/envoy

ADD pilot-agent /usr/local/bin/pilot-agent

COPY envoy_pilot.json /etc/istio/proxy/envoy_pilot.json
COPY envoy_pilot_auth.json /etc/istio/proxy/envoy_pilot_auth.json
COPY envoy_mixer.json /etc/istio/proxy/envoy_mixer.json
COPY envoy_mixer_auth.json /etc/istio/proxy/envoy_mixer_auth.json
# Use the same file as the deb file.
COPY envoy_bootstrap_tmpl.json /var/lib/istio/envoy/envoy_bootstrap_tmpl.json

# Sudoers used to allow tcpdump and other debug utilities.
Expand Down
77 changes: 1 addition & 76 deletions tests/e2e/framework/testInfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,12 @@ import (
"time"

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

"istio.io/istio/pkg/log"
"istio.io/istio/tests/util"
)

var (
resources = []string{
"pod",
"service",
"ingress",
}
testLogsPath = flag.String("test_logs_path", "", "Local path to store logs in")
)

Expand Down Expand Up @@ -105,76 +99,7 @@ func (t testInfo) Update(r int) error {
}

func (t testInfo) FetchAndSaveClusterLogs(namespace string) error {
var multiErr error
fetchAndWrite := func(pod string) error {
cmd := fmt.Sprintf(
"kubectl get pods -n %s %s -o jsonpath={.spec.containers[*].name}", namespace, pod)
containersString, err := util.Shell(cmd)
if err != nil {
return err
}
containers := strings.Split(containersString, " ")
for _, container := range containers {
filePath := filepath.Join(t.TempDir, fmt.Sprintf("%s_container:%s.log", pod, container))
f, err := os.Create(filePath)
if err != nil {
return err
}
defer func() {
if err = f.Close(); err != nil {
log.Warnf("Error during closing file: %v\n", err)
}
}()
dump, err := util.ShellMuteOutput(
fmt.Sprintf("kubectl logs %s -n %s -c %s", pod, namespace, container))
if err != nil {
return err
}
if _, err = f.WriteString(fmt.Sprintf("%s\n", dump)); err != nil {
return err
}
}
return nil
}

_, err := util.Shell("kubectl get ingress --all-namespaces")
if err != nil {
return err
}
lines, err := util.Shell("kubectl get pods -n " + namespace)
if err != nil {
return err
}
pods := strings.Split(lines, "\n")
if len(pods) > 1 {
for _, line := range pods[1:] {
if idxEndOfPodName := strings.Index(line, " "); idxEndOfPodName > 0 {
pod := line[:idxEndOfPodName]
log.Infof("Fetching logs on %s", pod)
if err := fetchAndWrite(pod); err != nil {
multiErr = multierror.Append(multiErr, err)
}
}
}
}

for _, resrc := range resources {
log.Info(fmt.Sprintf("Fetching deployment info on %s\n", resrc))
filePath := filepath.Join(t.TempDir, fmt.Sprintf("%s.yaml", resrc))
if yaml, err0 := util.ShellMuteOutput(
fmt.Sprintf("kubectl get %s -n %s -o yaml", resrc, namespace)); err0 != nil {
multiErr = multierror.Append(multiErr, err0)
} else {
if f, err1 := os.Create(filePath); err1 != nil {
multiErr = multierror.Append(multiErr, err1)
} else {
if _, err2 := f.WriteString(fmt.Sprintf("%s\n", yaml)); err2 != nil {
multiErr = multierror.Append(multiErr, err2)
}
}
}
}
return multiErr
return util.FetchAndSaveClusterLogs(namespace, t.TempDir)
}

func (t testInfo) createStatusFile(r int) error {
Expand Down
4 changes: 4 additions & 0 deletions tests/e2e/tests/pilot/egress_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ func (t *egressRules) Setup() error {

// TODO: test negatives
func (t *egressRules) Run() error {
// egress rules are v1alpha1
if !t.Config.V1alpha1 {
return nil
}
cases := []struct {
description string
config string
Expand Down
Loading

0 comments on commit 25fd341

Please sign in to comment.