Skip to content

Commit

Permalink
fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Achref Hawech committed Jan 28, 2021
1 parent b1d2d36 commit c994ff4
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ case class NetworkInfo(
import NetworkInfo._

/**
* compute the effective IP address based on whether the runSpec declares container-mode networking; if so
* then choose the first address from the list provided by Mesos. Otherwise, in host- and bridge-mode
* networking just use the agent hostname as the effective IP.
*
* we assume that container-mode networking is exclusive of bridge-mode networking.
* compute the effective IP address; choose the first address from the list provided by Mesos if it's not empty.
* Otherwise,just use the agent hostname as the effective IP.
*/
def effectiveIpAddress(runSpec: RunSpec): Option[String] = {
if (!ipAddresses.isEmpty) {
Expand Down
8 changes: 4 additions & 4 deletions src/test/scala/mesosphere/marathon/core/task/TaskTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -97,14 +97,14 @@ class TaskTest extends UnitTest with Inside {
f.taskWithMultipleNetworksAndOneIp.status.networkInfo.effectiveIpAddress(f.appWithIpAddress).value should equal(f.ipString1)
}

"effectiveIpAddress returns None if there is no ip" in {
"effectiveIpAddress returns agent hostname if there is no ip" in {
val f = new Fixture
f.taskWithMultipleNetworkAndNoIp.status.networkInfo.effectiveIpAddress(f.appWithIpAddress) should be(None)
f.taskWithMultipleNetworkAndNoIp.status.networkInfo.effectiveIpAddress(f.appWithIpAddress) should be(Some("agent1.mesos"))
}

"effectiveIpAddress returns the agent ip for MarathonTask instances with one NetworkInfo (if the app does NOT request an IP)" in {
"effectiveIpAddress returns the first container ip for MarathonTask instances with one NetworkInfo (if the app does NOT request an IP)" in {
val f = new Fixture
f.taskWithOneIp.status.networkInfo.effectiveIpAddress(f.appWithoutIpAddress).value should equal(f.host)
f.taskWithOneIp.status.networkInfo.effectiveIpAddress(f.appWithoutIpAddress).value should equal(f.ipString1)
}

"ipAddresses returns None for MarathonTask instances with no IPs" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@ class NetworkInfoTest extends UnitTest {
containerPort = Some(31000)),
PortAssignment(
portName = None,
effectiveIpAddress = None,
effectivePort = PortAssignment.NoPort,
effectiveIpAddress = Option(f.hostName),
effectivePort = 0,
hostPort = None,
containerPort = Some(0)),
PortAssignment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ class AppDefinitionPortAssignmentsTest extends UnitTest {
t.copy(status = t.status.copy(networkInfo = NetworkInfo(hostName, hostPorts = Nil, ipAddresses = Nil)))
}

Then("The port assignments are empty")
Then("The port assignments are not empty")
task.status.networkInfo.portAssignments(app, includeUnresolved = true) should equal(Seq(
PortAssignment(
portName = Some("http"),
effectiveIpAddress = None,
effectivePort = PortAssignment.NoPort,
effectiveIpAddress = Some(hostName),
effectivePort = 80,
hostPort = None,
containerPort = Some(80))
))
Expand Down

0 comments on commit c994ff4

Please sign in to comment.