Skip to content

Commit

Permalink
test: statefulset without ippool
Browse files Browse the repository at this point in the history
  • Loading branch information
oilbeater committed Jul 3, 2020
1 parent de35da0 commit dbc968c
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ uninstall:
bash dist/images/cleanup.sh

e2e:
docker pull nginx:alpine
kind load docker-image --name kube-ovn nginx:alpine
ginkgo -p --slowSpecThreshold=60 test/e2e

ut:
Expand Down
56 changes: 56 additions & 0 deletions test/e2e/ip/static_ip.go
Original file line number Diff line number Diff line change
Expand Up @@ -179,5 +179,61 @@ var _ = Describe("[IP Allocation]", func() {
Expect(pod.Status.PodIP).To(Equal([]string{"12.10.0.31", "12.10.0.32", "12.10.0.30"}[i]))
}
})

It("statefulset without ippool", func() {
name := f.GetName()
var replicas int32 = 3
autoMount := false
ss := appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: name,
Namespace: namespace,
},
Spec: appsv1.StatefulSetSpec{
Replicas: &replicas,
Selector: &metav1.LabelSelector{MatchLabels: map[string]string{"apps": name}},
Template: corev1.PodTemplateSpec{
ObjectMeta: metav1.ObjectMeta{
Labels: map[string]string{"apps": name},
},
Spec: corev1.PodSpec{
Containers: []corev1.Container{
{
Name: name,
Image: "nginx:alpine",
ImagePullPolicy: corev1.PullIfNotPresent,
},
},
AutomountServiceAccountToken: &autoMount,
},
},
},
}

By("Create statefulset")
_, err := f.KubeClientSet.AppsV1().StatefulSets(namespace).Create(&ss)
Expect(err).NotTo(HaveOccurred())

err = f.WaitStatefulsetReady(name, namespace)
Expect(err).NotTo(HaveOccurred())

ips := make([]string, 0, 3)
for i := 0; i < 3; i++ {
pod, err := f.KubeClientSet.CoreV1().Pods(namespace).Get(fmt.Sprintf("%s-%d", name, i), metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
ips = append(ips, pod.Status.PodIP)
}

err = f.KubeClientSet.CoreV1().Pods(namespace).DeleteCollection(&metav1.DeleteOptions{}, metav1.ListOptions{LabelSelector: labels.SelectorFromSet(ss.Spec.Template.Labels).String()})
Expect(err).NotTo(HaveOccurred())

err = f.WaitStatefulsetReady(name, namespace)
Expect(err).NotTo(HaveOccurred())
for i := 0; i < 3; i++ {
pod, err := f.KubeClientSet.CoreV1().Pods(namespace).Get(fmt.Sprintf("%s-%d", name, i), metav1.GetOptions{})
Expect(err).NotTo(HaveOccurred())
Expect(pod.Status.PodIP).To(Equal(ips[i]))
}
})
})
})

0 comments on commit dbc968c

Please sign in to comment.