diff options
Diffstat (limited to 'vespa-maven-plugin/src/test')
6 files changed, 93 insertions, 0 deletions
diff --git a/vespa-maven-plugin/src/test/java/ai/vespa/hosted/plugin/EffectiveServicesMojoTest.java b/vespa-maven-plugin/src/test/java/ai/vespa/hosted/plugin/EffectiveServicesMojoTest.java new file mode 100644 index 00000000000..17c233fa71a --- /dev/null +++ b/vespa-maven-plugin/src/test/java/ai/vespa/hosted/plugin/EffectiveServicesMojoTest.java @@ -0,0 +1,43 @@ +package ai.vespa.hosted.plugin; + +import com.yahoo.config.provision.zone.ZoneId; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; + +import static org.junit.jupiter.api.Assertions.assertEquals; + +/** + * @author jonmv + * @author olaa + */ +@DisplayName("Effective services are correctly generated") +class EffectiveServicesMojoTest { + + private final File servicesFile = new File("src/test/resources/effective-services/services.xml"); + + @Test + @DisplayName("when zone matches environment-only directive") + void devServices() throws Exception { + assertEquals(Files.readString(Paths.get("src/test/resources/effective-services/dev.xml")), + EffectiveServicesMojo.effectiveServices(servicesFile, ZoneId.from("dev", "us-east-3"))); + } + + @Test + @DisplayName("when zone matches region-and-environment directive") + void prodUsEast3() throws Exception { + assertEquals(Files.readString(Paths.get("src/test/resources/effective-services/prod_us-east-3.xml")), + EffectiveServicesMojo.effectiveServices(servicesFile, ZoneId.from("prod", "us-east-3"))); + } + + @Test + @DisplayName("when zone doesn't match any directives") + void prodUsWest1Services() throws Exception { + assertEquals(Files.readString(Paths.get("src/test/resources/effective-services/prod_us-west-1.xml")), + EffectiveServicesMojo.effectiveServices(servicesFile, ZoneId.from("prod", "us-west-1"))); + } + +} diff --git a/vespa-maven-plugin/src/test/resources/effective-services/dev.xml b/vespa-maven-plugin/src/test/resources/effective-services/dev.xml new file mode 100644 index 00000000000..d6343e7ace7 --- /dev/null +++ b/vespa-maven-plugin/src/test/resources/effective-services/dev.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<services xmlns:deploy="vespa"> + <container> + <component id="good-service-client"> + <config> + <url>dev.tld</url> + </config> + </component> + </container> +</services> diff --git a/vespa-maven-plugin/src/test/resources/effective-services/prod_us-east-3.xml b/vespa-maven-plugin/src/test/resources/effective-services/prod_us-east-3.xml new file mode 100644 index 00000000000..0bab4b7e74a --- /dev/null +++ b/vespa-maven-plugin/src/test/resources/effective-services/prod_us-east-3.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<services xmlns:deploy="vespa"> + <container> + <component id="good-service-client"> + <config> + <url>us-east-3.prod.tld</url> + </config> + </component> + </container> +</services> diff --git a/vespa-maven-plugin/src/test/resources/effective-services/prod_us-west-1.xml b/vespa-maven-plugin/src/test/resources/effective-services/prod_us-west-1.xml new file mode 100644 index 00000000000..e29ba231092 --- /dev/null +++ b/vespa-maven-plugin/src/test/resources/effective-services/prod_us-west-1.xml @@ -0,0 +1,9 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<services xmlns:deploy="vespa"> + <container> + <component id="good-service-client"> + <config> + </config> + </component> + </container> +</services> diff --git a/vespa-maven-plugin/src/test/resources/effective-services/services.xml b/vespa-maven-plugin/src/test/resources/effective-services/services.xml new file mode 100644 index 00000000000..bf183f474e4 --- /dev/null +++ b/vespa-maven-plugin/src/test/resources/effective-services/services.xml @@ -0,0 +1,11 @@ +<?xml version='1.0' encoding='UTF-8'?> +<services xmlns:deploy="vespa"> + <container> + <component id="good-service-client"> + <config> + <url deploy:environment="dev">dev.tld</url> + <url deploy:environment="prod" deploy:region="us-east-3">us-east-3.prod.tld</url> + </config> + </component> + </container> +</services>
\ No newline at end of file diff --git a/vespa-maven-plugin/src/test/resources/effective-services/test_us-east-1.xml b/vespa-maven-plugin/src/test/resources/effective-services/test_us-east-1.xml new file mode 100644 index 00000000000..7f9e1bb93b9 --- /dev/null +++ b/vespa-maven-plugin/src/test/resources/effective-services/test_us-east-1.xml @@ -0,0 +1,10 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<services xmlns:deploy="vespa"> + <container> + <component id="good-service-client"> + <config> + <url>us-east-1.tld</url> + </config> + </component> + </container> +</services> |