diff options
author | Morten Tokle <mortent@oath.com> | 2017-11-23 11:43:21 +0100 |
---|---|---|
committer | Morten Tokle <mortent@oath.com> | 2017-11-23 11:43:21 +0100 |
commit | 1e23ba499b681f05f5c19c09e26e4488b4d31121 (patch) | |
tree | 0131cb8f3bc11940325386cd624c9b45c4bdc6f9 | |
parent | 7c6b77534b607c6123956ad5cb04f1bf82812b93 (diff) |
Fix failing tests
6 files changed, 39 insertions, 23 deletions
diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/CompressedApplicationInputStreamTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/CompressedApplicationInputStreamTest.java index 5d23f1a4556..ddd29f96695 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/CompressedApplicationInputStreamTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/CompressedApplicationInputStreamTest.java @@ -1,8 +1,8 @@ // Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. package com.yahoo.vespa.config.server.http; +import com.google.common.collect.ImmutableList; import com.google.common.io.ByteStreams; -import com.yahoo.vespa.config.server.http.CompressedApplicationInputStream; import org.apache.commons.compress.archivers.ArchiveOutputStream; import org.apache.commons.compress.archivers.tar.TarArchiveInputStream; import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream; @@ -10,16 +10,19 @@ import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream; import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream; import org.junit.Test; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.Arrays; import java.util.List; import java.util.zip.GZIPInputStream; import java.util.zip.GZIPOutputStream; import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.containsInAnyOrder; import static org.junit.Assert.assertThat; import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; /** * @author lulf @@ -37,6 +40,7 @@ public class CompressedApplicationInputStreamTest { File app = new File("src/test/resources/deploy/validapp"); writeFileToTar(taos, new File(app, "services.xml")); writeFileToTar(taos, new File(app, "hosts.xml")); + writeFileToTar(taos, new File(app, "deployment.xml")); taos.close(); return outFile; } @@ -55,14 +59,8 @@ public class CompressedApplicationInputStreamTest { void assertTestApp(File outApp) { String [] files = outApp.list(); - assertThat(files.length, is(2)); - if ("hosts.xml".equals(files[0])) { - assertThat(files[1], is("services.xml")); - } else if ("hosts.xml".equals(files[1])) { - assertThat(files[0], is("services.xml")); - } else { - fail("Both services.xml and hosts.xml should be contained in the unpacked application"); - } + assertThat(files.length, is(3)); + assertThat(Arrays.asList(files), containsInAnyOrder(ImmutableList.of(is("hosts.xml"), is("services.xml"), is("deployment.xml")))); } @Test @@ -88,6 +86,10 @@ public class CompressedApplicationInputStreamTest { archiveOutputStream.putArchiveEntry(archiveOutputStream.createArchiveEntry(file, "application/" + file.getName())); ByteStreams.copy(new FileInputStream(file), archiveOutputStream); archiveOutputStream.closeArchiveEntry(); + file = new File(app, "deployment.xml"); + archiveOutputStream.putArchiveEntry(archiveOutputStream.createArchiveEntry(file, "application/" + file.getName())); + ByteStreams.copy(new FileInputStream(file), archiveOutputStream); + archiveOutputStream.closeArchiveEntry(); archiveOutputStream.close(); @@ -134,9 +136,10 @@ public class CompressedApplicationInputStreamTest { new TarArchiveInputStream(new GZIPInputStream(new FileInputStream(gzFile)))); File outApp = unpacked.decompress(); List<File> files = Arrays.asList(outApp.listFiles()); - assertThat(files.size(), is(4)); + assertThat(files.size(), is(5)); assertTrue(files.contains(new File(outApp, "services.xml"))); assertTrue(files.contains(new File(outApp, "hosts.xml"))); + assertTrue(files.contains(new File(outApp, "deployment.xml"))); assertTrue(files.contains(new File(outApp, "searchdefinitions"))); assertTrue(files.contains(new File(outApp, "external"))); File sd = files.get(files.indexOf(new File(outApp, "searchdefinitions"))); diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java index 7fe7b350734..310342e81f1 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/http/v2/SessionCreateHandlerTest.java @@ -3,11 +3,11 @@ package com.yahoo.vespa.config.server.http.v2; import com.yahoo.cloud.config.ConfigserverConfig; import com.yahoo.config.model.application.provider.FilesApplicationPackage; +import com.yahoo.config.provision.ApplicationId; import com.yahoo.config.provision.TenantName; import com.yahoo.container.jdisc.HttpRequest; import com.yahoo.container.jdisc.HttpResponse; import com.yahoo.container.logging.AccessLog; -import com.yahoo.config.provision.ApplicationId; import com.yahoo.vespa.config.server.ApplicationRepository; import com.yahoo.vespa.config.server.application.MemoryTenantApplications; import com.yahoo.vespa.config.server.application.TenantApplications; @@ -15,24 +15,33 @@ import com.yahoo.vespa.config.server.http.CompressedApplicationInputStreamTest; import com.yahoo.vespa.config.server.http.HandlerTest; import com.yahoo.vespa.config.server.http.HttpErrorResponse; import com.yahoo.vespa.config.server.http.SessionHandlerTest; -import com.yahoo.vespa.config.server.session.*; +import com.yahoo.vespa.config.server.session.LocalSessionRepo; +import com.yahoo.vespa.config.server.session.SessionFactory; import com.yahoo.vespa.config.server.tenant.Tenants; -import com.yahoo.vespa.curator.mock.MockCurator; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; import java.time.Clock; import java.util.Collections; import java.util.HashMap; import java.util.Map; -import static com.yahoo.jdisc.Response.Status.*; +import static com.yahoo.jdisc.Response.Status.BAD_REQUEST; +import static com.yahoo.jdisc.Response.Status.INTERNAL_SERVER_ERROR; +import static com.yahoo.jdisc.Response.Status.METHOD_NOT_ALLOWED; +import static com.yahoo.jdisc.Response.Status.OK; +import static com.yahoo.jdisc.http.HttpRequest.Method.GET; +import static com.yahoo.jdisc.http.HttpRequest.Method.POST; import static org.hamcrest.core.Is.is; -import static org.junit.Assert.*; - -import static com.yahoo.jdisc.http.HttpRequest.Method.*; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; /** * @author hmusum @@ -168,7 +177,7 @@ public class SessionCreateHandlerTest extends SessionHandlerTest { assertTrue(applicationPackage.exists()); final File[] files = applicationPackage.listFiles(); assertNotNull(files); - assertThat(files.length, is(2)); + assertThat(files.length, is(3)); } @Test diff --git a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java index 474b93f6972..df8ed405fe3 100644 --- a/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java +++ b/configserver/src/test/java/com/yahoo/vespa/config/server/model/LbServicesProducerTest.java @@ -88,8 +88,9 @@ public class LbServicesProducerTest { private LbServicesConfig createModelAndGetLbServicesConfig(RegionName regionName) throws IOException, SAXException { final Zone zone = new Zone(Environment.prod, regionName); - Map<TenantName, Map<ApplicationId, ApplicationInfo>> testModel = createTestModel(new DeployState.Builder(). - properties(new DeployProperties.Builder().zone(zone).build())); + Map<TenantName, Map<ApplicationId, ApplicationInfo>> testModel = createTestModel(new DeployState.Builder() + .properties(new DeployProperties.Builder().zone(zone).build()) + .zone(zone)); return getLbServicesConfig(new Zone(Environment.prod, regionName), testModel); } diff --git a/configserver/src/test/resources/deploy/advancedapp/deployment.xml b/configserver/src/test/resources/deploy/advancedapp/deployment.xml new file mode 100644 index 00000000000..fa1d1388e67 --- /dev/null +++ b/configserver/src/test/resources/deploy/advancedapp/deployment.xml @@ -0,0 +1 @@ +<deployment version='1.0'/>
\ No newline at end of file diff --git a/configserver/src/test/resources/deploy/app/deployment.xml b/configserver/src/test/resources/deploy/app/deployment.xml new file mode 100644 index 00000000000..fa1d1388e67 --- /dev/null +++ b/configserver/src/test/resources/deploy/app/deployment.xml @@ -0,0 +1 @@ +<deployment version='1.0'/>
\ No newline at end of file diff --git a/configserver/src/test/resources/deploy/validapp/deployment.xml b/configserver/src/test/resources/deploy/validapp/deployment.xml new file mode 100644 index 00000000000..fa1d1388e67 --- /dev/null +++ b/configserver/src/test/resources/deploy/validapp/deployment.xml @@ -0,0 +1 @@ +<deployment version='1.0'/>
\ No newline at end of file |