mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 14:37:00 +00:00
Merge pull request #38954 from slaskawi/statefulsets/add_service_level_tests
Automatic merge from submit-queue (batch tested with PRs 39169, 40719, 38954, 40808, 40689) Add StatefulSets checks at Service level Hi! Please let me propose some very small e2e testsuite enhancement. This PR removed a `TODO` about checking governing service at unit test level (which is hard) and adds this to e2e testsuite. Thanks Sebastian
This commit is contained in:
commit
6685d3c022
@ -57,7 +57,6 @@ func TestPetIDDNS(t *testing.T) {
|
|||||||
if hostname, ok := pod.Annotations[apipod.PodHostnameAnnotation]; !ok || hostname != petName {
|
if hostname, ok := pod.Annotations[apipod.PodHostnameAnnotation]; !ok || hostname != petName {
|
||||||
t.Errorf("Wrong hostname: %v", hostname)
|
t.Errorf("Wrong hostname: %v", hostname)
|
||||||
}
|
}
|
||||||
// TODO: Check this against the governing service.
|
|
||||||
if subdomain, ok := pod.Annotations[apipod.PodSubdomainAnnotation]; !ok || subdomain != petSubdomain {
|
if subdomain, ok := pod.Annotations[apipod.PodSubdomainAnnotation]; !ok || subdomain != petSubdomain {
|
||||||
t.Errorf("Wrong subdomain: %v", subdomain)
|
t.Errorf("Wrong subdomain: %v", subdomain)
|
||||||
}
|
}
|
||||||
|
@ -125,6 +125,9 @@ var _ = framework.KubeDescribe("StatefulSet", func() {
|
|||||||
By("Verifying statefulset provides a stable hostname for each pod")
|
By("Verifying statefulset provides a stable hostname for each pod")
|
||||||
framework.ExpectNoError(sst.checkHostname(ss))
|
framework.ExpectNoError(sst.checkHostname(ss))
|
||||||
|
|
||||||
|
By("Verifying statefulset set proper service name")
|
||||||
|
framework.ExpectNoError(sst.checkServiceName(ss, headlessSvcName))
|
||||||
|
|
||||||
cmd := "echo $(hostname) > /data/hostname; sync;"
|
cmd := "echo $(hostname) > /data/hostname; sync;"
|
||||||
By("Running " + cmd + " in all stateful pods")
|
By("Running " + cmd + " in all stateful pods")
|
||||||
framework.ExpectNoError(sst.execInStatefulPods(ss, cmd))
|
framework.ExpectNoError(sst.execInStatefulPods(ss, cmd))
|
||||||
@ -963,6 +966,16 @@ func (s *statefulSetTester) waitForStatus(ss *apps.StatefulSet, expectedReplicas
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (p *statefulSetTester) checkServiceName(ps *apps.StatefulSet, expectedServiceName string) error {
|
||||||
|
framework.Logf("Checking if statefulset spec.serviceName is %s", expectedServiceName)
|
||||||
|
|
||||||
|
if expectedServiceName != ps.Spec.ServiceName {
|
||||||
|
return fmt.Errorf("Wrong service name governing statefulset. Expected %s got %s", expectedServiceName, ps.Spec.ServiceName)
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func deleteAllStatefulSets(c clientset.Interface, ns string) {
|
func deleteAllStatefulSets(c clientset.Interface, ns string) {
|
||||||
sst := &statefulSetTester{c: c}
|
sst := &statefulSetTester{c: c}
|
||||||
ssList, err := c.Apps().StatefulSets(ns).List(metav1.ListOptions{LabelSelector: labels.Everything().String()})
|
ssList, err := c.Apps().StatefulSets(ns).List(metav1.ListOptions{LabelSelector: labels.Everything().String()})
|
||||||
|
Loading…
Reference in New Issue
Block a user