Skip to content

Commit

Permalink
Update release-tests harness to match latest k8s and etcd
Browse files Browse the repository at this point in the history
  • Loading branch information
rajatchopra committed Mar 12, 2020
1 parent 8672a33 commit bd3f2c0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
18 changes: 11 additions & 7 deletions Makefile
Expand Up @@ -47,7 +47,7 @@ dist/flanneld.exe: $(shell find . -type f -name '*.go')
# This will build flannel natively using golang image
dist/flanneld-$(ARCH): dist/qemu-$(ARCH)-static
# valid values for ARCH are [amd64 arm arm64 ppc64le s390x]
docker run -e CGO_ENABLED=$(CGO_ENABLED) -e GOARCH=$(ARCH) \
docker run -e CGO_ENABLED=$(CGO_ENABLED) -e GOARCH=$(ARCH) -e GOCACHE=/go \
-u $(shell id -u):$(shell id -g) \
-v $(CURDIR)/dist/qemu-$(ARCH)-static:/usr/bin/qemu-$(ARCH)-static \
-v $(CURDIR):/go/src/github.com/coreos/flannel:ro \
Expand Down Expand Up @@ -129,7 +129,7 @@ ifneq ($(ARCH),amd64)
$(MAKE) dist/qemu-$(ARCH)-static
endif
# valid values for ARCH are [amd64 arm arm64 ppc64le s390x]
docker run -e GOARM=$(GOARM) \
docker run -e GOARM=$(GOARM) -e GOCACHE=/go \
-u $(shell id -u):$(shell id -g) \
-v $(CURDIR):/go/src/github.com/coreos/flannel:ro \
-v $(CURDIR)/dist:/go/src/github.com/coreos/flannel/dist \
Expand Down Expand Up @@ -181,19 +181,23 @@ tar.gz:
tar --transform='flags=r;s|-s390x||' -zcvf dist/flannel-$(TAG)-linux-s390x.tar.gz -C dist flanneld-s390x mk-docker-opts.sh ../README.md
tar -tvf dist/flannel-$(TAG)-linux-s390x.tar.gz

release-tests: bash_unit
release-tests: release-etcd-tests release-k8s-tests

release-etcd-tests: bash_unit
# Run the functional tests with different etcd versions.
ETCD_IMG="quay.io/coreos/etcd:latest" ./bash_unit dist/functional-test.sh
ETCD_IMG="quay.io/coreos/etcd:v3.2.7" ./bash_unit dist/functional-test.sh
ETCD_IMG="quay.io/coreos/etcd:v3.1.10" ./bash_unit dist/functional-test.sh
ETCD_IMG="quay.io/coreos/etcd:v3.0.17" ./bash_unit dist/functional-test.sh
# Etcd v2 docker image format is different. Override the etcd binary location so it works.
ETCD_IMG="quay.io/coreos/etcd:v2.3.8" ETCD_LOCATION=" " ./bash_unit dist/functional-test.sh

release-k8s-tests: bash_unit
# Run the functional tests with different k8s versions. Currently these are the latest point releases.
# This list should be updated during the release process.
K8S_VERSION="1.7.6" ./bash_unit dist/functional-test-k8s.sh
K8S_VERSION="1.6.10" ./bash_unit dist/functional-test-k8s.sh
K8S_VERSION="1.17.3" HYPERKUBE_CMD=" " HYPERKUBE_APISERVER_CMD="kube-apiserver" ./bash_unit dist/functional-test-k8s.sh
K8S_VERSION="1.16.7" HYPERKUBE_CMD=" " HYPERKUBE_APISERVER_CMD="kube-apiserver" ./bash_unit dist/functional-test-k8s.sh
K8S_VERSION="1.15.10" HYPERKUBE_CMD=" " HYPERKUBE_APISERVER_CMD="kube-apiserver" ./bash_unit dist/functional-test-k8s.sh
# K8S_VERSION="1.7.6" ./bash_unit dist/functional-test-k8s.sh
# K8S_VERSION="1.6.10" ./bash_unit dist/functional-test-k8s.sh
# K8S_VERSION="1.5.7" ./bash_unit dist/functional-test-k8s.sh #kube-flannel.yml is incompatible
# K8S_VERSION="1.4.12" ./bash_unit dist/functional-test-k8s.sh #kube-flannel.yml is incompatible
# K8S_VERSION="1.3.10" ./bash_unit dist/functional-test-k8s.sh #kube-flannel.yml is incompatible
Expand Down
10 changes: 6 additions & 4 deletions dist/functional-test-k8s.sh
Expand Up @@ -8,6 +8,8 @@ TAG=`git describe --tags --dirty`
FLANNEL_DOCKER_IMAGE="${FLANNEL_DOCKER_IMAGE:-quay.io/coreos/flannel:$TAG}"
K8S_VERSION="${K8S_VERSION:-1.13.2}"
HYPERKUBE_IMG="gcr.io/google_containers/hyperkube-${ARCH}"
HYPERKUBE_CMD="${HYPERKUBE_CMD:-/hyperkube}"
HYPERKUBE_APISERVER_CMD="${HYPERKUBE_APISERVER_CMD:-apiserver}"

docker_ip=$(ip -o -f inet addr show docker0 | grep -Po 'inet \K[\d.]+')
etcd_endpt="http://$docker_ip:2379"
Expand All @@ -31,11 +33,11 @@ setup_suite() {
# Start a kubernetes API server
docker rm -f flannel-e2e-k8s-apiserver >/dev/null 2>/dev/null
docker run -d --net=host --name flannel-e2e-k8s-apiserver ${HYPERKUBE_IMG}:v$K8S_VERSION \
/hyperkube apiserver --etcd-servers=$etcd_endpt \
${HYPERKUBE_CMD} ${HYPERKUBE_APISERVER_CMD} --etcd-servers=$etcd_endpt \
--service-cluster-ip-range=10.101.0.0/16 --insecure-bind-address=0.0.0.0 --allow-privileged >/dev/null
sleep 1

while ! cat <<EOF | docker run -i --rm --net=host ${HYPERKUBE_IMG}:v$K8S_VERSION /hyperkube kubectl create -f - >/dev/null 2>/dev/null
while ! cat <<EOF | docker run -i --rm --net=host ${HYPERKUBE_IMG}:v$K8S_VERSION ${HYPERKUBE_CMD} kubectl create -f - >/dev/null 2>/dev/null
apiVersion: v1
kind: Node
metadata:
Expand All @@ -49,7 +51,7 @@ do
sleep 1
done

cat <<EOF | docker run -i --rm --net=host ${HYPERKUBE_IMG}:v$K8S_VERSION /hyperkube kubectl create -f - >/dev/null 2>/dev/null
cat <<EOF | docker run -i --rm --net=host ${HYPERKUBE_IMG}:v$K8S_VERSION ${HYPERKUBE_CMD} kubectl create -f - >/dev/null 2>/dev/null
apiVersion: v1
kind: Node
metadata:
Expand Down Expand Up @@ -148,5 +150,5 @@ pings() {

test_manifest() {
# This just tests that the API server accepts the manifest, not that it actually acts on it correctly.
assert "cat ../Documentation/kube-flannel.yml | docker run -i --rm --net=host ${HYPERKUBE_IMG}:v$K8S_VERSION /hyperkube kubectl create -f -"
assert "cat ../Documentation/kube-flannel.yml | docker run -i --rm --net=host ${HYPERKUBE_IMG}:v$K8S_VERSION ${HYPERKUBE_CMD} kubectl create -f -"
}
2 changes: 1 addition & 1 deletion dist/functional-test.sh
Expand Up @@ -25,7 +25,7 @@ setup_suite() {

# Start etcd
docker rm -f flannel-e2e-test-etcd >/dev/null 2>/dev/null
docker run --name=flannel-e2e-test-etcd -d -p 2379:2379 $ETCD_IMG $ETCD_LOCATION --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls $etcd_endpt >/dev/null
docker run --name=flannel-e2e-test-etcd -d --dns 8.8.8.8 -p 2379:2379 $ETCD_IMG $ETCD_LOCATION --listen-client-urls http://0.0.0.0:2379 --advertise-client-urls $etcd_endpt >/dev/null
}

teardown_suite() {
Expand Down
4 changes: 2 additions & 2 deletions subnet/etcdv2/mock_etcd.go
Expand Up @@ -239,7 +239,7 @@ func (me *mockEtcd) set(ctx context.Context, key, value string, opts *etcd.SetOp

if node != nil {
if opts.PrevIndex > 0 && opts.PrevIndex < node.ModifiedIndex {
return nil, me.newError(etcd.ErrorCodeTestFailed, "Key %s PrevIndex %s less than node ModifiedIndex %d", key, opts.PrevIndex, node.ModifiedIndex)
return nil, me.newError(etcd.ErrorCodeTestFailed, "Key %s PrevIndex %v less than node ModifiedIndex %d", key, opts.PrevIndex, node.ModifiedIndex)
}

if opts.Dir != node.Dir {
Expand Down Expand Up @@ -342,7 +342,7 @@ func (me *mockEtcd) Delete(ctx context.Context, key string, opts *etcd.DeleteOpt
}

if opts.PrevIndex > 0 && opts.PrevIndex < node.ModifiedIndex {
return nil, me.newError(etcd.ErrorCodeTestFailed, "Key %s PrevIndex %s less than node ModifiedIndex %d", key, opts.PrevIndex, node.ModifiedIndex)
return nil, me.newError(etcd.ErrorCodeTestFailed, "Key %s PrevIndex %v less than node ModifiedIndex %d", key, opts.PrevIndex, node.ModifiedIndex)
}

if opts.PrevValue != "" && opts.PrevValue != node.Value {
Expand Down

0 comments on commit bd3f2c0

Please sign in to comment.