Skip to content

Commit 8b4569b

Browse files
committed
Test demonstrating issue dekorateio#1000
1 parent f242d45 commit 8b4569b

File tree

8 files changed

+187
-0
lines changed

8 files changed

+187
-0
lines changed

examples/spring-boot-on-kubernetes-with-sbo-example/src/main/resources/application.properties

+9
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,12 @@ dekorate.servicebinding.services[0].api-version=postgresql.dev/v1
22
dekorate.servicebinding.services[0].kind=Database
33
dekorate.servicebinding.services[0].name=demo-database
44
dekorate.kubernetes.image-pull-policy=IfNotPresent
5+
dekorate.kubernetes.env-vars[0].name=from-props
6+
dekorate.kubernetes.env-vars[0].value=prop-value
7+
dekorate.kubernetes.env-vars[1].name=from-props2
8+
dekorate.kubernetes.env-vars[1].value=prop-value2
9+
dekorate.kubernetes.ports[0].name=http
10+
dekorate.kubernetes.ports[0].containerPort=8080
11+
dekorate.kubernetes.ports[1].name=httpx
12+
dekorate.kubernetes.ports[1].containerPort=8089
13+

tests/issue-1000-docker-registry-docker-file-needs-Dockerfile/_Dockerfile

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Copyright 2018 The original authors.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License");
6+
you may not use this file except in compliance with the License.
7+
You may obtain a copy of the License at
8+
9+
http://www.apache.org/licenses/LICENSE-2.0
10+
11+
Unless required by applicable law or agreed to in writing, software
12+
distributed under the License is distributed on an "AS IS" BASIS,
13+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
See the License for the specific language governing permissions and
15+
limitations under the License.
16+
17+
-->
18+
<project xmlns="http://maven.apache.org/POM/4.0.0"
19+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
20+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
21+
<modelVersion>4.0.0</modelVersion>
22+
23+
<parent>
24+
<artifactId>dekorate-tests</artifactId>
25+
<groupId>io.dekorate</groupId>
26+
<version>2.9-SNAPSHOT</version>
27+
<relativePath>../</relativePath>
28+
</parent>
29+
30+
<groupId>io.dekorate</groupId>
31+
<artifactId>issue-100-docker-registry-docker-file-needs-Dockerfile</artifactId>
32+
<packaging>jar</packaging>
33+
<name>Dekorate :: Tests :: Annotations :: Kubernetes :: Integration Test for #1000</name>
34+
<description>Docker registry is defined</description>
35+
36+
<properties>
37+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
38+
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
39+
</properties>
40+
41+
<dependencies>
42+
<dependency>
43+
<groupId>io.dekorate</groupId>
44+
<artifactId>kubernetes-annotations</artifactId>
45+
<version>${project.version}</version>
46+
</dependency>
47+
<!-- Testing -->
48+
<dependency>
49+
<groupId>org.junit.jupiter</groupId>
50+
<artifactId>junit-jupiter-api</artifactId>
51+
<scope>test</scope>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.junit.jupiter</groupId>
55+
<artifactId>junit-jupiter-engine</artifactId>
56+
<scope>test</scope>
57+
</dependency>
58+
</dependencies>
59+
60+
<build>
61+
<plugins>
62+
<plugin>
63+
<groupId>org.apache.maven.plugins</groupId>
64+
<artifactId>maven-surefire-plugin</artifactId>
65+
<version>${version.maven-surefire-plugin}</version>
66+
<inherited>true</inherited>
67+
<configuration>
68+
<useSystemClassLoader>false</useSystemClassLoader>
69+
</configuration>
70+
</plugin>
71+
<plugin>
72+
<groupId>org.apache.maven.plugins</groupId>
73+
<artifactId>maven-compiler-plugin</artifactId>
74+
<version>${version.maven-compiler-plugin}</version>
75+
<configuration>
76+
<source>${java.source}</source>
77+
<target>${java.target}</target>
78+
</configuration>
79+
</plugin>
80+
</plugins>
81+
</build>
82+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/**
2+
* Copyright 2018 The original authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.dekorate.example;
18+
19+
import io.dekorate.annotation.Dekorate;
20+
21+
@Dekorate
22+
public class Main {
23+
24+
public static void main(String[] args) {
25+
}
26+
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
FROM openjdk:8u171-alpine3.7
2+
RUN apk --no-cache add curl
3+
COPY target/*.jar example.jar
4+
CMD java ${JAVA_OPTS} -jar example.jar
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
dekorate:
2+
docker:
3+
registry: localhost:3000
4+
docker-file: src/main/resources/Dockerfile
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/**
2+
* Copyright 2018 The original authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package io.dekorate.example;
18+
19+
import static org.junit.jupiter.api.Assertions.assertNotNull;
20+
import static org.junit.jupiter.api.Assertions.assertTrue;
21+
22+
import java.util.Optional;
23+
24+
import org.junit.jupiter.api.Test;
25+
26+
import io.dekorate.utils.Serialization;
27+
import io.fabric8.kubernetes.api.model.Container;
28+
import io.fabric8.kubernetes.api.model.HasMetadata;
29+
import io.fabric8.kubernetes.api.model.KubernetesList;
30+
import io.fabric8.kubernetes.api.model.apps.Deployment;
31+
32+
public class Issue420Test {
33+
34+
@Test
35+
public void shouldHaveRegistry() {
36+
KubernetesList list = Serialization
37+
.unmarshalAsList(Issue420Test.class.getClassLoader().getResourceAsStream("META-INF/dekorate/kubernetes.yml"));
38+
assertNotNull(list);
39+
Deployment d = findFirst(list, Deployment.class).orElseThrow(() -> new IllegalStateException());
40+
assertNotNull(d);
41+
Container c = d.getSpec().getTemplate().getSpec().getContainers().get(0);
42+
assertNotNull(c);
43+
String image = c.getImage();
44+
assertTrue(image.startsWith("localhost:3000"));
45+
}
46+
47+
<T extends HasMetadata> Optional<T> findFirst(KubernetesList list, Class<T> t) {
48+
return (Optional<T>) list.getItems().stream()
49+
.filter(i -> t.isInstance(i))
50+
.findFirst();
51+
}
52+
53+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import io.dekorate.utils.Serialization
2+
import io.fabric8.kubernetes.api.model.KubernetesList
3+
import io.fabric8.kubernetes.api.model.apps.Deployment;
4+
5+
//Check that file exits
6+
String base = basedir
7+
File kubernetesYml = new File(base, "target/classes/META-INF/dekorate/kubernetes.yml")
8+
assert !kubernetesYml.exists()

0 commit comments

Comments
 (0)