Skip to content

Commit

Permalink
support to use python docker 3.5.0 (sonic-net#585)
Browse files Browse the repository at this point in the history
* support to use python docker 3.5.0

start from docker 3.0.0, results from exec_run changed to
dict(outout, code)

Signed-off-by: Guohan Lu <[email protected]>

* limit the scope of exception

Signed-off-by: Guohan Lu <[email protected]>

* modify runcmd output to include exitcode

Signed-off-by: Guohan Lu <[email protected]>
  • Loading branch information
lguohan authored Aug 19, 2018
1 parent cb28e4a commit a52b210
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SWSS Integration tests runs on docker-sonic-vs which runs on top of SAI virtual

- Install docker and pytest on your dev machine
```
sudo pip install --system docker==2.6.1
sudo pip install --system docker==3.5.0
sudo pip install --system pytest==3.3.0
```
- Compile and install swss common library. Follow instructions [here](https://github.com/Azure/sonic-swss-common/blob/master/README.md) to first install prerequisites to build swss common library.
Expand Down
15 changes: 13 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,11 @@ def check_ready(self, timeout=30):
started = 0
while True:
# get process status
out = self.ctn.exec_run("supervisorctl status")
res = self.ctn.exec_run("supervisorctl status")
try:
out = res.output
except AttributeError:
out = res
for l in out.split('\n'):
fds = re_space.split(l)
if len(fds) < 2:
Expand Down Expand Up @@ -204,7 +208,14 @@ def init_asicdb_validator(self):
self.asicdb = AsicDbValidator(self)

def runcmd(self, cmd):
return self.ctn.exec_run(cmd)
res = self.ctn.exec_run(cmd)
try:
exitcode = res.exit_code
out = res.output
except AttributeError:
exitcode = 0
out = res
return (exitcode, out)

@pytest.yield_fixture(scope="module")
def dvs(request):
Expand Down
10 changes: 5 additions & 5 deletions tests/test_warm_reboot.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ def test_VlanMgrdWarmRestart(dvs):
assert status == True


bv_before = dvs.runcmd("bridge vlan")
(exitcode, bv_before) = dvs.runcmd("bridge vlan")
print(bv_before)

restart_count = swss_get_RestartCount(state_db)
Expand All @@ -178,15 +178,15 @@ def test_VlanMgrdWarmRestart(dvs):
dvs.runcmd(['sh', '-c', 'supervisorctl start vlanmgrd'])
time.sleep(2)

bv_after = dvs.runcmd("bridge vlan")
(exitcode, bv_after) = dvs.runcmd("bridge vlan")
assert bv_after == bv_before

# No create/set/remove operations should be passed down to syncd for vlanmgr warm restart
num = dvs.runcmd(['sh', '-c', 'grep \|c\| /var/log/swss/sairedis.rec | wc -l'])
(exitcode, num) = dvs.runcmd(['sh', '-c', 'grep \|c\| /var/log/swss/sairedis.rec | wc -l'])
assert num == '0\n'
num = dvs.runcmd(['sh', '-c', 'grep \|s\| /var/log/swss/sairedis.rec | wc -l'])
(exitcode, num) = dvs.runcmd(['sh', '-c', 'grep \|s\| /var/log/swss/sairedis.rec | wc -l'])
assert num == '0\n'
num = dvs.runcmd(['sh', '-c', 'grep \|r\| /var/log/swss/sairedis.rec | wc -l'])
(exitcode, num) = dvs.runcmd(['sh', '-c', 'grep \|r\| /var/log/swss/sairedis.rec | wc -l'])
assert num == '0\n'

#new ip on server 5
Expand Down

0 comments on commit a52b210

Please sign in to comment.