Skip to content

Commit

Permalink
Merge pull request #272 from neiljerram/fix-tests-for-1.10
Browse files Browse the repository at this point in the history
Bump to k8s 1.10.4 and fix FVs to work with that
  • Loading branch information
Neil Jerram authored Jun 26, 2018
2 parents b0fa8d5 + b7a61a4 commit bf51712
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 16 deletions.
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ OS?=$(shell uname -s | tr A-Z a-z)
###############################################################################
GO_BUILD_VER ?= v0.15

K8S_VERSION=v1.8.1
K8S_VERSION?=v1.10.4
HYPERKUBE_IMAGE?=gcr.io/google_containers/hyperkube-$(ARCH):$(K8S_VERSION)
ETCD_VERSION=v3.2.5
ETCD_IMAGE ?= quay.io/coreos/etcd:$(ETCD_VERSION)-$(BUILDARCH)
Expand Down Expand Up @@ -212,7 +212,7 @@ ut: vendor
GINKGO_FOCUS?=.*
fv: tests/fv/fv.test image
@echo Running Go FVs.
cd tests/fv && ETCD_IMAGE=$(ETCD_IMAGE) HYPERKUBE_IMAGE=$(HYPERKUBE_IMAGE) CONTAINER_NAME=$(CONTAINER_NAME):latest-$(ARCH) ./fv.test -ginkgo.slowSpecThreshold 30 -ginkgo.focus $(GINKGO_FOCUS)
cd tests/fv && ETCD_IMAGE=$(ETCD_IMAGE) HYPERKUBE_IMAGE=$(HYPERKUBE_IMAGE) CONTAINER_NAME=$(CONTAINER_NAME):latest-$(ARCH) PRIVATE_KEY=`pwd`/private.key ./fv.test -ginkgo.slowSpecThreshold 30 -ginkgo.focus $(GINKGO_FOCUS)

tests/fv/fv.test: $(shell find ./tests -type f -name '*.go' -print)
# We pre-build the test binary so that we can run it outside a container and allow it
Expand Down Expand Up @@ -345,4 +345,4 @@ help: # Some kind of magic from https://gist.github.com/rcmachado/af3db315e31383
} \
{ helpMsg = $$0 }' \
width=20 \
$(MAKEFILE_LIST)
$(MAKEFILE_LIST)
48 changes: 35 additions & 13 deletions tests/fv/fv_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,12 @@ import (

var _ = Describe("kube-controllers FV tests", func() {
var (
etcd *containers.Container
policyController *containers.Container
apiserver *containers.Container
calicoClient client.Interface
k8sClient *kubernetes.Clientset
etcd *containers.Container
policyController *containers.Container
apiserver *containers.Container
calicoClient client.Interface
k8sClient *kubernetes.Clientset
controllerManager *containers.Container
)

const kNodeName = "k8snodename"
Expand Down Expand Up @@ -79,12 +80,20 @@ var _ = Describe("kube-controllers FV tests", func() {
_, err := k8sClient.CoreV1().Namespaces().List(metav1.ListOptions{})
return err
}, 15*time.Second, 500*time.Millisecond).Should(BeNil())

// Run controller manager. Empirically it can take around 10s until the
// controller manager is ready to create default service accounts, even
// when the hyperkube image has already been downloaded to run the API
// server. We use Eventually to allow for possible delay when doing
// initial pod creation below.
controllerManager = testutils.RunK8sControllerManager(apiserver.IP)
})

AfterEach(func() {
etcd.Stop()
controllerManager.Stop()
policyController.Stop()
apiserver.Stop()
etcd.Stop()
})

It("should initialize the datastore at start-of-day", func() {
Expand Down Expand Up @@ -675,8 +684,10 @@ var _ = Describe("kube-controllers FV tests", func() {
}

By("creating a Pod in the k8s API", func() {
_, err := k8sClient.CoreV1().Pods("default").Create(&pod)
Expect(err).NotTo(HaveOccurred())
Eventually(func() error {
_, err := k8sClient.CoreV1().Pods("default").Create(&pod)
return err
}, "20s", "2s").ShouldNot(HaveOccurred())
})

By("updating the pod's status to be running", func() {
Expand Down Expand Up @@ -713,8 +724,11 @@ var _ = Describe("kube-controllers FV tests", func() {
By("updating the pod's labels to trigger a cache update", func() {
// Definitively trigger a pod controller cache update by updating the pod's labels
// in the Kubernetes API. This ensures the controller has the cached WEP with container-id-1.
podNow, err := k8sClient.CoreV1().Pods("default").Get(podName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
pod = *podNow
pod.Labels["foo"] = "label2"
_, err := k8sClient.CoreV1().Pods("default").Update(&pod)
_, err = k8sClient.CoreV1().Pods("default").Update(&pod)
Expect(err).NotTo(HaveOccurred())
})

Expand Down Expand Up @@ -756,8 +770,11 @@ var _ = Describe("kube-controllers FV tests", func() {

By("updating the pod's labels a second time to trigger a datastore sync", func() {
// Trigger a pod 'update' in the pod controller by updating the pod's labels.
podNow, err := k8sClient.CoreV1().Pods("default").Get(podName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
pod = *podNow
pod.Labels["foo"] = "label3"
_, err := k8sClient.CoreV1().Pods(podNamespace).Update(&pod)
_, err = k8sClient.CoreV1().Pods(podNamespace).Update(&pod)
Expect(err).NotTo(HaveOccurred())
})

Expand Down Expand Up @@ -806,13 +823,18 @@ var _ = Describe("kube-controllers FV tests", func() {
}

By("creating a Pod in the k8s API", func() {
_, err := k8sClient.CoreV1().Pods("default").Create(&pod)
Expect(err).NotTo(HaveOccurred())
Eventually(func() error {
_, err := k8sClient.CoreV1().Pods("default").Create(&pod)
return err
}, "20s", "2s").ShouldNot(HaveOccurred())
})

By("updating that pod's labels", func() {
podNow, err := k8sClient.CoreV1().Pods("default").Get(podName, metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
pod = *podNow
pod.Labels["foo"] = "label2"
_, err := k8sClient.CoreV1().Pods("default").Update(&pod)
_, err = k8sClient.CoreV1().Pods("default").Update(&pod)
Expect(err).NotTo(HaveOccurred())
})

Expand Down
51 changes: 51 additions & 0 deletions tests/fv/private.key
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
-----BEGIN RSA PRIVATE KEY-----
MIIJKgIBAAKCAgEAwBXj4nTY7UhlAnwMZUisHxOIEkeZjeRfX/efdlT+0/9K0MUy
++hm6N526CqRmm75ynlbkBx1qtVgKbID5gK+v3wyALS0J9oZRYdx1lWN6S5Ix4Rp
vU00NBVkbJLRGfUrJRFgpALgUeCy3LC9r+9ZAVucikFmbBSYS6tcej2OALXuV7DI
PYr7PvJ+JVNGVw/5wNW5FNoGKxhj10Lb4uAC/0YB5p70JM/x7vAbA9PaP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GrZ5CfhPfxWLcV/lyVfHvUb8QGbjnB+ZmgNU78ZMVjUTww4C
wwDeJSECggEAKMyAiLEec7Uvr+l8O3Nv9MdLyslTOaNFJeffRgz005n1ofyhbCWH
49RfWGYSkM+YnQx5fGBEObj+0V3y1hg5K+m2/Lcyphz9EeewnVEJyi0HDOCzsa7g
VKKx4RFbDRqgAYq1zHvCSvidyJAhpdAbN3bFkPJ6aSQsMfkoTzPpY0K3NrrZ5fbT
Z589KgWDPVcTEkoYtm4iWEf0jBZ/jtfzlpC/Xz9ckIpswDA6kKQ7f5qALbLjLII9
LswwGP4dxqrJvZEUG5LRxTQ2P0uYg3p9VbBC32LiUaVs+TyYRaqnPzSwG00v658N
NrSH+n/9U1nRuQ6FQBa7uqfXDjNJMlVPPQKCAQEAxsluGdXNIKHwkQK5Mx2LS63V
WO6X6nDAxWI2BM8AeAwcnSwpZStZzmHQaj6qm+RNE/TAILZSOs/BWijlhxM/jBh6
gbKEF8+cwWS/WaSztYaUIl8fA2GD7Z4o0gY0bK1wxJYM4AfB9F7e7mu0p5yiRO8X
e0nmCCAra4u8T+W1X1hYVntEj0KHGszR2S4CICsdFwheinTfbz2Voe9OoPrhkmbZ
lxrxEy0q9D0kSbX2KekeLWWq6I7Ae8gIp1T+MNTU2UKICXPQTM2+F6hivCg7UX/g
RWUnv8T+2Smsm5BfG9riUeSKzmnwkOI0oKBzB9nkt6prT5dW90endOHlJhJOuQ==
-----END RSA PRIVATE KEY-----
17 changes: 17 additions & 0 deletions tests/testutils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,33 @@ current-context: test-context`

func RunK8sApiserver(etcdIp string) *containers.Container {
return containers.Run("st-apiserver",
"-v", os.Getenv("PRIVATE_KEY")+":/private.key",
fmt.Sprintf("%s", os.Getenv("HYPERKUBE_IMAGE")),
"/hyperkube", "apiserver",
"--service-cluster-ip-range=10.101.0.0/16",
"--authorization-mode=AlwaysAllow",
"--insecure-port=8080",
"--insecure-bind-address=0.0.0.0",
fmt.Sprintf("--etcd-servers=http://%s:2379", etcdIp),
"--service-account-key-file=/private.key",
)
}

func RunK8sControllerManager(apiserverIp string) *containers.Container {
c := containers.Run("st-controller-manager",
"-v", os.Getenv("PRIVATE_KEY")+":/private.key",
fmt.Sprintf("%s", os.Getenv("HYPERKUBE_IMAGE")),
"/hyperkube", "controller-manager",
fmt.Sprintf("--master=%v:8080", apiserverIp),
"--min-resync-period=3m",
"--allocate-node-cidrs=true",
"--cluster-cidr=192.168.0.0/16",
"--v=5",
"--service-account-private-key-file=/private.key",
)
return c
}

func RunEtcd() *containers.Container {
return containers.Run("etcd-fv",
fmt.Sprintf("%s", os.Getenv("ETCD_IMAGE")),
Expand Down

0 comments on commit bf51712

Please sign in to comment.