Skip to content

Commit

Permalink
test : Update CronJobIT to use batch/v1 CronJob instead(fabric8io#4434)
Browse files Browse the repository at this point in the history
Signed-off-by: Rohan Kumar <[email protected]>
  • Loading branch information
rohanKanojia committed Mar 31, 2023
1 parent e064378 commit 28f73e6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* fix #5002: Jetty response completion accounts for header processing

#### Improvements
* Fix #4434: Update CronJobIT to use `batch/v1` CronJob instead
* Fix #4477 exposing LeaderElector.release to force an elector to give up the lease
* Fix #4975: exposing scale operations for all Resources
* Fix #4992: Optimize Quantity parsing to avoid regex overhead
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

import io.fabric8.junit.jupiter.api.LoadKubernetesManifests;
import io.fabric8.junit.jupiter.api.RequireK8sSupport;
import io.fabric8.kubernetes.api.model.batch.v1beta1.CronJob;
import io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobBuilder;
import io.fabric8.kubernetes.api.model.batch.v1beta1.CronJobList;
import io.fabric8.kubernetes.api.model.batch.v1.CronJob;
import io.fabric8.kubernetes.api.model.batch.v1.CronJobBuilder;
import io.fabric8.kubernetes.api.model.batch.v1.CronJobList;
import io.fabric8.kubernetes.client.KubernetesClient;
import org.junit.jupiter.api.Test;

Expand All @@ -37,27 +37,27 @@ class CronJobIT {

@Test
void load() {
CronJob aCronJob = client.batch().v1beta1().cronjobs().load(getClass().getResourceAsStream("/test-cronjob.yml")).item();
CronJob aCronJob = client.batch().v1().cronjobs().load(getClass().getResourceAsStream("/test-cronjob.yml")).item();
assertNotNull(aCronJob);
assertEquals("hello", aCronJob.getMetadata().getName());
}

@Test
void get() {
CronJob cronJob1 = client.batch().v1beta1().cronjobs().withName("hello-get").get();
CronJob cronJob1 = client.batch().v1().cronjobs().withName("hello-get").get();
assertThat(cronJob1).isNotNull();
}

@Test
void list() {
CronJobList cronJobList = client.batch().v1beta1().cronjobs().list();
CronJobList cronJobList = client.batch().v1().cronjobs().list();
assertNotNull(cronJobList);
assertTrue(cronJobList.getItems().size() >= 1);
}

@Test
void update() {
CronJob cronJob1 = client.batch().v1beta1().cronjobs().withName("hello-update")
CronJob cronJob1 = client.batch().v1().cronjobs().withName("hello-update")
.edit(c -> new CronJobBuilder(c)
.editMetadata().withResourceVersion(null).endMetadata()
.editSpec().withSchedule("*/1 * * * *").endSpec()
Expand All @@ -67,6 +67,6 @@ void update() {

@Test
void delete() {
assertTrue(client.batch().v1beta1().cronjobs().withName("hello-delete").delete().size() == 1);
assertTrue(client.batch().v1().cronjobs().withName("hello-delete").delete().size() == 1);
}
}
8 changes: 4 additions & 4 deletions kubernetes-itests/src/test/resources/cronjob-it.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#

---
apiVersion: batch/v1beta1
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello-get
Expand All @@ -34,7 +34,7 @@ spec:
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
---
apiVersion: batch/v1beta1
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello-list
Expand All @@ -53,7 +53,7 @@ spec:
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
---
apiVersion: batch/v1beta1
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello-update
Expand All @@ -72,7 +72,7 @@ spec:
- date; echo Hello from the Kubernetes cluster
restartPolicy: OnFailure
---
apiVersion: batch/v1beta1
apiVersion: batch/v1
kind: CronJob
metadata:
name: hello-delete
Expand Down

0 comments on commit 28f73e6

Please sign in to comment.