diff --git a/build/Makefile b/build/Makefile index 0728b6a471..2d77b30044 100644 --- a/build/Makefile +++ b/build/Makefile @@ -66,7 +66,7 @@ controller_tag = $(REGISTRY)/agones-controller:$(VERSION) sidecar_tag = $(REGISTRY)/agones-sdk:$(VERSION) go_version_flags = -ldflags "-X agones.dev/agones/pkg.Version=$(VERSION)" -DOCKER_RUN ?= docker run --rm $(common_mounts) $(build_tag) +DOCKER_RUN ?= docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) # ___ ____ ___ _ _ # / _ \/ ___| |_ _|_ __ ___| |_ _ __| | ___ # | | | \___ \ | || '_ \ / __| | | | |/ _` |/ _ \ @@ -117,6 +117,7 @@ test-go: $(agones_package)/sdks/... # Runs end-to-end tests on the current configured cluster +# For minikube user the minikube-test-e2e targets test-e2e: $(DOCKER_RUN) go test -v $(agones_package)/test/e2e/... \ --kubeconfig /root/.kube/config \ @@ -313,6 +314,8 @@ clean-gcloud-test-cluster: $(ensure-build-image) docker run --rm -it $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) gcloud \ deployment-manager deployments delete $(GCP_CLUSTER_NAME) +# Creates a gcloud cluster for end-to-end +# it installs also a consul cluster to handle build system concurrency using a distributed lock gcloud-e2e-test-cluster: $(ensure-build-image) docker run --rm -it $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) gcloud \ deployment-manager deployments create e2e-test-cluster \ @@ -323,6 +326,7 @@ gcloud-e2e-test-cluster: $(ensure-build-image) docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) helm init --service-account helm --wait && \ helm install --wait --set Replicas=1,uiService.type=ClusterIP --name consul stable/consul +# Deletes the gcloud e2e cluster and cleanup any left pvc volumes clean-gcloud-e2e-test-cluster: $(ensure-build-image) docker run --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) \ helm delete --purge consul && kubectl delete pvc -l component=consul-consul @@ -402,3 +406,7 @@ minikube-install: minikube-agones-profile # Use TAG to specify the image to transfer into minikube minikube-transfer-image: docker save $(TAG) | ($(MINIKUBE_DOCKER_ENV) && docker load) + +# Runs e2e tests against our minikube +minikube-test-e2e: DOCKER_RUN_ARGS=--network=host -v $(minikube_cert_mount) +minikube-test-e2e: minikube-agones-profile test-e2e diff --git a/build/build-image/Dockerfile b/build/build-image/Dockerfile index 7ea8430a15..823d39ac7b 100644 --- a/build/build-image/Dockerfile +++ b/build/build-image/Dockerfile @@ -40,6 +40,7 @@ ENV PATH /usr/local/go/bin:/go/bin:/opt/google-cloud-sdk/bin:$PATH # RUN gcloud components update RUN gcloud components update + # install kubectl without gcloud as we want the last version ENV KUBECTL_VER 1.11.0 RUN curl -LO https://storage.googleapis.com/kubernetes-release/release/v${KUBECTL_VER}/bin/linux/amd64/kubectl && \ @@ -92,19 +93,6 @@ RUN wget -q https://static.rust-lang.org/rustup/archive/1.11.0/${RUST_ARCH}/rust RUN cargo install protobuf-codegen --vers 2.0.2 RUN cargo install grpcio-compiler --vers 0.3.0 -# set up Consul. -ENV CONSUL_VERSION=1.2.1 -ENV HASHICORP_RELEASES=https://releases.hashicorp.com -RUN mkdir -p /tmp/build && \ - wget ${HASHICORP_RELEASES}/consul/${CONSUL_VERSION}/consul_${CONSUL_VERSION}_linux_amd64.zip \ - -P /tmp/build/ && \ - unzip -d /usr/local/bin/ /tmp/build/consul_${CONSUL_VERSION}_linux_amd64.zip && \ - cd /tmp && \ - rm -rf /tmp/build && \ - chmod go+rx /usr/local/bin/consul && \ - # tiny smoke test to ensure the binary we downloaded runs - consul version - # make sure we keep the path to go RUN echo "export PATH=/usr/local/go/bin:/go/bin/:\$PATH" >> /root/.bashrc # make nano the editor diff --git a/build/e2e-image/e2e.sh b/build/e2e-image/e2e.sh index 2b2ceb8858..06dff13d78 100755 --- a/build/e2e-image/e2e.sh +++ b/build/e2e-image/e2e.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright 2017 Google Inc. All Rights Reserved. +# Copyright 2018 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/e2e-image/entrypoint.sh b/build/e2e-image/entrypoint.sh index 397389603f..4b871fec36 100644 --- a/build/e2e-image/entrypoint.sh +++ b/build/e2e-image/entrypoint.sh @@ -1,6 +1,6 @@ #!/usr/bin/env bash -# Copyright 2017 Google Inc. All Rights Reserved. +# Copyright 2018 Google Inc. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. diff --git a/build/gke-test-cluster/cluster-e2e.yml b/build/gke-test-cluster/cluster-e2e.yml index 6fd32af566..f7406c3d1b 100644 --- a/build/gke-test-cluster/cluster-e2e.yml +++ b/build/gke-test-cluster/cluster-e2e.yml @@ -1,4 +1,4 @@ -# Copyright 2017 Google Inc. All rights reserved. +# Copyright 2018 Google Inc. All rights reserved. # 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 diff --git a/test/e2e/README.md b/test/e2e/README.md index b0515cec12..66570e7f1c 100644 --- a/test/e2e/README.md +++ b/test/e2e/README.md @@ -9,8 +9,8 @@ Prerequisites: - Have kubeconfig file ready. e2e tests are written as Go test. All go test techniques apply, e.g. picking -what to run, timeout length. Let's say I want to run all tests in "test/e2e/": +what to run, timeout length. ``` -$ go test -v ./test/e2e/ --kubeconfig "$HOME/.kube/config" --gameserver-image=gcr.io/agones-images/cpp-simple-server:0.2 +make e2e ``` \ No newline at end of file diff --git a/test/e2e/framework/framework.go b/test/e2e/framework/framework.go index fdedd7b6b5..1f78929e33 100644 --- a/test/e2e/framework/framework.go +++ b/test/e2e/framework/framework.go @@ -86,7 +86,7 @@ func (f *Framework) WaitForGameServerState(gs *v1alpha1.GameServer, state v1alph var pollErr error var readyGs *v1alpha1.GameServer - err := wait.Poll(2*time.Second, timeout, func() (bool, error) { + err := wait.PollImmediate(2*time.Second, timeout, func() (bool, error) { readyGs, pollErr = f.AgonesClient.StableV1alpha1().GameServers(gs.Namespace).Get(gs.Name, v1.GetOptions{}) if pollErr != nil { diff --git a/test/e2e/gameserver_test.go b/test/e2e/gameserver_test.go index ad150ed024..4c99d5133a 100644 --- a/test/e2e/gameserver_test.go +++ b/test/e2e/gameserver_test.go @@ -19,7 +19,7 @@ import ( "testing" "agones.dev/agones/pkg/apis/stable/v1alpha1" - agonesFramework "agones.dev/agones/test/e2e/framework" + e2eframework "agones.dev/agones/test/e2e/framework" "github.com/stretchr/testify/assert" corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -58,7 +58,7 @@ func TestCreateConnect(t *testing.T) { assert.NotEmpty(t, readyGs.Status.NodeName) assert.Equal(t, readyGs.Status.State, v1alpha1.Ready) - reply, err := agonesFramework.PingGameServer("Hello World !", fmt.Sprintf("%s:%d", readyGs.Status.Address, + reply, err := e2eframework.PingGameServer("Hello World !", fmt.Sprintf("%s:%d", readyGs.Status.Address, readyGs.Status.Ports[0].Port)) if err != nil { diff --git a/test/e2e/main_test.go b/test/e2e/main_test.go index 4bbac73e0b..df04334bd1 100644 --- a/test/e2e/main_test.go +++ b/test/e2e/main_test.go @@ -22,10 +22,10 @@ import ( "path/filepath" "testing" - agonesFramework "agones.dev/agones/test/e2e/framework" + e2eframework "agones.dev/agones/test/e2e/framework" ) -var framework *agonesFramework.Framework +var framework *e2eframework.Framework func TestMain(m *testing.M) { usr, _ := user.Current() @@ -41,7 +41,7 @@ func TestMain(m *testing.M) { exitCode int ) - if framework, err = agonesFramework.New(*kubeconfig, *gsimage); err != nil { + if framework, err = e2eframework.New(*kubeconfig, *gsimage); err != nil { log.Printf("failed to setup framework: %v\n", err) os.Exit(1) }