diff options
author | Harald Musum <musum@oath.com> | 2018-09-13 09:46:22 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-09-13 09:46:22 +0200 |
commit | 883b285455301d8abc3db1b0ea18718fb92e6042 (patch) | |
tree | 8109e3a201952323fdc87589822464be9f87a786 | |
parent | 795f139f202207cb15236ed2ebeefc7c3143e54b (diff) | |
parent | 95ba8b99fa8669e4e6e0b4d35a1cb042b6a4fe83 (diff) |
Merge pull request #6910 from vespa-engine/olaaun/tests-log-retrieval
Added test for log retrieval
4 files changed, 57 insertions, 0 deletions
diff --git a/configserver/src/test/apps/app-logserver-with-container/hosts.xml b/configserver/src/test/apps/app-logserver-with-container/hosts.xml new file mode 100644 index 00000000000..d5a51f050fd --- /dev/null +++ b/configserver/src/test/apps/app-logserver-with-container/hosts.xml @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<hosts> + <host name="localhost"> + <alias>node1</alias> + </host> +</hosts> + diff --git a/configserver/src/test/apps/app-logserver-with-container/services.xml b/configserver/src/test/apps/app-logserver-with-container/services.xml new file mode 100644 index 00000000000..3b88fc3879d --- /dev/null +++ b/configserver/src/test/apps/app-logserver-with-container/services.xml @@ -0,0 +1,18 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!-- Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. --> +<services version="1.0"> + + <admin version="2.0"> + <adminserver hostalias="node1"/> + <logserver hostalias="node1"/> + </admin> + + + + <container version="1.0"> + <nodes> + <node hostalias="node1" /> + </nodes> + </container> + +</services> diff --git a/configserver/src/test/apps/app/services.xml b/configserver/src/test/apps/app/services.xml index 6cc30b8b6ec..457a3fad397 100644 --- a/configserver/src/test/apps/app/services.xml +++ b/configserver/src/test/apps/app/services.xml @@ -4,6 +4,7 @@ <admin version="2.0"> <adminserver hostalias="node1"/> + <logserver hostalias="node1" /> </admin> <content version="1.0"> diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java index a5e76262f48..120119f35bb 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/ApplicationRepositoryTest.java @@ -1,6 +1,8 @@ // Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server; +import com.github.tomakehurst.wiremock.WireMockServer; +import com.github.tomakehurst.wiremock.client.WireMock; import com.google.common.io.Files; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.component.Version; @@ -13,6 +15,7 @@ import com.yahoo.config.provision.Environment; import com.yahoo.config.provision.InstanceName; import com.yahoo.config.provision.Provisioner; import com.yahoo.config.provision.TenantName; +import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.io.IOUtils; import com.yahoo.test.ManualClock; import com.yahoo.text.Utf8; @@ -41,6 +44,11 @@ import java.util.Collections; import java.util.Optional; import java.util.Set; +import static com.github.tomakehurst.wiremock.client.WireMock.aResponse; +import static com.github.tomakehurst.wiremock.client.WireMock.get; +import static com.github.tomakehurst.wiremock.client.WireMock.stubFor; +import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo; +import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.wireMockConfig; import static org.hamcrest.CoreMatchers.is; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -58,6 +66,7 @@ public class ApplicationRepositoryTest { private final static File testApp = new File("src/test/apps/app"); private final static File testAppJdiscOnly = new File("src/test/apps/app-jdisc-only"); private final static File testAppJdiscOnlyRestart = new File("src/test/apps/app-jdisc-only-restart"); + private final static File testAppLogServerWithContainer = new File("src/test/apps/app-logserver-with-container"); private final static TenantName tenant1 = TenantName.from("test1"); private final static TenantName tenant2 = TenantName.from("test2"); @@ -109,6 +118,27 @@ public class ApplicationRepositoryTest { } @Test + public void getLogs(){ + WireMockServer wireMock = new WireMockServer(wireMockConfig().port(8080)); + wireMock.start(); + WireMock.configureFor("localhost", wireMock.port()); + stubFor(get(urlEqualTo("/logs")) + .willReturn(aResponse() + .withStatus(200))); + wireMock.start(); + deployApp(testAppLogServerWithContainer); + HttpResponse response = applicationRepository.getLogs(applicationId()); + assertEquals(response.getStatus(),200); + wireMock.stop(); + } + + @Test(expected = IllegalArgumentException.class) + public void getLogsNoContainerOnLogServerHostShouldThrowException() { + deployApp(testApp); + applicationRepository.getLogs(applicationId()); + } + + @Test public void deleteUnusedTenants() { // Set clock to epoch plus hour, as mock curator will always return epoch as creation time Instant now = ManualClock.at("1970-01-01T01:00:00"); |