Skip to content

Commit

Permalink
Merge branch 'feature/fix_travis' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
timsueberkrueb committed Mar 3, 2018
2 parents 16271d3 + 5c29ac1 commit 30fac16
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
17 changes: 13 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
sudo: required
dist: trusty
services:
- docker
sudo: required
language: python
python:
- "3.5"
install:
- pip install click pycodestyle
script:
- python3 ./scripts/run_tests.py --build-docker-images --docker --verbose
- python3 ./scripts/check_code_style.py
- sudo apt-get update
- sudo apt-get install --yes snapd
- sudo apt-get remove --yes lxd lxd-client
- sudo snap install core
- sudo snap install lxd
- for i in $(seq 12); do sudo /snap/bin/lxd waitready --timeout=10 >/dev/null 2>&1 && break; done
- sudo /snap/bin/lxd init --auto
- sudo /snap/bin/lxc network create testbr0
- sudo /snap/bin/lxc network attach-profile testbr0 default eth0
- export PATH="/snap/bin:$PATH"
- sudo env "PATH=$PATH" python3.5 ./scripts/run_tests.py --lxd --verbose
- python3.5 ./scripts/check_code_style.py
25 changes: 7 additions & 18 deletions scripts/container_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,10 @@ def docker_wait_for_snapd(container_name):

def lxd_wait_for_network(container_name):
print('Waiting for a network connection ...')
connected = False
retry_count = 25
network_probe = 'import urllib.request; urllib.request.urlopen("{}", timeout=5)' \
.format('http://start.ubuntu.com/connectivity-check.html')
while not connected:
time.sleep(1)
try:
result = subprocess.check_call(
['lxc', 'exec', container_name, '--',
'python3', '-c', "'" + network_probe + "'"]
)
connected = result == 0
except subprocess.CalledProcessError:
connected = False
retry_count -= 1
if retry_count == 0:
raise ConnectionError("No network connection")
print('Network connection established')
result = subprocess.check_call(
['lxc', 'exec', container_name, '--',
'sh', '-c', "for i in {1..50}; do ping -c1 www.ubuntu.com &> /dev/null && break; done"]
)
time.sleep(5)
if result == 0:
print('Network connection established')
3 changes: 2 additions & 1 deletion scripts/run_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

SUPPORTED_UBUNTU_RELEASES = (
'xenial', # 16.04
'artful', # 17.10
# FIXME: Disabled right
# 'artful', # 17.10
)


Expand Down

0 comments on commit 30fac16

Please sign in to comment.