mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 20:17:41 +00:00
Add an post-upgrade condition to ensure the job is running
This commit is contained in:
parent
67cf648ab7
commit
f8abe71238
@ -60,8 +60,11 @@ func (t *JobUpgradeTest) Setup(ctx context.Context, f *framework.Framework) {
|
|||||||
// Test verifies that the Jobs Pods are running after the an upgrade
|
// Test verifies that the Jobs Pods are running after the an upgrade
|
||||||
func (t *JobUpgradeTest) Test(ctx context.Context, f *framework.Framework, done <-chan struct{}, upgrade upgrades.UpgradeType) {
|
func (t *JobUpgradeTest) Test(ctx context.Context, f *framework.Framework, done <-chan struct{}, upgrade upgrades.UpgradeType) {
|
||||||
<-done
|
<-done
|
||||||
|
ginkgo.By("Ensuring job is running")
|
||||||
|
err := ensureJobRunning(ctx, f.ClientSet, t.namespace, t.job.Name)
|
||||||
|
framework.ExpectNoError(err)
|
||||||
ginkgo.By("Ensuring active pods == parallelism")
|
ginkgo.By("Ensuring active pods == parallelism")
|
||||||
err := ensureAllJobPodsRunning(ctx, f.ClientSet, t.namespace, t.job.Name, 2)
|
err = ensureAllJobPodsRunning(ctx, f.ClientSet, t.namespace, t.job.Name, 2)
|
||||||
framework.ExpectNoError(err)
|
framework.ExpectNoError(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,7 +73,7 @@ func (t *JobUpgradeTest) Teardown(ctx context.Context, f *framework.Framework) {
|
|||||||
// rely on the namespace deletion to clean up everything
|
// rely on the namespace deletion to clean up everything
|
||||||
}
|
}
|
||||||
|
|
||||||
// ensureAllJobPodsRunning uses c to check in the Job named jobName in ns
|
// ensureAllJobPodsRunning uses c to check if the Job named jobName in ns
|
||||||
// is running, returning an error if the expected parallelism is not
|
// is running, returning an error if the expected parallelism is not
|
||||||
// satisfied.
|
// satisfied.
|
||||||
func ensureAllJobPodsRunning(ctx context.Context, c clientset.Interface, ns, jobName string, parallelism int32) error {
|
func ensureAllJobPodsRunning(ctx context.Context, c clientset.Interface, ns, jobName string, parallelism int32) error {
|
||||||
@ -93,3 +96,19 @@ func ensureAllJobPodsRunning(ctx context.Context, c clientset.Interface, ns, job
|
|||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ensureJobRunning uses c to check if the Job named jobName in ns is running,
|
||||||
|
// (not completed, nor failed, nor suspended) returning an error if it can't
|
||||||
|
// read the job or when it's not runnig
|
||||||
|
func ensureJobRunning(ctx context.Context, c clientset.Interface, ns, jobName string) error {
|
||||||
|
job, err := e2ejob.GetJob(ctx, c, ns, jobName)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, c := range job.Status.Conditions {
|
||||||
|
if (c.Type == batchv1.JobComplete || c.Type == batchv1.JobFailed || c.Type == batchv1.JobSuspended) && c.Status == v1.ConditionTrue {
|
||||||
|
return fmt.Errorf("job is not running %#v", job)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user