diff options
author | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-07-02 14:03:13 +0200 |
---|---|---|
committer | Bjørn Christian Seime <bjorncs@verizonmedia.com> | 2020-07-02 14:05:04 +0200 |
commit | 5247bef4d4c58db7fb8716b654d47a41d6acd0a9 (patch) | |
tree | 23081ea7cfb2f9de5014a22bf322ccee1f358686 | |
parent | fe3c3cf89121d7c225c4c950cd97c22542137858 (diff) |
Use new OSGi based tester runtime in tester app
-rw-r--r-- | controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java | 31 | ||||
-rw-r--r-- | controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java | 25 | ||||
-rw-r--r-- | controller-server/src/test/resources/test_runner_services.xml-cd-legacy (renamed from controller-server/src/test/resources/test_runner_services.xml-cd) | 0 | ||||
-rw-r--r-- | controller-server/src/test/resources/test_runner_services.xml-cd-osgi | 26 |
4 files changed, 71 insertions, 11 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java index f08cce57dcb..6b09a77328d 100644 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java +++ b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunner.java @@ -45,6 +45,7 @@ import com.yahoo.vespa.hosted.controller.application.Deployment; import com.yahoo.vespa.hosted.controller.application.Endpoint; import com.yahoo.vespa.hosted.controller.application.TenantAndApplicationId; import com.yahoo.vespa.hosted.controller.certificate.EndpointCertificateException; +import com.yahoo.vespa.hosted.controller.config.ControllerConfig; import com.yahoo.vespa.hosted.controller.maintenance.JobRunner; import com.yahoo.vespa.hosted.controller.routing.RoutingPolicyId; import com.yahoo.yolean.Exceptions; @@ -793,10 +794,13 @@ public class InternalStepRunner implements StepRunner { ZoneId zone = id.type().zone(controller.system()); boolean useTesterCertificate = controller.system().isPublic() && id.type().environment().isTest(); + boolean useOsgiBasedTestRuntime = testerPlatformVersion(id).isAfter(new Version(7, 246)); byte[] servicesXml = servicesXml(! controller.system().isPublic(), useTesterCertificate, - testerResourcesFor(zone, spec.requireInstance(id.application().instance()))); + useOsgiBasedTestRuntime, + testerResourcesFor(zone, spec.requireInstance(id.application().instance())), + controller.controllerConfig().steprunner().testerapp()); byte[] testPackage = controller.applications().applicationStore().getTester(id.application().tenant(), id.application().application(), version); byte[] deploymentXml = deploymentXml(id.tester(), spec.athenzDomain(), @@ -845,7 +849,9 @@ public class InternalStepRunner implements StepRunner { } /** Returns the generated services.xml content for the tester application. */ - static byte[] servicesXml(boolean systemUsesAthenz, boolean useTesterCertificate, NodeResources resources) { + static byte[] servicesXml( + boolean systemUsesAthenz, boolean useTesterCertificate, boolean useOsgiBasedTestRuntime, + NodeResources resources, ControllerConfig.Steprunner.Testerapp config) { int jdiscMemoryGb = 2; // 2Gb memory for tester application (excessive?). int jdiscMemoryPct = (int) Math.ceil(100 * jdiscMemoryGb / resources.memoryGb()); @@ -856,6 +862,23 @@ public class InternalStepRunner implements StepRunner { "<resources vcpu=\"%.2f\" memory=\"%.2fGb\" disk=\"%.2fGb\" disk-speed=\"%s\" storage-type=\"%s\"/>", resources.vcpu(), resources.memoryGb(), resources.diskGb(), resources.diskSpeed().name(), resources.storageType().name()); + String runtimeProviderClass = config.runtimeProviderClass(); + String tenantCdBundle = config.tenantCdBundle(); + + String handlerAndExtraComponents = useOsgiBasedTestRuntime + ? + " <component id=\"" + runtimeProviderClass + "\" bundle=\"" + tenantCdBundle + "\" />\n" + + "\n" + + " <component id=\"com.yahoo.vespa.testrunner.JunitRunner\" bundle=\"vespa-osgi-testrunner\" />\n" + + "\n" + + " <handler id=\"com.yahoo.vespa.testrunner.JunitHandler\" bundle=\"vespa-osgi-testrunner\">\n" + + " <binding>http://*/tester/v1/*</binding>\n" + + " </handler>\n" + : + " <handler id=\"com.yahoo.vespa.hosted.testrunner.TestRunnerHandler\" bundle=\"vespa-testrunner-components\">\n" + + " <binding>http://*/tester/v1/*</binding>\n" + + " </handler>\n"; + String servicesXml = "<?xml version='1.0' encoding='UTF-8'?>\n" + "<services xmlns:deploy='vespa' version='1.0'>\n" + @@ -870,9 +893,7 @@ public class InternalStepRunner implements StepRunner { " </config>\n" + " </component>\n" + "\n" + - " <handler id=\"com.yahoo.vespa.hosted.testrunner.TestRunnerHandler\" bundle=\"vespa-testrunner-components\">\n" + - " <binding>http://*/tester/v1/*</binding>\n" + - " </handler>\n" + + handlerAndExtraComponents + "\n" + " <nodes count=\"1\" allocated-memory=\"" + jdiscMemoryPct + "%\">\n" + " " + resourceString + "\n" + diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java index 07c643070a0..02640cf8486 100644 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java +++ b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/deployment/InternalStepRunnerTest.java @@ -27,6 +27,7 @@ import com.yahoo.vespa.hosted.controller.api.integration.deployment.TesterCloud; import com.yahoo.vespa.hosted.controller.api.integration.stubs.MockMailer; import com.yahoo.vespa.hosted.controller.application.ApplicationPackage; import com.yahoo.vespa.hosted.controller.application.SystemApplication; +import com.yahoo.vespa.hosted.controller.config.ControllerConfig; import com.yahoo.vespa.hosted.controller.integration.ZoneApiMock; import org.junit.Before; import org.junit.Test; @@ -485,12 +486,24 @@ public class InternalStepRunnerTest { } @Test - public void generates_correct_services_xml_test() { - assertFile("test_runner_services.xml-cd", - new String(InternalStepRunner.servicesXml( - true, - false, - new NodeResources(2, 12, 75, 1, NodeResources.DiskSpeed.fast, NodeResources.StorageType.local)))); + public void generates_correct_services_xml_using_osgi_based_runtime() { + generates_correct_services_xml("test_runner_services.xml-cd-osgi", true); + } + + @Test + public void generates_correct_services_xml_using_legacy_runtime() { + generates_correct_services_xml("test_runner_services.xml-cd-legacy", false); + } + + private void generates_correct_services_xml(String filenameExpectedOutput, boolean useOsgiBasedRuntime) { + ControllerConfig.Steprunner.Testerapp config = new ControllerConfig.Steprunner.Testerapp.Builder().build(); + assertFile(filenameExpectedOutput, + new String(InternalStepRunner.servicesXml( + true, + false, + useOsgiBasedRuntime, + new NodeResources(2, 12, 75, 1, NodeResources.DiskSpeed.fast, NodeResources.StorageType.local), + config))); } private void assertFile(String resourceName, String actualContent) { diff --git a/controller-server/src/test/resources/test_runner_services.xml-cd b/controller-server/src/test/resources/test_runner_services.xml-cd-legacy index 125c5004d25..125c5004d25 100644 --- a/controller-server/src/test/resources/test_runner_services.xml-cd +++ b/controller-server/src/test/resources/test_runner_services.xml-cd-legacy diff --git a/controller-server/src/test/resources/test_runner_services.xml-cd-osgi b/controller-server/src/test/resources/test_runner_services.xml-cd-osgi new file mode 100644 index 00000000000..806c6befad0 --- /dev/null +++ b/controller-server/src/test/resources/test_runner_services.xml-cd-osgi @@ -0,0 +1,26 @@ +<?xml version='1.0' encoding='UTF-8'?> +<services xmlns:deploy='vespa' version='1.0'> + <container version='1.0' id='tester'> + + <component id="com.yahoo.vespa.hosted.testrunner.TestRunner" bundle="vespa-testrunner-components"> + <config name="com.yahoo.vespa.hosted.testrunner.test-runner"> + <artifactsPath>artifacts</artifactsPath> + <surefireMemoryMb>5120</surefireMemoryMb> + <useAthenzCredentials>true</useAthenzCredentials> + <useTesterCertificate>false</useTesterCertificate> + </config> + </component> + + <component id="ai.vespa.hosted.cd.cloud.impl.VespaTestRuntimeProvider" bundle="cloud-tenant-cd" /> + + <component id="com.yahoo.vespa.testrunner.JunitRunner" bundle="vespa-osgi-testrunner" /> + + <handler id="com.yahoo.vespa.testrunner.JunitHandler" bundle="vespa-osgi-testrunner"> + <binding>http://*/tester/v1/*</binding> + </handler> + + <nodes count="1" allocated-memory="17%"> + <resources vcpu="2.00" memory="12.00Gb" disk="75.00Gb" disk-speed="fast" storage-type="local"/> + </nodes> + </container> +</services> |