summaryrefslogtreecommitdiffstats
path: root/standalone-container/src/test/scala
diff options
context:
space:
mode:
Diffstat (limited to 'standalone-container/src/test/scala')
-rw-r--r--standalone-container/src/test/scala/com/yahoo/container/standalone/CloudConfigInstallVariablesTest.scala59
-rw-r--r--standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainer.scala64
-rw-r--r--standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainerTest.scala85
-rw-r--r--standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneSubscriberTest.scala41
4 files changed, 0 insertions, 249 deletions
diff --git a/standalone-container/src/test/scala/com/yahoo/container/standalone/CloudConfigInstallVariablesTest.scala b/standalone-container/src/test/scala/com/yahoo/container/standalone/CloudConfigInstallVariablesTest.scala
deleted file mode 100644
index d4baea43ba2..00000000000
--- a/standalone-container/src/test/scala/com/yahoo/container/standalone/CloudConfigInstallVariablesTest.scala
+++ /dev/null
@@ -1,59 +0,0 @@
-// Copyright 2018 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.container.standalone
-
-import com.yahoo.container.standalone.CloudConfigInstallVariables.{toConfigModelsPluginDir, toConfigServer, toConfigServers}
-import org.hamcrest.CoreMatchers.is
-import org.hamcrest.Matchers.arrayContaining
-import org.junit.Assert.assertThat
-import org.junit.Test
-
-/**
- * @author Ulf Lilleengen
- * @author Tony Vaagenes
- */
-class CloudConfigInstallVariablesTest {
-
- @Test
- def test_configserver_parsing {
- val parsed = toConfigServers("myhost.mydomain.com")
- assertThat(parsed.length, is(1))
- }
-
- @Test
- def port_can_be_configured {
- val parsed = toConfigServers("myhost:123")
- val port: Int = parsed(0).port.get()
- assertThat(port, is(123))
- }
-
- @Test
- def multiple_spaces_are_supported {
- val parsed = toConfigServers("test1 test2")
- assertThat(parsed.size, is(2))
-
- val hostNames = parsed.map(_.hostName)
- assertThat(hostNames, arrayContaining("test1", "test2"))
- }
-
- @Test(expected = classOf[IllegalArgumentException])
- def missing_port_gives_exception {
- toConfigServer("myhost:")
- }
-
- @Test(expected = classOf[IllegalArgumentException])
- def non_numeric_port_gives_exception {
- toConfigServer("myhost:non-numeric")
- }
-
- @Test
- def string_arrays_are_split_on_spaces {
- val parsed = toConfigModelsPluginDir("/home/vespa/foo /home/vespa/bar ")
- assertThat(parsed.size, is(2))
- }
-
- @Test
- def string_arrays_are_split_on_comma {
- val parsed = toConfigModelsPluginDir("/home/vespa/foo,/home/vespa/bar,")
- assertThat(parsed.size, is(2))
- }
-}
diff --git a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainer.scala b/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainer.scala
deleted file mode 100644
index 33f9a2e8594..00000000000
--- a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainer.scala
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.container.standalone
-
-import com.yahoo.config.model.producer.AbstractConfigProducerRoot
-import com.yahoo.config.model.test.MockRoot
-import com.yahoo.container.Container
-import com.yahoo.jdisc.test.TestDriver
-import scala.xml.Node
-import com.yahoo.vespa.model.VespaModel
-import com.yahoo.io.IOUtils
-import java.nio.file.{Files, Path}
-import com.yahoo.vespa.model.container.xml.ContainerModelBuilder.Networking
-
-/**
- * Creates a local application from vespa-services fragments.
- *
- * @author tonytv
- */
-object StandaloneContainer {
- def firstContainerId(root: AbstractConfigProducerRoot): String = {
- root.getConfigProducer("container").get().getConfigId
- }
-
- def withStandaloneContainer[T](containerNode: Node) {
- withTempDirectory { applicationDirectory =>
- System.setProperty(StandaloneContainerApplication.applicationLocationInstallVariable, applicationDirectory.toString)
- createServicesXml(applicationDirectory, containerNode)
-
- val driver = TestDriver.newInjectedApplicationInstance(classOf[StandaloneContainerApplication])
- driver.close()
- Container.resetInstance()
- }
- }
-
- def withContainerModel[T](containerNode: Node)(f: VespaModel => T) {
- withTempDirectory { applicationPath =>
- createServicesXml(applicationPath, containerNode)
-
- val distributedFiles = new LocalFileDb(applicationPath)
- val (root, container) = StandaloneContainerApplication.createContainerModel(
- applicationPath,
- distributedFiles,
- applicationPath.resolve("preprocesedApp").toFile,
- networkingOption = Networking.enable)
- f(root)
- }
- }
-
- private def withTempDirectory[T](f : Path => T) : T = {
- val directory = Files.createTempDirectory("application")
- try {
- f(directory)
- } finally {
- IOUtils.recursiveDeleteDir(directory.toFile)
- }
- }
-
- private def createServicesXml(applicationPath : Path,
- containerNode: Node) {
-
- scala.xml.XML.save(applicationPath.resolve("services.xml").toFile.getAbsolutePath,
- containerNode, xmlDecl = true)
- }
-}
diff --git a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainerTest.scala b/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainerTest.scala
deleted file mode 100644
index 87bef2efd95..00000000000
--- a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneContainerTest.scala
+++ /dev/null
@@ -1,85 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.container.standalone
-
-
-import com.yahoo.container.standalone.StandaloneContainerTest._
-import com.yahoo.vespa.model.AbstractService
-import org.junit.Assert._
-import org.junit.Test
-
-import scala.util.Try
-
-
-/**
- * @author tonytv
- * @author gjoranv
- */
-
-class StandaloneContainerTest {
- @Test
- def container_is_allowed_root_element() {
- StandaloneContainer.withContainerModel(plainXml) { root => }
- }
-
- @Test
- def services_is_allowed_root_element() {
- val servicesXml =
- <services>
- <container version="1.0" />
- </services>
-
- StandaloneContainer.withContainerModel(servicesXml) { root => }
- }
-
- @Test
- def multiple_container_elements_cannot_be_deployed() {
- val twoContainersXml =
- <services>
- <container id="container-1" version="1.0" />
- <container id="container-2" version="1.0" />
- </services>
-
- assertTrue(
- Try {
- StandaloneContainer.withContainerModel(twoContainersXml) { root => }
- }.isFailure)
- }
-
- @Test
- def application_preprocessor_is_run() {
- val servicesXml =
- <services xmlns:preprocess="properties">
- <preprocess:properties>
- <container_id>container-1</container_id>
- </preprocess:properties>
- <container id="${container_id}" version="1.0" />
- </services>
- StandaloneContainer.withContainerModel(servicesXml) {
- root =>
- assertTrue(root.getConfigProducer("container-1/standalone").isPresent)
- }
- }
-
- @Test
- def no_default_ports_are_enabled_when_using_http() {
- val xml =
- <jdisc version="1.0">
- <http>
- <server port="4000" id="server1" />
- </http>
- </jdisc>
-
- StandaloneContainer.withContainerModel(xml) { root =>
- val container = root.getConfigProducer("jdisc/standalone").get().asInstanceOf[AbstractService]
- println("portCnt: " + container.getPortCount)
- println("numPorts: " + container.getNumPortsAllocated)
- assertEquals(1, container.getNumPortsAllocated)
- }
- }
-
-}
-
-object StandaloneContainerTest {
-
- val plainXml = <container version="1.0" />
-}
diff --git a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneSubscriberTest.scala b/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneSubscriberTest.scala
deleted file mode 100644
index ab6f486c748..00000000000
--- a/standalone-container/src/test/scala/com/yahoo/container/standalone/StandaloneSubscriberTest.scala
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
-package com.yahoo.container.standalone
-
-import org.junit.{Ignore, Test}
-import org.junit.Assert.assertThat
-import org.hamcrest.CoreMatchers.is
-import org.hamcrest.number.OrderingComparison.greaterThan
-
-import StandaloneContainer.withContainerModel
-import com.yahoo.vespa.config.ConfigKey
-import com.yahoo.config.ConfigInstance
-import com.yahoo.container.{ComponentsConfig, BundlesConfig, di}
-import scala.collection.JavaConverters._
-
-/**
- * @author tonytv
- */
-class StandaloneSubscriberTest {
- val bundlesKey = key("bundles")
- val componentsKey = key("components")
-
- def key(name: String) = new ConfigKey(name, "container", "container").asInstanceOf[ConfigKey[ConfigInstance]]
-
- def box(i: Int) = java.lang.Integer.valueOf(i)
-
- @Test
- @Ignore
- def standalone_subscriber() {
- withContainerModel(<container version="1.0"> </container>) { root =>
- val subscriber = new StandaloneSubscriberFactory(root).getSubscriber(Set(bundlesKey, componentsKey).asJava)
- val config = subscriber.config.asScala
- assertThat(config.size, is(2))
-
- val bundlesConfig = config(bundlesKey).asInstanceOf[BundlesConfig]
- val componentsConfig = config(componentsKey).asInstanceOf[ComponentsConfig]
-
- assertThat(bundlesConfig.bundle().size(), is(0))
- assertThat(box(componentsConfig.components().size()), greaterThan(box(10)))
- }
- }
-}