Skip to content

Commit

Permalink
Merge "vnsw, docker netns command: Fixed bug when old symlinks remain…
Browse files Browse the repository at this point in the history
…ed after docker instance has been destroyed"
  • Loading branch information
Zuul authored and opencontrail-ci-admin committed Nov 25, 2015
2 parents 69dd345 + d8fc5db commit 6fd6cb8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,15 +78,21 @@ def test_create(self, mock_os, mock_netns):


@mock.patch('opencontrail_vrouter_netns.vrouter_docker.NetnsManager')
def test_delete(self, mock_netns):
@mock.patch('opencontrail_vrouter_netns.vrouter_docker.os')
def test_delete(self, mock_os, mock_netns):
cmd = "destroy"
cmd += " " + self.VM_ID
cmd += " --vmi-left-id " + self.VMI_LEFT['id']
cmd += " --vmi-right-id " + self.VMI_RIGHT['id']
cmd += " --vmi-management-id " + self.VMI_LEFT['id']
app = self.mock_app(cmd)
mock_os.path.islink.return_value = True
app.args.func()

app._client.inspect_container.assert_called_with(self.VM_ID)
mocked_netns = mock_netns.return_value
mocked_netns.unplug_namespace_interface.assert_called_with()
mocked_netns.destroy.assert_called_with()
mocked_netns.destroy.assert_called_with()
docker_pid = self.MOCK_CONTAINER["State"]["Pid"]
mock_os.remove.assert_called_once_with("/var/run/netns/%s" % docker_pid)
mock_os.path.islink.assert_called_once_with("/var/run/netns/%s" % docker_pid)
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def _stop(self, vm_name, vmi_left_id, vmi_right_id, vmi_management_id):
self._client.stop(vm_name)

netns_path = "/var/run/netns/%s" % docker_pid
if os.path.exists(netns_path):
if os.path.islink(netns_path):
os.remove(netns_path)

def create(self):
Expand Down

0 comments on commit 6fd6cb8

Please sign in to comment.