-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: e2e test to demonstrate namespace deletion problem
Signed-off-by: Attila Mészáros <[email protected]>
- Loading branch information
Showing
9 changed files
with
190 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>io.javaoperatorsdk</groupId> | ||
<artifactId>sample-operators</artifactId> | ||
<version>5.0.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>sample-controller-namespace-deletion</artifactId> | ||
<packaging>jar</packaging> | ||
<name>Operator SDK - Samples - Controller Namespace Deletion</name> | ||
<description>Deleting namespace with controller and custom resources</description> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>io.javaoperatorsdk</groupId> | ||
<artifactId>operator-framework-bom</artifactId> | ||
<version>${project.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.javaoperatorsdk</groupId> | ||
<artifactId>operator-framework</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.fabric8</groupId> | ||
<artifactId>crd-generator-apt</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-slf4j2-impl</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.apache.logging.log4j</groupId> | ||
<artifactId>log4j-core</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.takes</groupId> | ||
<artifactId>takes</artifactId> | ||
<version>1.24.4</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.awaitility</groupId> | ||
<artifactId>awaitility</artifactId> | ||
<scope>compile</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>io.javaoperatorsdk</groupId> | ||
<artifactId>operator-framework-junit-5</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.junit.jupiter</groupId> | ||
<artifactId>junit-jupiter-params</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<plugins> | ||
<plugin> | ||
<groupId>com.google.cloud.tools</groupId> | ||
<artifactId>jib-maven-plugin</artifactId> | ||
<version>${jib-maven-plugin.version}</version> | ||
<configuration> | ||
<from> | ||
<image>gcr.io/distroless/java17-debian11</image> | ||
</from> | ||
<to> | ||
<image>leader-election-operator</image> | ||
</to> | ||
</configuration> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>3.12.1</version> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
</project> |
7 changes: 7 additions & 0 deletions
7
...in/java/io/javaoperatorsdk/operator/sample/ControllerNamespaceDeletionCustomResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package io.javaoperatorsdk.operator.sample; | ||
|
||
import io.fabric8.kubernetes.client.CustomResource; | ||
|
||
public class ControllerNamespaceDeletionCustomResource extends CustomResource<ControllerNamespaceDeletionSpec, ControllerNamespaceDeletionStatus> { | ||
|
||
} |
19 changes: 19 additions & 0 deletions
19
...src/main/java/io/javaoperatorsdk/operator/sample/ControllerNamespaceDeletionOperator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package io.javaoperatorsdk.operator.sample; | ||
|
||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import io.javaoperatorsdk.operator.Operator; | ||
import io.javaoperatorsdk.operator.api.config.LeaderElectionConfiguration; | ||
|
||
public class ControllerNamespaceDeletionOperator { | ||
|
||
private static final Logger log = LoggerFactory.getLogger(ControllerNamespaceDeletionOperator.class); | ||
|
||
public static void main(String[] args) { | ||
Operator operator = new Operator(); | ||
|
||
operator.register(new ControllerNamespaceDeletionReconciler()); | ||
operator.start(); | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...c/main/java/io/javaoperatorsdk/operator/sample/ControllerNamespaceDeletionReconciler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.javaoperatorsdk.operator.sample; | ||
|
||
import io.javaoperatorsdk.operator.api.reconciler.Cleaner; | ||
import io.javaoperatorsdk.operator.api.reconciler.Context; | ||
import io.javaoperatorsdk.operator.api.reconciler.DeleteControl; | ||
import io.javaoperatorsdk.operator.api.reconciler.Reconciler; | ||
import io.javaoperatorsdk.operator.api.reconciler.UpdateControl; | ||
|
||
import java.time.Duration; | ||
|
||
public class ControllerNamespaceDeletionReconciler implements Reconciler<ControllerNamespaceDeletionCustomResource>, | ||
Cleaner<ControllerNamespaceDeletionCustomResource> { | ||
|
||
@Override | ||
public UpdateControl<ControllerNamespaceDeletionCustomResource> reconcile(ControllerNamespaceDeletionCustomResource resource, | ||
Context<ControllerNamespaceDeletionCustomResource> context) { | ||
|
||
|
||
return null; | ||
} | ||
|
||
|
||
@Override | ||
public DeleteControl cleanup(ControllerNamespaceDeletionCustomResource resource, | ||
Context<ControllerNamespaceDeletionCustomResource> context) { | ||
try { | ||
Thread.sleep(Duration.ofSeconds(10).toMillis()); | ||
return DeleteControl.defaultDelete(); | ||
} catch (InterruptedException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
...ion/src/main/java/io/javaoperatorsdk/operator/sample/ControllerNamespaceDeletionSpec.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.javaoperatorsdk.operator.sample; | ||
|
||
import io.fabric8.kubernetes.client.CustomResource; | ||
|
||
public class ControllerNamespaceDeletionSpec { | ||
} |
6 changes: 6 additions & 0 deletions
6
...n/src/main/java/io/javaoperatorsdk/operator/sample/ControllerNamespaceDeletionStatus.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package io.javaoperatorsdk.operator.sample; | ||
|
||
import io.fabric8.kubernetes.client.CustomResource; | ||
|
||
public class ControllerNamespaceDeletionStatus { | ||
} |
13 changes: 13 additions & 0 deletions
13
sample-operators/controller-namespace-deletion/src/main/resources/log4j2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Configuration status="WARN"> | ||
<Appenders> | ||
<Console name="Console" target="SYSTEM_OUT"> | ||
<PatternLayout pattern="%d %-30c{1.} [%-5level] %msg%n%throwable"/> | ||
</Console> | ||
</Appenders> | ||
<Loggers> | ||
<Root level="debug"> | ||
<AppenderRef ref="Console"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
13 changes: 13 additions & 0 deletions
13
sample-operators/controller-namespace-deletion/src/test/resources/log4j2.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Configuration status="WARN"> | ||
<Appenders> | ||
<Console name="Console" target="SYSTEM_OUT"> | ||
<PatternLayout pattern="%style{%d}{yellow} %style{%-30c{1.}}{cyan} %highlight{[%-5level] %msg%n%throwable}{INFO=white}"/> | ||
</Console> | ||
</Appenders> | ||
<Loggers> | ||
<Root level="debug"> | ||
<AppenderRef ref="Console"/> | ||
</Root> | ||
</Loggers> | ||
</Configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters