mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 20:17:41 +00:00
test/integration: use t.Log in TestAPIServiceWaitOnStart
This commit is contained in:
parent
77cf37ee54
commit
7ac36bd072
@ -73,13 +73,13 @@ func TestAPIServiceWaitOnStart(t *testing.T) {
|
|||||||
}
|
}
|
||||||
t.Cleanup(func() { etcd3Client.Close() })
|
t.Cleanup(func() { etcd3Client.Close() })
|
||||||
|
|
||||||
// Pollute CRD path in etcd so CRD lists cannot succeed and the informer cannot sync
|
t.Log("Pollute CRD path in etcd so CRD lists cannot succeed and the informer cannot sync")
|
||||||
bogusCRDEtcdPath := path.Join("/", etcdConfig.Prefix, "apiextensions.k8s.io/customresourcedefinitions/bogus")
|
bogusCRDEtcdPath := path.Join("/", etcdConfig.Prefix, "apiextensions.k8s.io/customresourcedefinitions/bogus")
|
||||||
if _, err := etcd3Client.KV.Put(ctx, bogusCRDEtcdPath, `bogus data`); err != nil {
|
if _, err := etcd3Client.KV.Put(ctx, bogusCRDEtcdPath, `bogus data`); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate a valid CRD and managed APIService in etcd
|
t.Log("Populate a valid CRD and managed APIService in etcd")
|
||||||
if _, err := etcd3Client.KV.Put(
|
if _, err := etcd3Client.KV.Put(
|
||||||
ctx,
|
ctx,
|
||||||
path.Join("/", etcdConfig.Prefix, "apiextensions.k8s.io/customresourcedefinitions/widgets.valid.example.com"),
|
path.Join("/", etcdConfig.Prefix, "apiextensions.k8s.io/customresourcedefinitions/widgets.valid.example.com"),
|
||||||
@ -155,7 +155,7 @@ func TestAPIServiceWaitOnStart(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate a stale managed APIService in etcd
|
t.Log("Populate a stale managed APIService in etcd")
|
||||||
if _, err := etcd3Client.KV.Put(
|
if _, err := etcd3Client.KV.Put(
|
||||||
ctx,
|
ctx,
|
||||||
path.Join("/", etcdConfig.Prefix, "apiregistration.k8s.io/apiservices/v1.stale.example.com"),
|
path.Join("/", etcdConfig.Prefix, "apiregistration.k8s.io/apiservices/v1.stale.example.com"),
|
||||||
@ -179,7 +179,7 @@ func TestAPIServiceWaitOnStart(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start server
|
t.Log("Starting server")
|
||||||
options := kastesting.NewDefaultTestServerOptions()
|
options := kastesting.NewDefaultTestServerOptions()
|
||||||
options.SkipHealthzCheck = true
|
options.SkipHealthzCheck = true
|
||||||
testServer := kastesting.StartTestServerOrDie(t, options, nil, etcdConfig)
|
testServer := kastesting.StartTestServerOrDie(t, options, nil, etcdConfig)
|
||||||
@ -188,7 +188,7 @@ func TestAPIServiceWaitOnStart(t *testing.T) {
|
|||||||
kubeClientConfig := rest.CopyConfig(testServer.ClientConfig)
|
kubeClientConfig := rest.CopyConfig(testServer.ClientConfig)
|
||||||
aggregatorClient := aggregatorclient.NewForConfigOrDie(kubeClientConfig)
|
aggregatorClient := aggregatorclient.NewForConfigOrDie(kubeClientConfig)
|
||||||
|
|
||||||
// ensure both APIService objects remain
|
t.Log("Ensure both APIService objects remain")
|
||||||
for i := 0; i < 10; i++ {
|
for i := 0; i < 10; i++ {
|
||||||
if _, err := aggregatorClient.ApiregistrationV1().APIServices().Get(ctx, "v1.valid.example.com", metav1.GetOptions{}); err != nil {
|
if _, err := aggregatorClient.ApiregistrationV1().APIServices().Get(ctx, "v1.valid.example.com", metav1.GetOptions{}); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
@ -199,13 +199,12 @@ func TestAPIServiceWaitOnStart(t *testing.T) {
|
|||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear the bogus CRD data so the informer can sync
|
t.Log("Clear the bogus CRD data so the informer can sync")
|
||||||
if _, err := etcd3Client.KV.Delete(ctx, bogusCRDEtcdPath); err != nil {
|
if _, err := etcd3Client.KV.Delete(ctx, bogusCRDEtcdPath); err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
t.Log("cleaned up bogus CRD data")
|
|
||||||
|
|
||||||
// ensure the stale APIService object is cleaned up
|
t.Log("Ensure the stale APIService object is cleaned up")
|
||||||
if err := wait.Poll(time.Second, wait.ForeverTestTimeout, func() (bool, error) {
|
if err := wait.Poll(time.Second, wait.ForeverTestTimeout, func() (bool, error) {
|
||||||
_, err := aggregatorClient.ApiregistrationV1().APIServices().Get(ctx, "v1.stale.example.com", metav1.GetOptions{})
|
_, err := aggregatorClient.ApiregistrationV1().APIServices().Get(ctx, "v1.stale.example.com", metav1.GetOptions{})
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@ -220,7 +219,7 @@ func TestAPIServiceWaitOnStart(t *testing.T) {
|
|||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensure the valid APIService object remains
|
t.Log("Ensure the valid APIService object remains")
|
||||||
for i := 0; i < 5; i++ {
|
for i := 0; i < 5; i++ {
|
||||||
time.Sleep(time.Second)
|
time.Sleep(time.Second)
|
||||||
if _, err := aggregatorClient.ApiregistrationV1().APIServices().Get(ctx, "v1.valid.example.com", metav1.GetOptions{}); err != nil {
|
if _, err := aggregatorClient.ApiregistrationV1().APIServices().Get(ctx, "v1.valid.example.com", metav1.GetOptions{}); err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user