Skip to content

Commit

Permalink
MGDSTRM-10781 using the project bundle for the test
Browse files Browse the repository at this point in the history
  • Loading branch information
shawkins committed Mar 1, 2023
1 parent dfd4d0a commit 17bf3e0
Show file tree
Hide file tree
Showing 13 changed files with 76 additions and 1,336 deletions.
59 changes: 40 additions & 19 deletions bundle/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,32 +64,53 @@
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.skyscreamer</groupId>
<artifactId>jsonassert</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!--
Set dependency paths as properties to make operator and sync bundle metadata artifacts
available to bundle generator.
-->
<execution>
<id>define-dependency-properties</id>
<goals>
<goal>properties</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemPropertyVariables>
<kas.bundle.operator-archive>${kas.bundle.operator-archive}</kas.bundle.operator-archive>
<kas.bundle.sync-archive>${kas.bundle.sync-archive}</kas.bundle.sync-archive>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>

<profiles>
<profile>
<id>generate-bundle</id>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<!--
Set dependency paths as properties to make operator and sync bundle metadata artifacts
available to bundle generator.
-->
<execution>
<id>define-dependency-properties</id>
<goals>
<goal>properties</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -254,7 +255,7 @@ void mergeClusterServiceVersions() throws IOException {
ClusterServiceVersion operatorCsv = operatorBundle.readResource("manifests/kas-fleetshard-operator.clusterserviceversion.yaml");

operatorCsv.getMetadata().setName("kas-fleetshard-operator.v" + version);
operatorCsv.getMetadata().setAnnotations(new HashMap<>());
operatorCsv.getMetadata().setAnnotations(new LinkedHashMap<>());
operatorCsv.getMetadata().getAnnotations().put("olm.skipRange", ">=0.0.1 <" + version);
operatorCsv.getMetadata().getAnnotations().put("alm-examples", JSON_MAPPER.writerWithDefaultPrettyPrinter().writeValueAsString(almExamples));

Expand Down Expand Up @@ -318,7 +319,7 @@ void buildAndPushImage() throws InvalidImageReferenceException, InterruptedExcep
.map(retrieverFactory::dockerConfig))
.orElseGet(retrieverFactory::dockerConfig);

Map<String, String> bundleAnnotations = new HashMap<>();
Map<String, String> bundleAnnotations = new LinkedHashMap<>();

YAML_MAPPER.readTree(operatorBundle.getEntry(ANNOTATIONS_PATH))
.get("annotations")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,22 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import io.fabric8.kubernetes.client.utils.IOHelpers;
import org.apache.commons.compress.archivers.ArchiveException;
import org.apache.commons.compress.archivers.ArchiveStreamFactory;
import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
import org.apache.commons.compress.utils.IOUtils;
import org.json.JSONException;
import org.junit.jupiter.api.Test;
import org.skyscreamer.jsonassert.JSONAssert;
import org.skyscreamer.jsonassert.JSONCompareMode;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.UncheckedIOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
Expand All @@ -40,8 +43,6 @@ void testAssembler() throws Exception {
Path bundleTar = testBundle.resolve("bundle.tar");

System.setProperty("kas.bundle.output-directory", testBundle.toAbsolutePath().toString());
System.setProperty("kas.bundle.operator-archive", targetPath.resolve("test-classes/operator-archive").toString());
System.setProperty("kas.bundle.sync-archive", targetPath.resolve("test-classes/sync-archive").toString());
System.setProperty("kas.bundle.version", "1.2.3");
System.setProperty("kas.bundle.image", "bf2/kas-fleetshard-operator-bundle:1.2.3");
System.setProperty("kas.bundle.tar-image", bundleTar.toString());
Expand Down Expand Up @@ -78,9 +79,10 @@ void testAssembler() throws Exception {
try {
String expected = Files.readString(file);
String actual = new String(layerEntries.get(expectedBundle.relativize(file).toString()), StandardCharsets.UTF_8);
assertEquals(expected, actual);
} catch (IOException e) {
throw new UncheckedIOException(e);

JSONAssert.assertEquals(IOHelpers.convertYamlToJson(expected), IOHelpers.convertYamlToJson(actual), JSONCompareMode.NON_EXTENSIBLE);
} catch (IOException | JSONException e) {
throw new RuntimeException(e);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ metadata:
spec:
customresourcedefinitions:
owned:
- kind: ManagedKafka
name: managedkafkas.managedkafka.bf2.org
version: v1alpha1
- kind: ManagedKafkaAgent
name: managedkafkaagents.managedkafka.bf2.org
version: v1alpha1
- kind: ManagedKafka
name: managedkafkas.managedkafka.bf2.org
version: v1alpha1
description: Operator That Manages Kafka Instances
displayName: KaaS Fleetshard Operator
install:
Expand Down Expand Up @@ -275,7 +275,7 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.namespace
image: quay.io/bf2fc6cc711aee1a0c2a82e312df7f2e6b37baa12bd9b1f2fd752e260d93a6f8144ac730947f25caa2bfe6ad0f410da360940ee6d28d6c1688d3822c4055650e/kas-fleetshard-operator:latest
image: kas-fleetshard-operator
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
Expand Down Expand Up @@ -343,7 +343,7 @@ spec:
value: prod
- name: QUARKUS_KUBERNETES_CONFIG_ENABLED
value: "true"
image: quay.io/bf2fc6cc711aee1a0c2a82e312df7f2e6b37baa12bd9b1f2fd752e260d93a6f8144ac730947f25caa2bfe6ad0f410da360940ee6d28d6c1688d3822c4055650e/kas-fleetshard-sync:latest
image: kas-fleetshard-sync
imagePullPolicy: Always
livenessProbe:
failureThreshold: 3
Expand Down Expand Up @@ -424,4 +424,4 @@ spec:
provider:
name: bf2 community
url: https://github.com/bf2fc6cc711aee1a0c2a/kas-fleetshard
version: 1.2.3
version: 1.2.3
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ spec:
type: object
net:
properties:
_private:
private:
type: boolean
type: object
required:
Expand Down
Loading

0 comments on commit 17bf3e0

Please sign in to comment.