From e512ac3717bffe11970d4a86f4b00da1f4fb6659 Mon Sep 17 00:00:00 2001 From: James DeFelice Date: Thu, 27 Oct 2016 17:33:32 -0400 Subject: [PATCH] move Container.Docker.PortMapping to Container.PortMapping Summary: Port mappings are supported (by Mesos) for more than just Docker, so move PortMapping into Container (as a first step). related to https://github.com/mesosphere/marathon/issues/4548 Test Plan: sbt test Reviewers: nfnt, jasongilanfarr Reviewed By: jasongilanfarr Subscribers: jenkins, marathon-team Differential Revision: https://phabricator.mesosphere.com/D123 --- .../serialization/ContainerSerializer.scala | 6 +- .../marathon/api/v2/json/Formats.scala | 8 +- .../mesosphere/marathon/state/Container.scala | 107 +++++++++--------- .../marathon/tasks/PortsMatcher.scala | 2 +- .../marathon/api/v2/AppsResourceTest.scala | 11 +- .../marathon/api/v2/ModelValidationTest.scala | 4 +- .../v2/json/AppDefinitionFormatsTest.scala | 5 +- .../api/v2/json/AppDefinitionTest.scala | 29 ++--- .../marathon/api/v2/json/AppUpdateTest.scala | 7 +- .../validation/AppUpdateValidatorTest.scala | 4 +- .../group/impl/GroupManagerActorTest.scala | 18 ++- .../core/health/MesosHealthCheckTest.scala | 25 ++-- .../AppDeployIntegrationTest.scala | 8 +- .../integration/facades/MarathonFacade.scala | 4 +- .../setup/MarathonCallbackTestSupport.scala | 3 +- .../AppDefinitionPortAssignmentsTest.scala | 19 ++-- .../marathon/state/AppDefinitionTest.scala | 12 +- .../marathon/state/PortMappingTest.scala | 7 +- .../marathon/tasks/PortsMatcherTest.scala | 25 ++-- .../marathon/test/MarathonTestHelper.scala | 2 +- .../mesos/ResourceMatcherTest.scala | 10 +- .../mesosphere/mesos/TaskBuilderTest.scala | 15 ++- 22 files changed, 168 insertions(+), 163 deletions(-) diff --git a/src/main/scala/mesosphere/marathon/api/serialization/ContainerSerializer.scala b/src/main/scala/mesosphere/marathon/api/serialization/ContainerSerializer.scala index 157c404777e..e33b7ff4db3 100644 --- a/src/main/scala/mesosphere/marathon/api/serialization/ContainerSerializer.scala +++ b/src/main/scala/mesosphere/marathon/api/serialization/ContainerSerializer.scala @@ -2,7 +2,7 @@ package mesosphere.marathon package api.serialization import mesosphere.marathon.core.externalvolume.ExternalVolumes -import mesosphere.marathon.state.Container.Docker.PortMapping +import mesosphere.marathon.state.Container.PortMapping import mesosphere.marathon.state._ import mesosphere.marathon.stream._ import org.apache.mesos @@ -214,7 +214,7 @@ object LabelsSerializer { } object PortMappingSerializer { - def toProto(mapping: Container.Docker.PortMapping): Protos.ExtendedContainerInfo.DockerInfo.PortMapping = { + def toProto(mapping: Container.PortMapping): Protos.ExtendedContainerInfo.DockerInfo.PortMapping = { val builder = Protos.ExtendedContainerInfo.DockerInfo.PortMapping.newBuilder .setContainerPort(mapping.containerPort) .setProtocol(mapping.protocol) @@ -237,7 +237,7 @@ object PortMappingSerializer { proto.getLabelsList.map { p => p.getKey -> p.getValue }(collection.breakOut) ) - def toMesos(mapping: Container.Docker.PortMapping): Seq[mesos.Protos.ContainerInfo.DockerInfo.PortMapping] = { + def toMesos(mapping: Container.PortMapping): Seq[mesos.Protos.ContainerInfo.DockerInfo.PortMapping] = { def mesosPort(protocol: String, hostPort: Int) = { mesos.Protos.ContainerInfo.DockerInfo.PortMapping.newBuilder .setContainerPort (mapping.containerPort) diff --git a/src/main/scala/mesosphere/marathon/api/v2/json/Formats.scala b/src/main/scala/mesosphere/marathon/api/v2/json/Formats.scala index f63742a2b62..a8462ef86cd 100644 --- a/src/main/scala/mesosphere/marathon/api/v2/json/Formats.scala +++ b/src/main/scala/mesosphere/marathon/api/v2/json/Formats.scala @@ -223,14 +223,14 @@ trait ContainerFormats { implicit lazy val DockerNetworkFormat: Format[DockerInfo.Network] = enumFormat(DockerInfo.Network.valueOf, str => s"$str is not a valid network type") - implicit lazy val PortMappingFormat: Format[Container.Docker.PortMapping] = ( + implicit lazy val PortMappingFormat: Format[Container.PortMapping] = ( (__ \ "containerPort").formatNullable[Int].withDefault(AppDefinition.RandomPortValue) ~ (__ \ "hostPort").formatNullable[Int] ~ (__ \ "servicePort").formatNullable[Int].withDefault(AppDefinition.RandomPortValue) ~ (__ \ "protocol").formatNullable[String].withDefault("tcp") ~ (__ \ "name").formatNullable[String] ~ (__ \ "labels").formatNullable[Map[String, String]].withDefault(Map.empty[String, String]) - )(Container.Docker.PortMapping(_, _, _, _, _, _), unlift(Container.Docker.PortMapping.unapply)) + )(Container.PortMapping(_, _, _, _, _, _), unlift(Container.PortMapping.unapply)) implicit lazy val CredentialFormat: Format[Container.Credential] = ( (__ \ "principal").format[String] ~ @@ -291,7 +291,7 @@ trait ContainerFormats { case class DockerContainerParameters( image: String, network: Option[ContainerInfo.DockerInfo.Network], - portMappings: Option[Seq[Container.Docker.PortMapping]], + portMappings: Option[Seq[Container.PortMapping]], privileged: Boolean, parameters: Seq[Parameter], credential: Option[Container.Credential], @@ -300,7 +300,7 @@ trait ContainerFormats { implicit lazy val DockerContainerParametersFormat: Format[DockerContainerParameters] = ( (__ \ "image").format[String] ~ (__ \ "network").formatNullable[DockerInfo.Network] ~ - (__ \ "portMappings").formatNullable[Seq[Container.Docker.PortMapping]] ~ + (__ \ "portMappings").formatNullable[Seq[Container.PortMapping]] ~ (__ \ "privileged").formatNullable[Boolean].withDefault(false) ~ (__ \ "parameters").formatNullable[Seq[Parameter]].withDefault(Seq.empty) ~ (__ \ "credential").formatNullable[Container.Credential] ~ diff --git a/src/main/scala/mesosphere/marathon/state/Container.scala b/src/main/scala/mesosphere/marathon/state/Container.scala index 25fbfc0ba11..e85e4c33834 100644 --- a/src/main/scala/mesosphere/marathon/state/Container.scala +++ b/src/main/scala/mesosphere/marathon/state/Container.scala @@ -1,4 +1,5 @@ -package mesosphere.marathon.state +package mesosphere.marathon +package state import com.wix.accord.dsl._ import com.wix.accord._ @@ -20,7 +21,7 @@ sealed trait Container { } // TODO(jdef): Someone should really fix this to not be Option[Seq[]] - we can't express that in protos anyways! - def portMappings: Option[Seq[Container.Docker.PortMapping]] = None + def portMappings: Option[Seq[Container.PortMapping]] = None def hostPorts: Option[Seq[Option[Int]]] = for (pms <- portMappings) yield pms.map(_.hostPort) @@ -37,7 +38,7 @@ object Container { volumes: Seq[Volume] = Seq.empty, image: String = "", network: Option[ContainerInfo.DockerInfo.Network] = None, - override val portMappings: Option[Seq[Docker.PortMapping]] = None, + override val portMappings: Option[Seq[PortMapping]] = None, privileged: Boolean = false, parameters: Seq[Parameter] = Nil, forcePullImage: Boolean = false) extends Container @@ -48,7 +49,7 @@ object Container { volumes: Seq[Volume], image: String = "", network: Option[ContainerInfo.DockerInfo.Network] = None, - portMappings: Option[Seq[Docker.PortMapping]] = None, + portMappings: Option[Seq[PortMapping]] = None, privileged: Boolean = false, parameters: Seq[Parameter] = Seq.empty, forcePullImage: Boolean = false): Docker = Docker( @@ -69,63 +70,63 @@ object Container { parameters = parameters, forcePullImage = forcePullImage) - /** - * @param containerPort The container port to expose - * @param hostPort The host port to bind - * @param servicePort The well-known port for this service - * @param protocol Layer 4 protocol to expose (i.e. "tcp", "udp" or "udp,tcp" for both). - * @param name Name of the service hosted on this port. - * @param labels This can be used to decorate the message with metadata to be - * interpreted by external applications such as firewalls. - */ - case class PortMapping( - containerPort: Int = AppDefinition.RandomPortValue, - hostPort: Option[Int] = None, // defaults to HostPortDefault for BRIDGE mode, None for USER mode - servicePort: Int = AppDefinition.RandomPortValue, - protocol: String = "tcp", - name: Option[String] = None, - labels: Map[String, String] = Map.empty[String, String]) - - object PortMapping { - val TCP = "tcp" - val UDP = "udp" - - val HostPortDefault = AppDefinition.RandomPortValue // HostPortDefault only applies when in BRIDGE mode - - implicit val uniqueProtocols: Validator[Iterable[String]] = - isTrue[Iterable[String]]("protocols must be unique.") { protocols => - protocols.size == protocols.toSet.size - } + val validDockerContainer = validator[Docker] { docker => + docker.image is notEmpty + docker.portMappings is optional(PortMapping.portMappingsValidator and PortMapping.validForDocker(docker)) + } + } - implicit val portMappingValidator = validator[PortMapping] { portMapping => - portMapping.protocol.split(',').toIterable is uniqueProtocols and every(oneOf(TCP, UDP)) - portMapping.containerPort should be >= 0 - portMapping.hostPort.each should be >= 0 - portMapping.servicePort should be >= 0 - portMapping.name is optional(matchRegexFully(PortAssignment.PortNamePattern)) + /** + * @param containerPort The container port to expose + * @param hostPort The host port to bind + * @param servicePort The well-known port for this service + * @param protocol Layer 4 protocol to expose (i.e. "tcp", "udp" or "udp,tcp" for both). + * @param name Name of the service hosted on this port. + * @param labels This can be used to decorate the message with metadata to be + * interpreted by external applications such as firewalls. + */ + case class PortMapping( + containerPort: Int = AppDefinition.RandomPortValue, + hostPort: Option[Int] = None, // defaults to HostPortDefault for BRIDGE mode, None for USER mode + servicePort: Int = AppDefinition.RandomPortValue, + protocol: String = "tcp", + name: Option[String] = None, + labels: Map[String, String] = Map.empty[String, String]) + + object PortMapping { + val TCP = "tcp" + val UDP = "udp" + + val HostPortDefault = AppDefinition.RandomPortValue // HostPortDefault only applies when in BRIDGE mode + + implicit val uniqueProtocols: Validator[Iterable[String]] = + isTrue[Iterable[String]]("protocols must be unique.") { protocols => + protocols.size == protocols.toSet.size } - def networkHostPortValidator(docker: Docker): Validator[PortMapping] = - isTrue[PortMapping]("hostPort is required for BRIDGE mode.") { pm => - docker.network match { - case Some(ContainerInfo.DockerInfo.Network.BRIDGE) => pm.hostPort.isDefined - case _ => true - } - } + implicit val portMappingValidator = validator[PortMapping] { portMapping => + portMapping.protocol.split(',').toIterable is uniqueProtocols and every(oneOf(TCP, UDP)) + portMapping.containerPort should be >= 0 + portMapping.hostPort.each should be >= 0 + portMapping.servicePort should be >= 0 + portMapping.name is optional(matchRegexFully(PortAssignment.PortNamePattern)) + } - val portMappingsValidator = validator[Seq[PortMapping]] { portMappings => - portMappings is every(valid) - portMappings is elementsAreUniqueByOptional(_.name, "Port names must be unique.") + def networkHostPortValidator(docker: Docker): Validator[PortMapping] = + isTrue[PortMapping]("hostPort is required for BRIDGE mode.") { pm => + docker.network match { + case Some(ContainerInfo.DockerInfo.Network.BRIDGE) => pm.hostPort.isDefined + case _ => true + } } - def validForDocker(docker: Docker): Validator[Seq[PortMapping]] = validator[Seq[PortMapping]] { pm => - pm is every(valid(PortMapping.networkHostPortValidator(docker))) - } + val portMappingsValidator = validator[Seq[PortMapping]] { portMappings => + portMappings is every(valid) + portMappings is elementsAreUniqueByOptional(_.name, "Port names must be unique.") } - val validDockerContainer = validator[Docker] { docker => - docker.image is notEmpty - docker.portMappings is optional(PortMapping.portMappingsValidator and PortMapping.validForDocker(docker)) + def validForDocker(docker: Docker): Validator[Seq[PortMapping]] = validator[Seq[PortMapping]] { pm => + pm is every(valid(PortMapping.networkHostPortValidator(docker))) } } diff --git a/src/main/scala/mesosphere/marathon/tasks/PortsMatcher.scala b/src/main/scala/mesosphere/marathon/tasks/PortsMatcher.scala index deed7bc9195..a997a5f3e9b 100644 --- a/src/main/scala/mesosphere/marathon/tasks/PortsMatcher.scala +++ b/src/main/scala/mesosphere/marathon/tasks/PortsMatcher.scala @@ -51,7 +51,7 @@ class PortsMatcher private[tasks] ( mappedPortRanges(requiredPorts) case app: AppDefinition => - val portMappings: Option[Seq[Container.Docker.PortMapping]] = + val portMappings: Option[Seq[Container.PortMapping]] = for { c <- app.container pms <- c.portMappings if pms.nonEmpty diff --git a/src/test/scala/mesosphere/marathon/api/v2/AppsResourceTest.scala b/src/test/scala/mesosphere/marathon/api/v2/AppsResourceTest.scala index 3b1ed0a92ee..3d1f4437d88 100644 --- a/src/test/scala/mesosphere/marathon/api/v2/AppsResourceTest.scala +++ b/src/test/scala/mesosphere/marathon/api/v2/AppsResourceTest.scala @@ -1,4 +1,5 @@ -package mesosphere.marathon.api.v2 +package mesosphere.marathon +package api.v2 import java.util import javax.ws.rs.core.Response @@ -319,7 +320,7 @@ class AppsResourceTest extends MarathonSpec with MarathonActorSupport with Match network = Some(Mesos.ContainerInfo.DockerInfo.Network.USER), image = "jdef/helpme", portMappings = Some(Seq( - Container.Docker.PortMapping(containerPort = 0, protocol = "tcp") + Container.PortMapping(containerPort = 0, protocol = "tcp") )) )), portDefinitions = Seq.empty @@ -351,7 +352,7 @@ class AppsResourceTest extends MarathonSpec with MarathonActorSupport with Match network = Some(Mesos.ContainerInfo.DockerInfo.Network.BRIDGE), image = "jdef/helpme", portMappings = Some(Seq( - Container.Docker.PortMapping(containerPort = 0, protocol = "tcp") + Container.PortMapping(containerPort = 0, protocol = "tcp") )) ) @@ -384,7 +385,7 @@ class AppsResourceTest extends MarathonSpec with MarathonActorSupport with Match versionInfo = VersionInfo.OnlyVersion(clock.now()), container = Some(container.copy( portMappings = Some(Seq( - Container.Docker.PortMapping(containerPort = 0, hostPort = Some(0), protocol = "tcp") + Container.PortMapping(containerPort = 0, hostPort = Some(0), protocol = "tcp") )) )) ), @@ -410,7 +411,7 @@ class AppsResourceTest extends MarathonSpec with MarathonActorSupport with Match network = Some(Mesos.ContainerInfo.DockerInfo.Network.USER), image = "jdef/helpme", portMappings = Some(Seq( - Container.Docker.PortMapping(containerPort = 0, protocol = "tcp") + Container.PortMapping(containerPort = 0, protocol = "tcp") )) ) ), diff --git a/src/test/scala/mesosphere/marathon/api/v2/ModelValidationTest.scala b/src/test/scala/mesosphere/marathon/api/v2/ModelValidationTest.scala index e3f2ab336f0..e8b060554c0 100644 --- a/src/test/scala/mesosphere/marathon/api/v2/ModelValidationTest.scala +++ b/src/test/scala/mesosphere/marathon/api/v2/ModelValidationTest.scala @@ -1,10 +1,10 @@ -package mesosphere.marathon.api.v2 +package mesosphere.marathon +package api.v2 import com.wix.accord._ import com.wix.accord.dsl._ import mesosphere.marathon.api.v2.Validation._ import mesosphere.marathon.api.v2.json.GroupUpdate -import mesosphere.marathon.state.Container.Docker.PortMapping import mesosphere.marathon.state.Container._ import mesosphere.marathon.state.PathId._ import mesosphere.marathon.state._ diff --git a/src/test/scala/mesosphere/marathon/api/v2/json/AppDefinitionFormatsTest.scala b/src/test/scala/mesosphere/marathon/api/v2/json/AppDefinitionFormatsTest.scala index 35621ba44c9..422a20e8858 100644 --- a/src/test/scala/mesosphere/marathon/api/v2/json/AppDefinitionFormatsTest.scala +++ b/src/test/scala/mesosphere/marathon/api/v2/json/AppDefinitionFormatsTest.scala @@ -1,4 +1,5 @@ -package mesosphere.marathon.api.v2.json +package mesosphere.marathon +package api.v2.json import mesosphere.marathon.Protos import mesosphere.marathon.Protos.Constraint @@ -329,7 +330,7 @@ class AppDefinitionFormatsTest appDef.container.get shouldBe a[Container.Docker] appDef.container.flatMap(_.docker.flatMap(_.network.map(_.toString))) should equal (Some("USER")) appDef.container.flatMap(_.portMappings) should equal (Some(Seq( - Container.Docker.PortMapping(containerPort = 123, servicePort = 80, name = Some("foobar")) + Container.PortMapping(containerPort = 123, servicePort = 80, name = Some("foobar")) ))) } diff --git a/src/test/scala/mesosphere/marathon/api/v2/json/AppDefinitionTest.scala b/src/test/scala/mesosphere/marathon/api/v2/json/AppDefinitionTest.scala index 98eeba3f335..0aa3811ad05 100644 --- a/src/test/scala/mesosphere/marathon/api/v2/json/AppDefinitionTest.scala +++ b/src/test/scala/mesosphere/marathon/api/v2/json/AppDefinitionTest.scala @@ -1,4 +1,5 @@ -package mesosphere.marathon.api.v2.json +package mesosphere.marathon +package api.v2.json import com.wix.accord._ import mesosphere.marathon.Protos @@ -10,6 +11,7 @@ import mesosphere.marathon.core.plugin.PluginManager import mesosphere.marathon.core.readiness.ReadinessCheckTestHelper import mesosphere.marathon.raml.Resources import mesosphere.marathon.state.Container.Docker +import mesosphere.marathon.state.Container.PortMapping import mesosphere.marathon.state.DiscoveryInfo.Port import mesosphere.marathon.state.EnvVarValue._ import mesosphere.marathon.state.PathId._ @@ -108,8 +110,8 @@ class AppDefinitionTest extends MarathonSpec with Matchers { image = "mesosphere/marathon", network = Some(mesos.ContainerInfo.DockerInfo.Network.BRIDGE), portMappings = Some(Seq( - Docker.PortMapping(8080, Some(0), 0, "tcp", Some("foo")), - Docker.PortMapping(8081, Some(0), 0, "tcp", Some("foo")) + PortMapping(8080, Some(0), 0, "tcp", Some("foo")), + PortMapping(8081, Some(0), 0, "tcp", Some("foo")) )) )), portDefinitions = Nil @@ -140,8 +142,8 @@ class AppDefinitionTest extends MarathonSpec with Matchers { container = Some(Docker( image = "mesosphere/marathon", portMappings = Some(Seq( - Docker.PortMapping(8080, Some(0), 0, "tcp", Some("foo")), - Docker.PortMapping(8081, Some(0), 0, "tcp", Some("bar")) + PortMapping(8080, Some(0), 0, "tcp", Some("foo")), + PortMapping(8081, Some(0), 0, "tcp", Some("bar")) )) )), portDefinitions = Nil) @@ -156,7 +158,7 @@ class AppDefinitionTest extends MarathonSpec with Matchers { image = "mesosphere/marathon", network = Some(mesos.ContainerInfo.DockerInfo.Network.USER), portMappings = Some(Seq( - Docker.PortMapping(8080, None, 0, "tcp", Some("foo")) + PortMapping(8080, None, 0, "tcp", Some("foo")) )) )), portDefinitions = Nil) @@ -171,7 +173,7 @@ class AppDefinitionTest extends MarathonSpec with Matchers { image = "mesosphere/marathon", network = Some(mesos.ContainerInfo.DockerInfo.Network.BRIDGE), portMappings = Some(Seq( - Docker.PortMapping(8080, None, 0, "tcp", Some("foo")) + PortMapping(8080, None, 0, "tcp", Some("foo")) )) )), portDefinitions = Nil) @@ -186,8 +188,8 @@ class AppDefinitionTest extends MarathonSpec with Matchers { image = "mesosphere/marathon", network = Some(mesos.ContainerInfo.DockerInfo.Network.USER), portMappings = Some(Seq( - Docker.PortMapping(8080, Some(0), 0, "tcp", Some("foo")), - Docker.PortMapping(8081, Some(0), 0, "tcp", Some("bar")) + PortMapping(8080, Some(0), 0, "tcp", Some("foo")), + PortMapping(8081, Some(0), 0, "tcp", Some("bar")) )) )), portDefinitions = Nil) @@ -203,8 +205,8 @@ class AppDefinitionTest extends MarathonSpec with Matchers { image = "mesosphere/marathon", network = Some(mesos.ContainerInfo.DockerInfo.Network.USER), portMappings = Some(Seq( - Docker.PortMapping(8080, Some(0), 0, "tcp", Some("foo")), - Docker.PortMapping(8081, Some(0), 0, "tcp", Some("foo")) + PortMapping(8080, Some(0), 0, "tcp", Some("foo")), + PortMapping(8081, Some(0), 0, "tcp", Some("foo")) )) )), portDefinitions = Nil) @@ -326,8 +328,8 @@ class AppDefinitionTest extends MarathonSpec with Matchers { container = Some(Docker( network = Some(mesos.ContainerInfo.DockerInfo.Network.BRIDGE), portMappings = Some(Seq( - Docker.PortMapping(8080, Some(0), 0, "tcp"), - Docker.PortMapping(8081, Some(0), 0, "tcp") + PortMapping(8080, Some(0), 0, "tcp"), + PortMapping(8081, Some(0), 0, "tcp") )) )), portDefinitions = Nil, @@ -645,7 +647,6 @@ class AppDefinitionTest extends MarathonSpec with Matchers { } test("Read app with container definition and port mappings") { - import mesosphere.marathon.state.Container.Docker.PortMapping import org.apache.mesos.Protos.ContainerInfo.DockerInfo.Network val app4 = AppDefinition( diff --git a/src/test/scala/mesosphere/marathon/api/v2/json/AppUpdateTest.scala b/src/test/scala/mesosphere/marathon/api/v2/json/AppUpdateTest.scala index 6380e3054ca..4e43b33340d 100644 --- a/src/test/scala/mesosphere/marathon/api/v2/json/AppUpdateTest.scala +++ b/src/test/scala/mesosphere/marathon/api/v2/json/AppUpdateTest.scala @@ -1,4 +1,5 @@ -package mesosphere.marathon.api.v2.json +package mesosphere.marathon +package api.v2.json import com.wix.accord._ import mesosphere.marathon.api.JsonTestHelper @@ -223,7 +224,7 @@ class AppUpdateTest extends MarathonSpec with Matchers { assert(AppUpdate(id = Some("foo".toPath), version = Some(Timestamp.now())).onlyVersionOrIdSet) - intercept[Exception] { + intercept[IllegalArgumentException] { AppUpdate(cmd = Some("foo"), version = Some(Timestamp.now())) } } @@ -570,7 +571,7 @@ class AppUpdateTest extends MarathonSpec with Matchers { test("container change in AppUpdate should be stored") { val appDef = AppDefinition(id = runSpecId, container = Some(Docker(portMappings = None))) val appUpdate = AppUpdate(container = Some(Docker(portMappings = Some(Seq( - Container.Docker.PortMapping(containerPort = 4000, protocol = "tcp") + Container.PortMapping(containerPort = 4000, protocol = "tcp") ))))) val roundTrip = appUpdate(appDef) roundTrip.container.get.portMappings should not be None diff --git a/src/test/scala/mesosphere/marathon/api/validation/AppUpdateValidatorTest.scala b/src/test/scala/mesosphere/marathon/api/validation/AppUpdateValidatorTest.scala index cd88011ee60..6d88d94776d 100644 --- a/src/test/scala/mesosphere/marathon/api/validation/AppUpdateValidatorTest.scala +++ b/src/test/scala/mesosphere/marathon/api/validation/AppUpdateValidatorTest.scala @@ -6,7 +6,7 @@ import mesosphere.UnitTest import mesosphere.marathon.api.v2.json.AppUpdate import mesosphere.marathon.api.v2.json.Formats._ import mesosphere.marathon.core.plugin.PluginManager -import mesosphere.marathon.state.Container.Docker +import mesosphere.marathon.state.Container.PortMapping import mesosphere.marathon.state.{ AppDefinition, Container, PathId } import org.scalatest.Matchers import play.api.libs.json.Json @@ -111,7 +111,7 @@ class AppUpdateValidatorTest extends UnitTest with Matchers { class Fixture { def invalidDockerContainer: Container = Container.Docker( portMappings = Some(Seq( - Docker.PortMapping(-1, Some(-1), -1, "tcp") // Invalid (negative) port numbers + PortMapping(-1, Some(-1), -1, "tcp") // Invalid (negative) port numbers )) ) diff --git a/src/test/scala/mesosphere/marathon/core/group/impl/GroupManagerActorTest.scala b/src/test/scala/mesosphere/marathon/core/group/impl/GroupManagerActorTest.scala index 79cb5b68419..7538cbe35fe 100644 --- a/src/test/scala/mesosphere/marathon/core/group/impl/GroupManagerActorTest.scala +++ b/src/test/scala/mesosphere/marathon/core/group/impl/GroupManagerActorTest.scala @@ -1,4 +1,5 @@ -package mesosphere.marathon.core.group.impl +package mesosphere.marathon +package core.group.impl import java.util.concurrent.atomic.AtomicInteger import javax.inject.Provider @@ -57,8 +58,7 @@ class GroupManagerActorTest extends Mockito with Matchers with MarathonSpec { } test("Assign dynamic service ports specified in the container") { - import Container.Docker - import Docker.PortMapping + import Container.{ Docker, PortMapping } import org.apache.mesos.Protos.ContainerInfo.DockerInfo.Network val container = Docker( image = "busybox", @@ -82,8 +82,7 @@ class GroupManagerActorTest extends Mockito with Matchers with MarathonSpec { } test("Assign dynamic service ports specified in multiple containers") { - import Container.Docker - import Docker.PortMapping + import Container.{ Docker, PortMapping } import org.apache.mesos.Protos.ContainerInfo.DockerInfo.Network val c1 = Some(Docker( image = "busybox", @@ -113,8 +112,7 @@ class GroupManagerActorTest extends Mockito with Matchers with MarathonSpec { } test("Assign dynamic service ports w/ both BRIDGE and USER containers") { - import Container.Docker - import Docker.PortMapping + import Container.{ Docker, PortMapping } import org.apache.mesos.Protos.ContainerInfo.DockerInfo.Network val bridgeModeContainer = Some(Docker( image = "busybox", @@ -152,8 +150,7 @@ class GroupManagerActorTest extends Mockito with Matchers with MarathonSpec { } test("Assign a service port for an app using Docker USER networking with a default port mapping") { - import Container.Docker - import Docker.PortMapping + import Container.{ Docker, PortMapping } import org.apache.mesos.Protos.ContainerInfo.DockerInfo.Network val c1 = Some(Docker( image = "busybox", @@ -183,8 +180,7 @@ class GroupManagerActorTest extends Mockito with Matchers with MarathonSpec { // Regression test for #1365 test("Export non-dynamic service ports specified in the container to the ports field") { - import Container.Docker - import Docker.PortMapping + import Container.{ Docker, PortMapping } import org.apache.mesos.Protos.ContainerInfo.DockerInfo.Network val container = Docker( image = "busybox", diff --git a/src/test/scala/mesosphere/marathon/core/health/MesosHealthCheckTest.scala b/src/test/scala/mesosphere/marathon/core/health/MesosHealthCheckTest.scala index 88a8da72acf..83cbfa498ac 100644 --- a/src/test/scala/mesosphere/marathon/core/health/MesosHealthCheckTest.scala +++ b/src/test/scala/mesosphere/marathon/core/health/MesosHealthCheckTest.scala @@ -1,4 +1,5 @@ -package mesosphere.marathon.core.health +package mesosphere.marathon +package core.health import com.wix.accord.validate import mesosphere.marathon.Protos @@ -7,7 +8,7 @@ import mesosphere.marathon.api.JsonTestHelper import mesosphere.marathon.api.v2.ValidationHelper import mesosphere.marathon.api.v2.json.Formats.HealthCheckFormat import mesosphere.marathon.core.task.Task -import mesosphere.marathon.state.Container.Docker +import mesosphere.marathon.state.Container.PortMapping import mesosphere.marathon.state._ import mesosphere.marathon.test.{ MarathonSpec, MarathonTestHelper } import mesosphere.mesos.TaskBuilder @@ -448,7 +449,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.BRIDGE) .withPortMappings(Seq( - Docker.PortMapping(containerPort = 80, hostPort = Some(0), servicePort = 0, protocol = "tcp", + PortMapping(containerPort = 80, hostPort = Some(0), servicePort = 0, protocol = "tcp", name = Some("http")) )) .withHealthCheck(mesosHttpHealthCheckWithPortIndex) @@ -467,7 +468,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.BRIDGE) .withPortMappings(Seq( - Docker.PortMapping(containerPort = 8080, hostPort = Some(0), servicePort = 0, protocol = "tcp", + PortMapping(containerPort = 8080, hostPort = Some(0), servicePort = 0, protocol = "tcp", name = Some("http")) )) .withHealthCheck(mesosHttpHealthCheckWithPort) @@ -486,7 +487,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withIpAddress(IpAddress.empty) .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.USER) - .withPortMappings(Seq(Docker.PortMapping(containerPort = 80, hostPort = None))) + .withPortMappings(Seq(PortMapping(containerPort = 80, hostPort = None))) .withHealthCheck(mesosHttpHealthCheckWithPortIndex) val task: Option[(MesosProtos.TaskInfo, Seq[Option[Int]])] = buildIfMatches(app) @@ -502,7 +503,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withIpAddress(IpAddress.empty) .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.USER) - .withPortMappings(Seq(Docker.PortMapping(containerPort = 80, hostPort = Some(0)))) + .withPortMappings(Seq(PortMapping(containerPort = 80, hostPort = Some(0)))) .withHealthCheck(mesosHttpHealthCheckWithPortIndex) val task: Option[(MesosProtos.TaskInfo, Seq[Option[Int]])] = buildIfMatches(app) @@ -519,7 +520,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withIpAddress(IpAddress.empty) .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.USER) - .withPortMappings(Seq(Docker.PortMapping(containerPort = 31337, hostPort = Some(0)))) + .withPortMappings(Seq(PortMapping(containerPort = 31337, hostPort = Some(0)))) .withHealthCheck(mesosHttpHealthCheckWithPort) val task: Option[(MesosProtos.TaskInfo, Seq[Option[Int]])] = buildIfMatches(app) @@ -632,7 +633,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.BRIDGE) .withPortMappings(Seq( - Docker.PortMapping(containerPort = 80, hostPort = Some(0), servicePort = 0, protocol = "tcp", + PortMapping(containerPort = 80, hostPort = Some(0), servicePort = 0, protocol = "tcp", name = Some("http")) )) .withHealthCheck(mesosTcpHealthCheckWithPortIndex) @@ -651,7 +652,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.BRIDGE) .withPortMappings(Seq( - Docker.PortMapping(containerPort = 8080, hostPort = Some(0), servicePort = 0, protocol = "tcp", + PortMapping(containerPort = 8080, hostPort = Some(0), servicePort = 0, protocol = "tcp", name = Some("http")) )) .withHealthCheck(mesosTcpHealthCheckWithPort) @@ -670,7 +671,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withIpAddress(IpAddress.empty) .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.USER) - .withPortMappings(Seq(Docker.PortMapping(containerPort = 80, hostPort = None))) + .withPortMappings(Seq(PortMapping(containerPort = 80, hostPort = None))) .withHealthCheck(mesosTcpHealthCheckWithPortIndex) val task: Option[(MesosProtos.TaskInfo, Seq[Option[Int]])] = buildIfMatches(app) @@ -686,7 +687,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withIpAddress(IpAddress.empty) .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.USER) - .withPortMappings(Seq(Docker.PortMapping(containerPort = 80, hostPort = Some(0)))) + .withPortMappings(Seq(PortMapping(containerPort = 80, hostPort = Some(0)))) .withHealthCheck(mesosTcpHealthCheckWithPortIndex) val task: Option[(MesosProtos.TaskInfo, Seq[Option[Int]])] = buildIfMatches(app) @@ -703,7 +704,7 @@ class MesosHealthCheckTest extends MarathonSpec { .withNoPortDefinitions() .withIpAddress(IpAddress.empty) .withDockerNetwork(MesosProtos.ContainerInfo.DockerInfo.Network.USER) - .withPortMappings(Seq(Docker.PortMapping(containerPort = 31337, hostPort = Some(0)))) + .withPortMappings(Seq(PortMapping(containerPort = 31337, hostPort = Some(0)))) .withHealthCheck(mesosTcpHealthCheckWithPort) val task: Option[(MesosProtos.TaskInfo, Seq[Option[Int]])] = buildIfMatches(app) diff --git a/src/test/scala/mesosphere/marathon/integration/AppDeployIntegrationTest.scala b/src/test/scala/mesosphere/marathon/integration/AppDeployIntegrationTest.scala index 6bcd4fcd1c6..84eff0a9319 100644 --- a/src/test/scala/mesosphere/marathon/integration/AppDeployIntegrationTest.scala +++ b/src/test/scala/mesosphere/marathon/integration/AppDeployIntegrationTest.scala @@ -1,8 +1,8 @@ -package mesosphere.marathon.integration +package mesosphere.marathon +package integration import java.util.UUID -import mesosphere.marathon.Protos import mesosphere.marathon.Protos.Constraint.Operator import mesosphere.marathon.Protos.HealthCheckDefinition.Protocol import mesosphere.marathon.api.v2.json.AppUpdate @@ -649,7 +649,7 @@ class AppDeployIntegrationTest network = Some(org.apache.mesos.Protos.ContainerInfo.DockerInfo.Network.BRIDGE), image = "jdef/helpme", portMappings = Some(Seq( - Container.Docker.PortMapping(containerPort = 3000, protocol = "tcp") + Container.PortMapping(containerPort = 3000, protocol = "tcp") )) ) @@ -669,7 +669,7 @@ class AppDeployIntegrationTest waitForEvent("deployment_success") val appUpdate = AppUpdate(container = Some(container.copy(portMappings = Some(Seq( - Container.Docker.PortMapping(containerPort = 4000, protocol = "tcp") + Container.PortMapping(containerPort = 4000, protocol = "tcp") ))))) val updateResult = marathon.updateApp(app.id, appUpdate, true) diff --git a/src/test/scala/mesosphere/marathon/integration/facades/MarathonFacade.scala b/src/test/scala/mesosphere/marathon/integration/facades/MarathonFacade.scala index 6ca92fd28fd..a9facd3860d 100644 --- a/src/test/scala/mesosphere/marathon/integration/facades/MarathonFacade.scala +++ b/src/test/scala/mesosphere/marathon/integration/facades/MarathonFacade.scala @@ -366,7 +366,7 @@ class MarathonFacade(url: String, baseGroup: PathId, waitTime: Duration = 30.sec } object MarathonFacade { - def extractDeploymentIds(app: RestResult[AppDefinition]): scala.collection.Seq[String] = { + def extractDeploymentIds(app: RestResult[AppDefinition]): Seq[String] = { try { for (deployment <- (app.entityJson \ "deployments").as[JsArray].value) yield (deployment \ "id").as[String] @@ -374,5 +374,5 @@ object MarathonFacade { case NonFatal(e) => throw new RuntimeException(s"while parsing:\n${app.entityPrettyJsonString}", e) } - } + }.toIndexedSeq } diff --git a/src/test/scala/mesosphere/marathon/integration/setup/MarathonCallbackTestSupport.scala b/src/test/scala/mesosphere/marathon/integration/setup/MarathonCallbackTestSupport.scala index 3ba439e5000..5396f16eac0 100644 --- a/src/test/scala/mesosphere/marathon/integration/setup/MarathonCallbackTestSupport.scala +++ b/src/test/scala/mesosphere/marathon/integration/setup/MarathonCallbackTestSupport.scala @@ -1,4 +1,5 @@ -package mesosphere.marathon.integration.setup +package mesosphere.marathon +package integration.setup import java.util.concurrent.ConcurrentLinkedQueue diff --git a/src/test/scala/mesosphere/marathon/state/AppDefinitionPortAssignmentsTest.scala b/src/test/scala/mesosphere/marathon/state/AppDefinitionPortAssignmentsTest.scala index f5f4f2011ae..e3c00140bbf 100644 --- a/src/test/scala/mesosphere/marathon/state/AppDefinitionPortAssignmentsTest.scala +++ b/src/test/scala/mesosphere/marathon/state/AppDefinitionPortAssignmentsTest.scala @@ -1,7 +1,8 @@ -package mesosphere.marathon.state +package mesosphere.marathon +package state import mesosphere.marathon.core.instance.TestTaskBuilder -import mesosphere.marathon.state.Container.Docker +import mesosphere.marathon.state.Container.PortMapping import mesosphere.marathon.test.MarathonTestHelper import org.apache.mesos.Protos import org.scalatest.{ FunSuiteLike, GivenWhenThen, Matchers, OptionValues } @@ -91,7 +92,7 @@ class AppDefinitionPortAssignmentsTest extends FunSuiteLike with GivenWhenThen w .withNoPortDefinitions() .withDockerNetwork(Protos.ContainerInfo.DockerInfo.Network.BRIDGE) .withPortMappings(Seq( - Docker.PortMapping(containerPort = 80, hostPort = Some(0), servicePort = 0, protocol = "tcp", + PortMapping(containerPort = 80, hostPort = Some(0), servicePort = 0, protocol = "tcp", name = Some("http")) )) @@ -134,7 +135,7 @@ class AppDefinitionPortAssignmentsTest extends FunSuiteLike with GivenWhenThen w .withIpAddress(IpAddress.empty) .withDockerNetwork(Protos.ContainerInfo.DockerInfo.Network.USER) .withPortMappings(Seq( - Docker.PortMapping(containerPort = 80, hostPort = None, servicePort = 0, protocol = "tcp", name = Some("http")) + PortMapping(containerPort = 80, hostPort = None, servicePort = 0, protocol = "tcp", name = Some("http")) )) Given("A task with an IP and without a host port") @@ -163,7 +164,7 @@ class AppDefinitionPortAssignmentsTest extends FunSuiteLike with GivenWhenThen w .withIpAddress(IpAddress.empty) .withDockerNetwork(Protos.ContainerInfo.DockerInfo.Network.USER) .withPortMappings(Seq( - Docker.PortMapping(containerPort = 80, hostPort = Some(0), servicePort = 0, protocol = "tcp", + PortMapping(containerPort = 80, hostPort = Some(0), servicePort = 0, protocol = "tcp", name = Some("http")) )) @@ -193,8 +194,8 @@ class AppDefinitionPortAssignmentsTest extends FunSuiteLike with GivenWhenThen w .withIpAddress(IpAddress.empty) .withDockerNetwork(Protos.ContainerInfo.DockerInfo.Network.USER) .withPortMappings(Seq( - Docker.PortMapping(containerPort = 80, hostPort = None, servicePort = 0, protocol = "tcp", name = Some("http")), - Docker.PortMapping(containerPort = 443, hostPort = Some(0), servicePort = 0, protocol = "tcp", + PortMapping(containerPort = 80, hostPort = None, servicePort = 0, protocol = "tcp", name = Some("http")), + PortMapping(containerPort = 443, hostPort = Some(0), servicePort = 0, protocol = "tcp", name = Some("https")) )) @@ -229,9 +230,9 @@ class AppDefinitionPortAssignmentsTest extends FunSuiteLike with GivenWhenThen w .withNoPortDefinitions() .withDockerNetwork(Protos.ContainerInfo.DockerInfo.Network.USER) .withPortMappings(Seq( - Docker.PortMapping(containerPort = 80, hostPort = None, servicePort = 0, protocol = "tcp", + PortMapping(containerPort = 80, hostPort = None, servicePort = 0, protocol = "tcp", name = Some("http")), - Docker.PortMapping(containerPort = 443, hostPort = Some(0), servicePort = 0, protocol = "tcp", + PortMapping(containerPort = 443, hostPort = Some(0), servicePort = 0, protocol = "tcp", name = Some("https")) )) diff --git a/src/test/scala/mesosphere/marathon/state/AppDefinitionTest.scala b/src/test/scala/mesosphere/marathon/state/AppDefinitionTest.scala index 5e66b7d6d42..70944d31cc1 100644 --- a/src/test/scala/mesosphere/marathon/state/AppDefinitionTest.scala +++ b/src/test/scala/mesosphere/marathon/state/AppDefinitionTest.scala @@ -149,9 +149,9 @@ class AppDefinitionTest extends MarathonSpec with Matchers { image = "jdef/foo", network = Some(mesos.ContainerInfo.DockerInfo.Network.USER), portMappings = Some(Seq( - Container.Docker.PortMapping(hostPort = None), - Container.Docker.PortMapping(hostPort = Some(123)), - Container.Docker.PortMapping(containerPort = 1, hostPort = Some(234), protocol = "udp") + Container.PortMapping(hostPort = None), + Container.PortMapping(hostPort = Some(123)), + Container.PortMapping(containerPort = 1, hostPort = Some(234), protocol = "udp") )) )) ) @@ -173,9 +173,9 @@ class AppDefinitionTest extends MarathonSpec with Matchers { image = "jdef/foo", network = Some(mesos.ContainerInfo.DockerInfo.Network.BRIDGE), portMappings = Some(Seq( - Container.Docker.PortMapping(hostPort = Some(0)), - Container.Docker.PortMapping(hostPort = Some(123)), - Container.Docker.PortMapping(containerPort = 1, hostPort = Some(234), protocol = "udp") + Container.PortMapping(hostPort = Some(0)), + Container.PortMapping(hostPort = Some(123)), + Container.PortMapping(containerPort = 1, hostPort = Some(234), protocol = "udp") )) )) ) diff --git a/src/test/scala/mesosphere/marathon/state/PortMappingTest.scala b/src/test/scala/mesosphere/marathon/state/PortMappingTest.scala index b6ae4d488e7..71f0c06f54d 100644 --- a/src/test/scala/mesosphere/marathon/state/PortMappingTest.scala +++ b/src/test/scala/mesosphere/marathon/state/PortMappingTest.scala @@ -1,11 +1,12 @@ -package mesosphere.marathon.state +package mesosphere.marathon +package state import com.wix.accord._ -import mesosphere.marathon.state.Container.Docker.PortMapping +import mesosphere.marathon.state.Container.PortMapping import org.scalatest.{ FunSuiteLike, Matchers } class PortMappingTest extends FunSuiteLike with Matchers { - import mesosphere.marathon.state.Container.Docker.PortMapping.portMappingValidator + import mesosphere.marathon.state.Container.PortMapping.portMappingValidator test("valid portMapping should be valid") { validate(Fixture.validPortMapping) should be(Success) diff --git a/src/test/scala/mesosphere/marathon/tasks/PortsMatcherTest.scala b/src/test/scala/mesosphere/marathon/tasks/PortsMatcherTest.scala index 57c114f2982..6083c55de02 100644 --- a/src/test/scala/mesosphere/marathon/tasks/PortsMatcherTest.scala +++ b/src/test/scala/mesosphere/marathon/tasks/PortsMatcherTest.scala @@ -1,8 +1,9 @@ -package mesosphere.marathon.tasks +package mesosphere.marathon +package tasks import java.util -import mesosphere.marathon.state.Container.Docker +import mesosphere.marathon.state.Container.{ Docker, PortMapping } import mesosphere.marathon.state.{ AppDefinition, PathId, PortDefinitions, ResourceRole } import mesosphere.marathon.tasks.PortsMatcher.PortWithRole import mesosphere.marathon.test.{ MarathonSpec, MarathonTestHelper } @@ -157,7 +158,7 @@ class PortsMatcherTest extends MarathonSpec with Matchers { test("fail if dynamic mapped port from container cannot be satisfied") { val app = AppDefinition(id = runSpecId, container = Some(Docker( portMappings = Some(Seq( - new Docker.PortMapping(containerPort = 1, hostPort = Some(0)) + new PortMapping(containerPort = 1, hostPort = Some(0)) )) ))) @@ -170,7 +171,7 @@ class PortsMatcherTest extends MarathonSpec with Matchers { test("satisfy dynamic mapped port from container") { val app = AppDefinition(id = runSpecId, container = Some(Docker( portMappings = Some(Seq( - new Docker.PortMapping(containerPort = 1, hostPort = Some(0)) + new PortMapping(containerPort = 1, hostPort = Some(0)) )) ))) @@ -184,7 +185,7 @@ class PortsMatcherTest extends MarathonSpec with Matchers { test("randomly satisfy dynamic mapped port from container") { val app = AppDefinition(id = runSpecId, container = Some(Docker( portMappings = Some(Seq( - new Docker.PortMapping(containerPort = 1, hostPort = Some(0)) + new PortMapping(containerPort = 1, hostPort = Some(0)) )) ))) @@ -215,7 +216,7 @@ class PortsMatcherTest extends MarathonSpec with Matchers { test("fail if fixed mapped port from container cannot be satisfied") { val app = AppDefinition(id = runSpecId, container = Some(Docker( portMappings = Some(Seq( - new Docker.PortMapping(containerPort = 1, hostPort = Some(8080)) + new PortMapping(containerPort = 1, hostPort = Some(8080)) )) ))) @@ -228,7 +229,7 @@ class PortsMatcherTest extends MarathonSpec with Matchers { test("satisfy fixed mapped port from container") { val app = AppDefinition(id = runSpecId, container = Some(Docker( portMappings = Some(Seq( - new Docker.PortMapping(containerPort = 1, hostPort = Some(31200)) + new PortMapping(containerPort = 1, hostPort = Some(31200)) )) ))) @@ -242,7 +243,7 @@ class PortsMatcherTest extends MarathonSpec with Matchers { test("do not satisfy fixed mapped port from container with resource offer of incorrect role") { val app = AppDefinition(id = runSpecId, container = Some(Docker( portMappings = Some(Seq( - new Docker.PortMapping(containerPort = 1, hostPort = Some(31200)) + new PortMapping(containerPort = 1, hostPort = Some(31200)) )) ))) @@ -261,8 +262,8 @@ class PortsMatcherTest extends MarathonSpec with Matchers { test("satisfy fixed and dynamic mapped port from container from one offered range") { val app = AppDefinition(id = runSpecId, container = Some(Docker( portMappings = Some(Seq( - new Docker.PortMapping(containerPort = 1, hostPort = Some(0)), - new Docker.PortMapping(containerPort = 1, hostPort = Some(31000)) + new PortMapping(containerPort = 1, hostPort = Some(0)), + new PortMapping(containerPort = 1, hostPort = Some(31000)) )) ))) @@ -276,8 +277,8 @@ class PortsMatcherTest extends MarathonSpec with Matchers { test("satisfy fixed and dynamic mapped port from container from ranges with different roles") { val app = AppDefinition(id = runSpecId, container = Some(Docker( portMappings = Some(Seq( - new Docker.PortMapping(containerPort = 1, hostPort = Some(0)), - new Docker.PortMapping(containerPort = 1, hostPort = Some(31000)) + new PortMapping(containerPort = 1, hostPort = Some(0)), + new PortMapping(containerPort = 1, hostPort = Some(31000)) )) ))) diff --git a/src/test/scala/mesosphere/marathon/test/MarathonTestHelper.scala b/src/test/scala/mesosphere/marathon/test/MarathonTestHelper.scala index 4eab4824445..62857503139 100644 --- a/src/test/scala/mesosphere/marathon/test/MarathonTestHelper.scala +++ b/src/test/scala/mesosphere/marathon/test/MarathonTestHelper.scala @@ -22,7 +22,7 @@ import mesosphere.marathon.core.task.tracker.{ InstanceTracker, InstanceTrackerM import mesosphere.marathon.metrics.Metrics import mesosphere.marathon.raml.Resources import mesosphere.marathon.state.Container.Docker -import mesosphere.marathon.state.Container.Docker.PortMapping +import mesosphere.marathon.state.Container.PortMapping import mesosphere.marathon.state.PathId._ import mesosphere.marathon.state._ import mesosphere.marathon.storage.repository.legacy.store.{ InMemoryStore, MarathonStore, PersistentStore } diff --git a/src/test/scala/mesosphere/mesos/ResourceMatcherTest.scala b/src/test/scala/mesosphere/mesos/ResourceMatcherTest.scala index 910667caf14..1fc817ee931 100644 --- a/src/test/scala/mesosphere/mesos/ResourceMatcherTest.scala +++ b/src/test/scala/mesosphere/mesos/ResourceMatcherTest.scala @@ -79,8 +79,8 @@ class ResourceMatcherTest extends MarathonSpec with Matchers with Inside { image = "foo/bar", network = Some(ContainerInfo.DockerInfo.Network.BRIDGE), portMappings = Some(Seq( - Container.Docker.PortMapping(31001, Some(0), 0, "tcp", Some("qax")), - Container.Docker.PortMapping(31002, Some(0), 0, "tcp", Some("qab")) + Container.PortMapping(31001, Some(0), 0, "tcp", Some("qax")), + Container.PortMapping(31002, Some(0), 0, "tcp", Some("qab")) )) )) ) @@ -107,9 +107,9 @@ class ResourceMatcherTest extends MarathonSpec with Matchers with Inside { image = "foo/bar", network = Some(ContainerInfo.DockerInfo.Network.USER), portMappings = Some(Seq( - Container.Docker.PortMapping(0, Some(0), 0, "tcp", Some("yas")), - Container.Docker.PortMapping(31001, None, 0, "tcp", Some("qax")), - Container.Docker.PortMapping(31002, Some(0), 0, "tcp", Some("qab")) + Container.PortMapping(0, Some(0), 0, "tcp", Some("yas")), + Container.PortMapping(31001, None, 0, "tcp", Some("qax")), + Container.PortMapping(31002, Some(0), 0, "tcp", Some("qab")) )) )) ) diff --git a/src/test/scala/mesosphere/mesos/TaskBuilderTest.scala b/src/test/scala/mesosphere/mesos/TaskBuilderTest.scala index b1487f91fd1..aa48ebbc63a 100644 --- a/src/test/scala/mesosphere/mesos/TaskBuilderTest.scala +++ b/src/test/scala/mesosphere/mesos/TaskBuilderTest.scala @@ -6,8 +6,7 @@ import mesosphere.marathon.api.serialization.PortDefinitionSerializer import mesosphere.marathon.core.instance.{ Instance, TestInstanceBuilder } import mesosphere.marathon.core.task.Task import mesosphere.marathon.raml.Resources -import mesosphere.marathon.state.Container.Docker -import mesosphere.marathon.state.Container.Docker.PortMapping +import mesosphere.marathon.state.Container.{ Docker, PortMapping } import mesosphere.marathon.state.PathId._ import mesosphere.marathon.state.VersionInfo.OnlyVersion import mesosphere.marathon.state.{ AppDefinition, Container, PathId, Timestamp, _ } @@ -1657,12 +1656,12 @@ class TaskBuilderTest extends MarathonSpec with Matchers { network = Some(MesosProtos.ContainerInfo.DockerInfo.Network.USER), portMappings = Some(Seq( // order is important here since it impacts the specific assertions that follow - Container.Docker.PortMapping(containerPort = 0, hostPort = None), - Container.Docker.PortMapping(containerPort = 100, hostPort = Some(0)), - Container.Docker.PortMapping(containerPort = 200, hostPort = Some(25002)), - Container.Docker.PortMapping(containerPort = 0, hostPort = Some(25001)), - Container.Docker.PortMapping(containerPort = 400, hostPort = None), - Container.Docker.PortMapping(containerPort = 0, hostPort = Some(0)) + Container.PortMapping(containerPort = 0, hostPort = None), + Container.PortMapping(containerPort = 100, hostPort = Some(0)), + Container.PortMapping(containerPort = 200, hostPort = Some(25002)), + Container.PortMapping(containerPort = 0, hostPort = Some(25001)), + Container.PortMapping(containerPort = 400, hostPort = None), + Container.PortMapping(containerPort = 0, hostPort = Some(0)) )) )), ipAddress = Some(IpAddress(networkName = Some("vnet"))),