Skip to content

Remove duplicate TestServiceUpdatePort#36502

Merged
yongtang merged 1 commit intomoby:masterfrom
thaJeztah:remove-duplicate-test
Mar 6, 2018
Merged

Remove duplicate TestServiceUpdatePort#36502
yongtang merged 1 commit intomoby:masterfrom
thaJeztah:remove-duplicate-test

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

The TestAPIServiceUpdatePort test performs exactly the same steps.

Here's one;

func (s *DockerSwarmSuite) TestServiceUpdatePort(c *check.C) {
d := s.AddDaemon(c, true, true)
serviceName := "TestServiceUpdatePort"
serviceArgs := append([]string{"service", "create", "--detach", "--no-resolve-image", "--name", serviceName, "-p", "8080:8081", defaultSleepImage}, sleepCommandForDaemonPlatform()...)
// Create a service with a port mapping of 8080:8081.
out, err := d.Cmd(serviceArgs...)
c.Assert(err, checker.IsNil)
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
// Update the service: changed the port mapping from 8080:8081 to 8082:8083.
_, err = d.Cmd("service", "update", "--detach", "--publish-add", "8082:8083", "--publish-rm", "8081", serviceName)
c.Assert(err, checker.IsNil)
// Inspect the service and verify port mapping
expected := []swarm.PortConfig{
{
Protocol: "tcp",
PublishedPort: 8082,
TargetPort: 8083,
PublishMode: "ingress",
},
}
out, err = d.Cmd("service", "inspect", "--format", "{{ json .Spec.EndpointSpec.Ports }}", serviceName)
c.Assert(err, checker.IsNil)
var portConfig []swarm.PortConfig
if err := json.Unmarshal([]byte(out), &portConfig); err != nil {
c.Fatalf("invalid JSON in inspect result: %v (%s)", err, out)
}
c.Assert(portConfig, checker.DeepEquals, expected)
}

And the other;

func (s *DockerSwarmSuite) TestAPIServiceUpdatePort(c *check.C) {
d := s.AddDaemon(c, true, true)
// Create a service with a port mapping of 8080:8081.
portConfig := []swarm.PortConfig{{TargetPort: 8081, PublishedPort: 8080}}
serviceID := d.CreateService(c, simpleTestService, setInstances(1), setPortConfig(portConfig))
waitAndAssert(c, defaultReconciliationTimeout, d.CheckActiveContainerCount, checker.Equals, 1)
// Update the service: changed the port mapping from 8080:8081 to 8082:8083.
updatedPortConfig := []swarm.PortConfig{{TargetPort: 8083, PublishedPort: 8082}}
remoteService := d.GetService(c, serviceID)
d.UpdateService(c, remoteService, setPortConfig(updatedPortConfig))
// Inspect the service and verify port mapping.
updatedService := d.GetService(c, serviceID)
c.Assert(updatedService.Spec.EndpointSpec, check.NotNil)
c.Assert(len(updatedService.Spec.EndpointSpec.Ports), check.Equals, 1)
c.Assert(updatedService.Spec.EndpointSpec.Ports[0].TargetPort, check.Equals, uint32(8083))
c.Assert(updatedService.Spec.EndpointSpec.Ports[0].PublishedPort, check.Equals, uint32(8082))
}

The TestAPIServiceUpdatePort test performs exactly
the same steps.

Signed-off-by: Sebastiaan van Stijn <[email protected]>
Copy link
Copy Markdown
Member

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🐯

Copy link
Copy Markdown
Member

@dnephin dnephin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@thaJeztah
Copy link
Copy Markdown
Member Author

hm... https://jenkins.dockerproject.org/job/Docker-PRs-experimental/39654/console

15:31:45 === RUN   TestServiceWithPredefinedNetwork
15:31:56 --- FAIL: TestServiceWithPredefinedNetwork (11.33s)
15:31:56 	daemon.go:283: [d016408df2853] waiting for daemon to start
15:31:56 	daemon.go:315: [d016408df2853] daemon started
15:31:56 	service_test.go:52: timeout hit after 10s: task count at 1 waiting for 0
15:31:56 	daemon.go:273: [d016408df2853] exiting daemon
15:31:56 FAIL

Odd, that test was added in #36316, but trying to understand how waiting for 0 can occur

@thaJeztah
Copy link
Copy Markdown
Member Author

oh! misreading, was looking at service count, not task-count (thanks @vdemeester), so that test is failing at

poll.WaitOn(t, noTasks(client), pollSettings)

Copy link
Copy Markdown
Member

@yongtang yongtang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 6, 2018

Codecov Report

❗ No coverage uploaded for pull request base (master@f0694e9). Click here to learn what that means.
The diff coverage is n/a.

@@            Coverage Diff            @@
##             master   #36502   +/-   ##
=========================================
  Coverage          ?   34.64%           
=========================================
  Files             ?      613           
  Lines             ?    45404           
  Branches          ?        0           
=========================================
  Hits              ?    15730           
  Misses            ?    27614           
  Partials          ?     2060

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants