diff --git a/tests/feat-575-knative-scale-to-zero/pom.xml b/tests/feat-575-knative-scale-to-zero/pom.xml new file mode 100644 index 000000000..55b996055 --- /dev/null +++ b/tests/feat-575-knative-scale-to-zero/pom.xml @@ -0,0 +1,66 @@ + + + 4.0.0 + + + dekorate-tests + io.dekorate + 0.12-SNAPSHOT + ../ + + + io.dekorate + feat-575-knative-scale-to-zero + Dekorate :: Tests :: Annotations :: Knative :: Scale to zero #575 + + + + + io.dekorate + knative-annotations + ${project.version} + + + io.dekorate + dekorate-spring-boot + ${project.version} + + + org.springframework.boot + spring-boot-starter-web + ${version.spring-boot} + + + + + org.junit.jupiter + junit-jupiter-api + ${version.junit-jupiter} + test + + + org.junit.jupiter + junit-jupiter-engine + ${version.junit-jupiter} + test + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + true + + false + + + + org.springframework.boot + spring-boot-maven-plugin + + + + diff --git a/tests/feat-575-knative-scale-to-zero/src/main/java/io/dekorate/annotationless/DemoApplication.java b/tests/feat-575-knative-scale-to-zero/src/main/java/io/dekorate/annotationless/DemoApplication.java new file mode 100644 index 000000000..527992eef --- /dev/null +++ b/tests/feat-575-knative-scale-to-zero/src/main/java/io/dekorate/annotationless/DemoApplication.java @@ -0,0 +1,28 @@ +/** + * Copyright 2018 The original authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package io.dekorate.annotationless; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class DemoApplication { + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } + +} diff --git a/tests/feat-575-knative-scale-to-zero/src/main/java/io/dekorate/annotationless/HelloController.java b/tests/feat-575-knative-scale-to-zero/src/main/java/io/dekorate/annotationless/HelloController.java new file mode 100644 index 000000000..987c1c7b2 --- /dev/null +++ b/tests/feat-575-knative-scale-to-zero/src/main/java/io/dekorate/annotationless/HelloController.java @@ -0,0 +1,32 @@ +/** + * Copyright 2018 The original authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +**/ + +package io.dekorate.annotationless; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +public class HelloController { + + private static final String HELLO = "hello world!"; + + @RequestMapping("/") + public String hello() { + return HELLO; + } +} diff --git a/tests/feat-575-knative-scale-to-zero/src/main/resources/application.properties b/tests/feat-575-knative-scale-to-zero/src/main/resources/application.properties new file mode 100644 index 000000000..0fd563e87 --- /dev/null +++ b/tests/feat-575-knative-scale-to-zero/src/main/resources/application.properties @@ -0,0 +1 @@ +dekorate.knative.scale-to-zero-enabled=false diff --git a/tests/feat-575-knative-scale-to-zero/src/test/java/io/dekorate/knative/Feat575ScaleToZeroTest.java b/tests/feat-575-knative-scale-to-zero/src/test/java/io/dekorate/knative/Feat575ScaleToZeroTest.java new file mode 100644 index 000000000..bbf5e87da --- /dev/null +++ b/tests/feat-575-knative-scale-to-zero/src/test/java/io/dekorate/knative/Feat575ScaleToZeroTest.java @@ -0,0 +1,48 @@ +/** + * Copyright 2018 The original authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * +**/ + +package io.dekorate.knative; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import java.util.Optional; + +import org.junit.jupiter.api.Test; + +import io.dekorate.utils.Serialization; +import io.fabric8.kubernetes.api.model.ConfigMap; +import io.fabric8.kubernetes.api.model.HasMetadata; +import io.fabric8.kubernetes.api.model.KubernetesList; + +public class Feat575ScaleToZeroTest { + + @Test + public void shouldContainRequestsPerSecond() { + KubernetesList list = Serialization.unmarshalAsList(getClass().getClassLoader().getResourceAsStream("META-INF/dekorate/knative.yml")); + assertNotNull(list); + ConfigMap c = findFirst(list, ConfigMap.class).orElseThrow(() -> new IllegalStateException()); + assertEquals("false", c.getData().get("enable-scale-to-zero")); + } + + + Optional findFirst(KubernetesList list, Class t) { + return (Optional) list.getItems().stream() + .filter(i -> t.isInstance(i)) + .findFirst(); + } +}