Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to disable the project/namespace deletion on test failures #18

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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