Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update ansible-test sanity command. #31958

Merged
merged 23 commits into from Oct 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
66ea146
Run sanity tests in a docker container.
mattclay Oct 18, 2017
b6519d0
Add git fallback for validate-modules.
mattclay Aug 29, 2017
9045167
Use correct pip version in ansible-test.
mattclay Aug 29, 2017
cb37a83
Use correct python version for sanity tests.
mattclay Oct 18, 2017
d052da8
Pin docker completion images and add default.
mattclay Oct 19, 2017
3ececa5
Split pylint execution into multiple contexts.
mattclay Oct 18, 2017
6d653cc
Only test .py files in use-argspec-type-path test.
mattclay Oct 19, 2017
f819195
Accept identical python interpeter name or binary.
mattclay Oct 19, 2017
151865f
Switch cloud tests to default container.
mattclay Oct 19, 2017
993d0c2
Remove unused extras from pip install.
mattclay Oct 20, 2017
17b9e67
Filter out empty pip commands.
mattclay Oct 20, 2017
87eaebe
Don't force running of pip list.
mattclay Oct 20, 2017
93404cf
Update default Docker image SHA.
mattclay Oct 20, 2017
8faa44c
Support delegation for windows and network tests.
mattclay Oct 20, 2017
f21a766
Fix ansible-test python version usage.
mattclay Oct 24, 2017
d9b7e8c
Fix ansible-test python version skipping.
mattclay Oct 24, 2017
20770d8
Update default container hash.
mattclay Oct 24, 2017
c84558a
Use absolute path for log in ansible-test.
mattclay Oct 24, 2017
67f9423
Run vyos_command test on python 3.
mattclay Oct 24, 2017
575f604
Fix windows/network instance persistence.
mattclay Oct 24, 2017
7afae88
Add `test/cache` dir to classification.
mattclay Oct 24, 2017
ab15c4c
Enable more python versions for network tests.
mattclay Oct 25, 2017
dad3c4e
Fix cs_router test.
mattclay Oct 25, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -67,6 +67,7 @@ results.xml
coverage.xml
/test/units/cover-html
/test/integration/targets/*/backup/
/test/cache/*
# Development
/test/develop
venv
Expand Down
8 changes: 4 additions & 4 deletions shippable.yml
Expand Up @@ -62,11 +62,11 @@ matrix:
- env: T=linux/ubuntu1604/3
- env: T=linux/ubuntu1604py3/3

- env: T=cloud/ubuntu1604/1
- env: T=cloud/ubuntu1604py3/1
- env: T=cloud/default/2.7/1
- env: T=cloud/default/3.6/1

- env: T=cloud/ubuntu1604/2
- env: T=cloud/ubuntu1604py3/2
- env: T=cloud/default/2.7/2
- env: T=cloud/default/3.6/2

branches:
except:
Expand Down
File renamed without changes.
11 changes: 5 additions & 6 deletions test/integration/targets/cs_router/tasks/main.yml
Expand Up @@ -49,12 +49,8 @@
- instance.name == "instance-vm"
- instance.state == "Running"

- name: install jq
package:
name: jq

- name: setup find the routers name
shell: cs listRouters listall=true networkid="{{ net.id }}" zone="{{ cs_common_zone_adv }}" | jq ".router[].name" | tr -d '"'
shell: cs listRouters listall=true networkid="{{ net.id }}" zone="{{ cs_common_zone_adv }}"
args:
chdir: "{{ playbook_dir }}"
register: router
Expand All @@ -63,7 +59,10 @@
var: router.stdout

- set_fact:
router_name: "{{ router.stdout }}"
router_json: "{{ router.stdout | from_json }}"

- set_fact:
router_name: "{{ router_json.router[0].name }}"

- name: test router started
cs_router:
Expand Down
1 change: 0 additions & 1 deletion test/integration/targets/vyos_command/aliases
@@ -1,2 +1 @@
network/ci
skip/python3
19 changes: 10 additions & 9 deletions test/runner/completion/docker.txt
@@ -1,9 +1,10 @@
centos6
centos7
fedora24
fedora25
opensuse42.2
opensuse42.3
ubuntu1404
ubuntu1604
ubuntu1604py3
centos6@sha256:41eb4b870ce400202945ccf572d45bf5f2f5ebb50e9dee244de73b9d0278db30
centos7@sha256:bd571611112cccefdaa951ea640177cbb77c8ee011f958d2562781d90594ea9c
default@sha256:424161033bf1342bc463c27c5fad182c171aa3bc17b3c1fe7aac44623cc8d304
fedora24@sha256:7b642c5d25b779a3a605fb8f70d9d92972f2004a5266fe364264809899fb1117
fedora25@sha256:828c71d87f1636f4d09916b8e2d87fc9a615d361a9afed22e8843ffb3d2729d2
opensuse42.2@sha256:fc22d6684910018d2e5f2e8613391b5ae5aca7760d365ac3098971b7aa41d8a2
opensuse42.3@sha256:7f48e874367528711a1df7ff16da5667d67d2eb15902b8e5151d34546e6af04d
ubuntu1404@sha256:ba27d23e815a4c3fb361001aea2ef70241d66f08bdf962cf5717037e882ff78a
ubuntu1604@sha256:ff3898ac817a10ec7129f6483721a717ed0d98c6ba42c27be1472d73908568da
ubuntu1604py3@sha256:f0b7883eb3f17ee7cb3a77f4aeea0d743101e103f93a76f4f5120aed9c44c0bc
1 change: 1 addition & 0 deletions test/runner/injector/ansible-connection
5 changes: 4 additions & 1 deletion test/runner/lib/ansible_util.py
Expand Up @@ -49,6 +49,9 @@ def ansible_environment(args, color=True):
env.update(ansible)

if args.debug:
env.update(dict(ANSIBLE_DEBUG='true'))
env.update(dict(
ANSIBLE_DEBUG='true',
ANSIBLE_LOG_PATH=os.path.abspath('test/results/logs/debug.log'),
))

return env
3 changes: 3 additions & 0 deletions test/runner/lib/classification.py
Expand Up @@ -367,6 +367,9 @@ def _classify(self, path):

return minimal

if path.startswith('test/cache/'):
return minimal

if path.startswith('test/compile/'):
return {
'compile': 'all',
Expand Down
3 changes: 2 additions & 1 deletion test/runner/lib/config.py
Expand Up @@ -43,6 +43,7 @@ def __init__(self, args, command):
self.docker_privileged = args.docker_privileged if 'docker_privileged' in args else False # type: bool
self.docker_util = docker_qualify_image(args.docker_util if 'docker_util' in args else '') # type: str
self.docker_pull = args.docker_pull if 'docker_pull' in args else False # type: bool
self.docker_keep_git = args.docker_keep_git if 'docker_keep_git' in args else False # type: bool

self.tox_sitepackages = args.tox_sitepackages # type: bool

Expand All @@ -53,7 +54,7 @@ def __init__(self, args, command):
self.requirements = args.requirements # type: bool

if self.python == 'default':
self.python = '.'.join(str(i) for i in sys.version_info[:2])
self.python = None

self.python_version = self.python or '.'.join(str(i) for i in sys.version_info[:2])

Expand Down
67 changes: 48 additions & 19 deletions test/runner/lib/core_ci.py
Expand Up @@ -8,6 +8,7 @@
import uuid
import errno
import time
import shutil

from lib.http import (
HttpClient,
Expand Down Expand Up @@ -35,13 +36,14 @@

class AnsibleCoreCI(object):
"""Client for Ansible Core CI services."""
def __init__(self, args, platform, version, stage='prod', persist=True, name=None):
def __init__(self, args, platform, version, stage='prod', persist=True, load=True, name=None):
"""
:type args: EnvironmentConfig
:type platform: str
:type version: str
:type stage: str
:type persist: bool
:type load: bool
:type name: str
"""
self.args = args
Expand Down Expand Up @@ -106,7 +108,7 @@ def __init__(self, args, platform, version, stage='prod', persist=True, name=Non

self.path = os.path.expanduser('~/.ansible/test/instances/%s-%s' % (self.name, self.stage))

if persist and self._load():
if persist and load and self._load():
try:
display.info('Checking existing %s/%s instance %s.' % (self.platform, self.version, self.instance_id),
verbosity=1)
Expand All @@ -125,7 +127,7 @@ def __init__(self, args, platform, version, stage='prod', persist=True, name=Non

self.instance_id = None
self.endpoint = None
else:
elif not persist:
self.instance_id = None
self.endpoint = None
self._clear()
Expand Down Expand Up @@ -160,6 +162,11 @@ def _get_parallels_endpoints(self):

def start(self):
"""Start instance."""
if self.started:
display.info('Skipping started %s/%s instance %s.' % (self.platform, self.version, self.instance_id),
verbosity=1)
return

if is_shippable():
return self.start_shippable()

Expand Down Expand Up @@ -289,11 +296,6 @@ def _uri(self):

def _start(self, auth):
"""Start instance."""
if self.started:
display.info('Skipping started %s/%s instance %s.' % (self.platform, self.version, self.instance_id),
verbosity=1)
return

display.info('Initializing new %s/%s instance %s.' % (self.platform, self.version, self.instance_id), verbosity=1)

if self.platform == 'windows':
Expand Down Expand Up @@ -413,6 +415,13 @@ def _load(self):

config = json.loads(data)

return self.load(config)

def load(self, config):
"""
:type config: dict[str, str]
:rtype: bool
"""
self.instance_id = config['instance_id']
self.endpoint = config['endpoint']
self.started = True
Expand All @@ -424,16 +433,23 @@ def _save(self):
if self.args.explain:
return

config = self.save()

make_dirs(os.path.dirname(self.path))

with open(self.path, 'w') as instance_fd:
config = dict(
instance_id=self.instance_id,
endpoint=self.endpoint,
)

instance_fd.write(json.dumps(config, indent=4, sort_keys=True))

def save(self):
"""
:rtype: dict[str, str]
"""
return dict(
platform_version='%s/%s' % (self.platform, self.version),
instance_id=self.instance_id,
endpoint=self.endpoint,
)

@staticmethod
def _create_http_error(response):
"""
Expand Down Expand Up @@ -472,20 +488,33 @@ def __init__(self, status, remote_message, remote_stack_trace):

class SshKey(object):
"""Container for SSH key used to connect to remote instances."""
KEY_NAME = 'id_rsa'
PUB_NAME = 'id_rsa.pub'

def __init__(self, args):
"""
:type args: EnvironmentConfig
"""
tmp = os.path.expanduser('~/.ansible/test/')
cache_dir = 'test/cache'

self.key = os.path.join(cache_dir, self.KEY_NAME)
self.pub = os.path.join(cache_dir, self.PUB_NAME)

self.key = os.path.join(tmp, 'id_rsa')
self.pub = os.path.join(tmp, 'id_rsa.pub')
if not os.path.isfile(self.key) or not os.path.isfile(self.pub):
base_dir = os.path.expanduser('~/.ansible/test/')

key = os.path.join(base_dir, self.KEY_NAME)
pub = os.path.join(base_dir, self.PUB_NAME)

if not os.path.isfile(self.pub):
if not args.explain:
make_dirs(tmp)
make_dirs(base_dir)

if not os.path.isfile(key) or not os.path.isfile(pub):
run_command(args, ['ssh-keygen', '-q', '-t', 'rsa', '-N', '', '-f', key])

run_command(args, ['ssh-keygen', '-q', '-t', 'rsa', '-N', '', '-f', self.key])
if not args.explain:
shutil.copy2(key, self.key)
shutil.copy2(pub, self.pub)

if args.explain:
self.pub_contents = None
Expand Down
13 changes: 9 additions & 4 deletions test/runner/lib/delegation.py
Expand Up @@ -102,10 +102,10 @@ def delegate_tox(args, exclude, require):
:type require: list[str]
"""
if args.python:
versions = args.python,
versions = args.python_version,

if args.python not in SUPPORTED_PYTHON_VERSIONS:
raise ApplicationError('tox does not support Python version %s' % args.python)
if args.python_version not in SUPPORTED_PYTHON_VERSIONS:
raise ApplicationError('tox does not support Python version %s' % args.python_version)
else:
versions = SUPPORTED_PYTHON_VERSIONS

Expand Down Expand Up @@ -189,7 +189,12 @@ def delegate_docker(args, exclude, require):
with tempfile.NamedTemporaryFile(prefix='ansible-source-', suffix='.tgz') as local_source_fd:
try:
if not args.explain:
lib.pytar.create_tarfile(local_source_fd.name, '.', lib.pytar.ignore)
if args.docker_keep_git:
tar_filter = lib.pytar.AllowGitTarFilter()
else:
tar_filter = lib.pytar.DefaultTarFilter()

lib.pytar.create_tarfile(local_source_fd.name, '.', tar_filter)

if util_image:
util_options = [
Expand Down