mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-08 20:50:24 +00:00
@@ -24,6 +24,7 @@ import (
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/format"
|
||||
|
||||
batchv1 "k8s.io/api/batch/v1"
|
||||
v1 "k8s.io/api/core/v1"
|
||||
@@ -308,7 +309,9 @@ var _ = SIGDescribe("CronJob", func() {
|
||||
cronJob.Spec.TimeZone = &badTimeZone
|
||||
_, err := createCronJob(ctx, f.ClientSet, f.Namespace.Name, cronJob)
|
||||
framework.ExpectError(err, "CronJob creation should fail with invalid time zone error")
|
||||
framework.ExpectEqual(apierrors.IsInvalid(err), true, "CronJob creation should fail with invalid time zone error")
|
||||
if !apierrors.IsInvalid(err) {
|
||||
framework.Failf("Failed to create CronJob, invalid time zone.")
|
||||
}
|
||||
})
|
||||
|
||||
/*
|
||||
@@ -387,8 +390,9 @@ var _ = SIGDescribe("CronJob", func() {
|
||||
for sawAnnotations := false; !sawAnnotations; {
|
||||
select {
|
||||
case evt, ok := <-cjWatch.ResultChan():
|
||||
|
||||
if !ok {
|
||||
framework.Fail("watch channel should not close")
|
||||
framework.Fail("Watch channel is closed.")
|
||||
}
|
||||
framework.ExpectEqual(evt.Type, watch.Modified)
|
||||
watchedCronJob, isCronJob := evt.Object.(*batchv1.CronJob)
|
||||
@@ -439,6 +443,7 @@ var _ = SIGDescribe("CronJob", func() {
|
||||
return err
|
||||
})
|
||||
framework.ExpectNoError(err)
|
||||
|
||||
if !updatedStatus.Status.LastScheduleTime.Equal(&now2) {
|
||||
framework.Failf("updated object status expected to have updated lastScheduleTime %#v, got %#v", statusToUpdate.Status.LastScheduleTime, updatedStatus.Status.LastScheduleTime)
|
||||
}
|
||||
@@ -454,9 +459,8 @@ var _ = SIGDescribe("CronJob", func() {
|
||||
// CronJob resource delete operations
|
||||
expectFinalizer := func(cj *batchv1.CronJob, msg string) {
|
||||
framework.ExpectNotEqual(cj.DeletionTimestamp, nil, fmt.Sprintf("expected deletionTimestamp, got nil on step: %q, cronjob: %+v", msg, cj))
|
||||
if len(cj.Finalizers) == 0 {
|
||||
framework.Failf("expected finalizers on cronjob, got none on step: %q, cronjob: %+v", msg, cj)
|
||||
}
|
||||
gomega.Expect(len(cj.Finalizers)).To(gomega.BeNumerically(">", 0), "expected finalizers on cronjob, got none on step: %q, cronjob: %+v", msg, cj)
|
||||
|
||||
}
|
||||
|
||||
ginkgo.By("deleting")
|
||||
@@ -469,10 +473,8 @@ var _ = SIGDescribe("CronJob", func() {
|
||||
// If controller does not support finalizers, we expect a 404. Otherwise we validate finalizer behavior.
|
||||
if err == nil {
|
||||
expectFinalizer(cj, "deleting cronjob")
|
||||
} else {
|
||||
if !apierrors.IsNotFound(err) {
|
||||
framework.Failf("expected 404, got %v", err)
|
||||
}
|
||||
} else if !apierrors.IsNotFound(err) {
|
||||
framework.Failf("expected 404, got %v", err)
|
||||
}
|
||||
|
||||
ginkgo.By("deleting a collection")
|
||||
@@ -481,10 +483,7 @@ var _ = SIGDescribe("CronJob", func() {
|
||||
cjs, err = cjClient.List(ctx, metav1.ListOptions{LabelSelector: "special-label=" + f.UniqueName})
|
||||
framework.ExpectNoError(err)
|
||||
// Should have <= 2 items since some cronjobs might not have been deleted yet due to finalizers
|
||||
if len(cjs.Items) > 2 {
|
||||
framework.Logf("got unexpected filtered list: %v", cjs.Items)
|
||||
framework.Fail("filtered list should be <= 2")
|
||||
}
|
||||
gomega.Expect(len(cjs.Items)).To(gomega.BeNumerically("<=", 2), "filtered list length should be <= 2, got:\n%s", format.Object(cjs.Items, 1))
|
||||
// Validate finalizers
|
||||
for _, cj := range cjs.Items {
|
||||
expectFinalizer(&cj, "deleting cronjob collection")
|
||||
|
@@ -299,7 +299,7 @@ var _ = SIGDescribe("Job", func() {
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
framework.Failf("Expected suspended job to exist. It was not found.")
|
||||
framework.Failf("Job was expected to be completed or failed")
|
||||
}
|
||||
|
||||
ginkgo.By("Updating the job with suspend=false")
|
||||
@@ -357,7 +357,7 @@ var _ = SIGDescribe("Job", func() {
|
||||
}
|
||||
}
|
||||
if !exists {
|
||||
framework.Failf("Expected suspended job to exist. It was not found.")
|
||||
framework.Failf("Job was expected to be completed or failed")
|
||||
}
|
||||
})
|
||||
|
||||
|
@@ -45,6 +45,8 @@ import (
|
||||
admissionapi "k8s.io/pod-security-admission/api"
|
||||
|
||||
"github.com/onsi/ginkgo/v2"
|
||||
"github.com/onsi/gomega"
|
||||
"github.com/onsi/gomega/format"
|
||||
)
|
||||
|
||||
var _ = SIGDescribe("ReplicationController", func() {
|
||||
@@ -247,6 +249,7 @@ var _ = SIGDescribe("ReplicationController", func() {
|
||||
return true, nil
|
||||
})
|
||||
framework.ExpectNoError(err, "Wait until condition with watch events should not return an error")
|
||||
|
||||
if !eventFound {
|
||||
framework.Failf("failed to find RC %v event", watch.Added)
|
||||
}
|
||||
@@ -271,7 +274,6 @@ var _ = SIGDescribe("ReplicationController", func() {
|
||||
if !eventFound {
|
||||
framework.Fail("Failed to find updated ready replica count")
|
||||
}
|
||||
|
||||
ginkgo.By("fetching ReplicationController status")
|
||||
rcStatusUnstructured, err := dc.Resource(rcResource).Namespace(testRcNamespace).Get(ctx, testRcName, metav1.GetOptions{}, "status")
|
||||
framework.ExpectNoError(err, "Failed to fetch ReplicationControllerStatus")
|
||||
@@ -306,7 +308,7 @@ var _ = SIGDescribe("ReplicationController", func() {
|
||||
})
|
||||
framework.ExpectNoError(err, "Wait until condition with watch events should not return an error")
|
||||
if !eventFound {
|
||||
framework.Failf("failed to find RC %v event", watch.Added)
|
||||
framework.Failf("Failed to find RC %v event", watch.Added)
|
||||
}
|
||||
|
||||
ginkgo.By("waiting for ReplicationController's scale to be the max amount")
|
||||
@@ -360,6 +362,7 @@ var _ = SIGDescribe("ReplicationController", func() {
|
||||
return true, nil
|
||||
})
|
||||
framework.ExpectNoError(err, "Wait until condition with watch events should not return an error")
|
||||
|
||||
if !eventFound {
|
||||
framework.Failf("failed to find RC %v event", watch.Added)
|
||||
}
|
||||
@@ -367,9 +370,7 @@ var _ = SIGDescribe("ReplicationController", func() {
|
||||
ginkgo.By("listing all ReplicationControllers")
|
||||
rcs, err := f.ClientSet.CoreV1().ReplicationControllers("").List(ctx, metav1.ListOptions{LabelSelector: "test-rc-static=true"})
|
||||
framework.ExpectNoError(err, "failed to list ReplicationController")
|
||||
if len(rcs.Items) == 0 {
|
||||
framework.Fail("Expected to find a ReplicationController but none was found")
|
||||
}
|
||||
gomega.Expect(len(rcs.Items)).To(gomega.BeNumerically(">", 0), "Expected to find a ReplicationController but none was found")
|
||||
|
||||
ginkgo.By("checking that ReplicationController has expected values")
|
||||
foundRc := false
|
||||
@@ -382,8 +383,7 @@ var _ = SIGDescribe("ReplicationController", func() {
|
||||
}
|
||||
}
|
||||
if !foundRc {
|
||||
framework.Logf("Got unexpected replication controller list %v", rcs.Items)
|
||||
framework.Failf("could not find ReplicationController %s", testRcName)
|
||||
framework.Failf("ReplicationController doesn't have expected values.\nValues that are in the ReplicationController list:\n%s", format.Object(rcs.Items, 1))
|
||||
}
|
||||
|
||||
// Delete ReplicationController
|
||||
@@ -407,7 +407,6 @@ var _ = SIGDescribe("ReplicationController", func() {
|
||||
if !eventFound {
|
||||
framework.Failf("failed to find RC %v event", watch.Added)
|
||||
}
|
||||
|
||||
return actualWatchEvents
|
||||
}, func() (err error) {
|
||||
_ = f.ClientSet.CoreV1().ReplicationControllers(testRcNamespace).DeleteCollection(ctx, metav1.DeleteOptions{}, metav1.ListOptions{LabelSelector: "test-rc-static=true"})
|
||||
|
Reference in New Issue
Block a user