Skip to content

Commit

Permalink
Allow to disable the project/namespace deletion on test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgitario committed May 7, 2021
1 parent 4d2f4e4 commit c2e866f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 2 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,16 @@ Use this Maven dependency:

And now, we can write also scenarios to be run in OpenShift by adding the `@OpenShiftScenario`.

#### Enable/Disable Project Deletion on Failures

By default, the framework will always delete the OpenShift project and, sometimes, it's useful to not delete
the OpenShift project on failures to troubleshooting purposes. For disabling the deletion on failures, we need to run the
test using:
```
mvn clean verify -Dts.openshift.delete.project.on.failure=false
```
#### Deployment Strategies
- **(Default) Using Build**
Expand Down Expand Up @@ -513,6 +523,16 @@ public class KubernetesPingPongResourceIT {
}
```
#### Enable/Disable Namespace Deletion on Failures
By default, the framework will always delete the Kubernetes namespace and, sometimes, it's useful to not delete
the Kubernetes namespace on failures to troubleshooting purposes. For disabling the deletion on failures, we need to run the
test using:

```
mvn clean verify -Dts.kubernetes.delete.namespace.on.failure=false
```

#### Deployment Strategies

- **(Default) Container Registry**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ public String get() {

return defaultValue;
}

public Boolean getAsBoolean() {
String value = get();
return Boolean.TRUE.toString().equalsIgnoreCase(value);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
import org.junit.jupiter.api.extension.ExtensionContext;

import io.quarkus.test.bootstrap.inject.KubectlClient;
import io.quarkus.test.configuration.PropertyLookup;
import io.quarkus.test.logging.Log;
import io.quarkus.test.scenarios.KubernetesScenario;
import io.quarkus.test.utils.FileUtils;

public class KubernetesExtensionBootstrap implements ExtensionBootstrap {

public static final String CLIENT = "kubectl-client";
private static final PropertyLookup DELETE_ON_FAIL = new PropertyLookup("ts.kubernetes.delete.namespace.on.failure",
Boolean.TRUE.toString());

private KubectlClient client;

Expand All @@ -30,7 +33,9 @@ public void beforeAll(ExtensionContext context) {

@Override
public void afterAll(ExtensionContext context) {
client.deleteNamespace();
if (DELETE_ON_FAIL.getAsBoolean()) {
client.deleteNamespace();
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@
import org.junit.jupiter.api.extension.ExtensionContext;

import io.quarkus.test.bootstrap.inject.OpenShiftClient;
import io.quarkus.test.configuration.PropertyLookup;
import io.quarkus.test.logging.Log;
import io.quarkus.test.scenarios.OpenShiftScenario;
import io.quarkus.test.utils.FileUtils;

public class OpenShiftExtensionBootstrap implements ExtensionBootstrap {

public static final String CLIENT = "openshift-client";
private static final PropertyLookup DELETE_ON_FAIL = new PropertyLookup("ts.openshift.delete.project.on.failure",
Boolean.TRUE.toString());

private OpenShiftClient client;

Expand All @@ -30,7 +33,9 @@ public void beforeAll(ExtensionContext context) {

@Override
public void afterAll(ExtensionContext context) {
client.deleteProject();
if (DELETE_ON_FAIL.getAsBoolean()) {
client.deleteProject();
}
}

@Override
Expand Down

0 comments on commit c2e866f

Please sign in to comment.