From d8b380c53689721d5d89e9007f1dc8cb9515af30 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 14:10:48 -0400 Subject: [PATCH 01/21] tests: placeholder pytest.ini to define test root dir Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/pytest.ini | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/pytest.ini diff --git a/tests/pytest.ini b/tests/pytest.ini new file mode 100644 index 000000000..c3e641df4 --- /dev/null +++ b/tests/pytest.ini @@ -0,0 +1,2 @@ +# this is just a placeholder so that we can define what the 'root' of the tests +# dir really is. From d73843c36c0a9010bbaf7492a1264c7c6149033e Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 15:24:44 -0400 Subject: [PATCH 02/21] tests: create a test to check for mon_initial_members Signed-off-by: Alfredo Deza Resolves: pytest#harness --- .../tests/mon/test_initial_members.py | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/functional/tests/mon/test_initial_members.py diff --git a/tests/functional/tests/mon/test_initial_members.py b/tests/functional/tests/mon/test_initial_members.py new file mode 100644 index 000000000..db6d2f474 --- /dev/null +++ b/tests/functional/tests/mon/test_initial_members.py @@ -0,0 +1,32 @@ +import pytest + + + +uses_mon_initial_members = pytest.mark.skipif( + 'mon_initial_members' not in pytest.config.slaveinput['node_config']['components'], + reason="only run in monitors configured with initial_members" +) + + +class TestMon(object): + + def get_line_from_config(self, string, conf_path): + with open(conf_path) as ceph_conf: + ceph_conf_lines = ceph_conf.readlines() + for line in ceph_conf: + if string in line: + return line + + @uses_mon_initial_members + def test_ceph_config_has_inital_members_line(self, scenario_config): + cluster_name = scenario_config.get('ceph', {}).get('cluster_name', 'ceph') + ceph_conf_path = '/etc/ceph/%s.conf' % cluster_name + initial_members_line = self.get_line_from_config('mon_initial_members', ceph_conf_path) + assert initial_members_line + + @uses_mon_initial_members + def test_initial_members_line_has_correct_value(self, scenario_config): + cluster_name = scenario_config.get('ceph', {}).get('cluster_name', 'ceph') + ceph_conf_path = '/etc/ceph/%s.conf' % cluster_name + initial_members_line = self.get_line_from_config('mon_initial_members', ceph_conf_path) + assert initial_members_line == 'mon_initial_members = mon0' From fe7bfbb62f4d99e64c86ff8cf014f6be4068a4ad Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 15:28:37 -0400 Subject: [PATCH 03/21] tests: add __init__.py for mon tests Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/functional/tests/mon/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/functional/tests/mon/__init__.py diff --git a/tests/functional/tests/mon/__init__.py b/tests/functional/tests/mon/__init__.py new file mode 100644 index 000000000..e69de29bb From 757356d57ee7f3dba5eda01294bcd1c8cae7806a Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 15:29:12 -0400 Subject: [PATCH 04/21] tests: common basic tests for after installation Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/functional/tests/test_install.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 tests/functional/tests/test_install.py diff --git a/tests/functional/tests/test_install.py b/tests/functional/tests/test_install.py new file mode 100644 index 000000000..4acaf2496 --- /dev/null +++ b/tests/functional/tests/test_install.py @@ -0,0 +1,10 @@ +import os + + +class TestInstall(object): + + def test_ceph_dir_exists(self): + assert os.path.isdir('/etc/ceph') + + def test_ceph_conf_exists(self): + assert os.path.isfile('/etc/ceph/ceph.conf') From cdac170cbf0e4517251bfb4db668323bca2ec877 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 15:29:28 -0400 Subject: [PATCH 05/21] tests: add __init__.py for functional tests Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/functional/tests/__init__.py | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 tests/functional/tests/__init__.py diff --git a/tests/functional/tests/__init__.py b/tests/functional/tests/__init__.py new file mode 100644 index 000000000..e69de29bb From f828b3d3fc9d4d422303a26df2dd15914ce15e6f Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 15:30:40 -0400 Subject: [PATCH 06/21] create a scenario config file for mon initial members Signed-off-by: Alfredo Deza Resolves: pytest#harness --- .../ubuntu/16.04/mon/initial_members/scenario.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/functional/ubuntu/16.04/mon/initial_members/scenario.py diff --git a/tests/functional/ubuntu/16.04/mon/initial_members/scenario.py b/tests/functional/ubuntu/16.04/mon/initial_members/scenario.py new file mode 100644 index 000000000..caabef690 --- /dev/null +++ b/tests/functional/ubuntu/16.04/mon/initial_members/scenario.py @@ -0,0 +1,15 @@ +# Basic information about ceph and its configuration +ceph = { + 'releases': ['infernalis', 'jewel'], + 'cluster_name': 'ceph' +} + +# remote nodes to test, with anything specific to them that might be useful for +# tests to get. Each one of these can get requested as a py.test fixture to +# validate information. +nodes = { + 'mon0': { + 'username': 'vagrant', + 'components': ['mon', 'mon_initial_members'] + } +} From 4b93837e4d1e5f8a070cce1bfc69445496e231ec Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 15:37:52 -0400 Subject: [PATCH 07/21] tests: add the symlinked Vagrantfile to initial_members Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/functional/ubuntu/16.04/mon/initial_members/Vagrantfile | 1 + 1 file changed, 1 insertion(+) create mode 120000 tests/functional/ubuntu/16.04/mon/initial_members/Vagrantfile diff --git a/tests/functional/ubuntu/16.04/mon/initial_members/Vagrantfile b/tests/functional/ubuntu/16.04/mon/initial_members/Vagrantfile new file mode 120000 index 000000000..9797e1cb7 --- /dev/null +++ b/tests/functional/ubuntu/16.04/mon/initial_members/Vagrantfile @@ -0,0 +1 @@ +../../../../../../Vagrantfile \ No newline at end of file From 05dace442d2d6123703910ea80aec6e989c65009 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 15:39:12 -0400 Subject: [PATCH 08/21] tests: create the conftest file that does all the magic Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/conftest.py | 101 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 tests/conftest.py diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 000000000..0c054050f --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,101 @@ +import os + +import pytest +import imp + + +def pytest_addoption(parser): + default = 'scenario.py' + parser.addoption( + "--scenario", + action="store", + default=default, + help="YAML file defining scenarios to test. Currently defaults to: %s" % default + ) + + +def load_scenario_config(filepath, **kw): + ''' + Creates a configuration dictionary from a file. + + :param filepath: The path to the file. + ''' + + abspath = os.path.abspath(os.path.expanduser(filepath)) + conf_dict = {} + if not os.path.isfile(abspath): + raise RuntimeError('`%s` is not a file.' % abspath) + + # First, make sure the code will actually compile (and has no SyntaxErrors) + with open(abspath, 'rb') as f: + compiled = compile(f.read(), abspath, 'exec') + + # Next, attempt to actually import the file as a module. + # This provides more verbose import-related error reporting than exec() + absname, _ = os.path.splitext(abspath) + basepath, module_name = absname.rsplit(os.sep, 1) + imp.load_module( + module_name, + *imp.find_module(module_name, [basepath]) + ) + + # If we were able to import as a module, actually exec the compiled code + exec(compiled, globals(), conf_dict) + conf_dict['__file__'] = abspath + return conf_dict + + +def pytest_configure_node(node): + node_id = node.slaveinput['slaveid'] + scenario_path = os.path.abspath(node.config.getoption('--scenario')) + scenario = load_scenario_config(scenario_path) + node.slaveinput['node_config'] = scenario['nodes'][node_id] + node.slaveinput['scenario_config'] = scenario + + +@pytest.fixture(scope='session') +def node_config(request): + return request.config.slaveinput['node_config'] + + +@pytest.fixture(scope="session") +def scenario_config(request): + return request.config.slaveinput['scenario_config'] + + +def pytest_report_header(config): + """ + Hook to add extra information about the execution environment and to be + able to debug what did the magical args got expanded to + """ + lines = [] + scenario_path = str(config.rootdir.join(config.getoption('--scenario'))) + if not config.remote_execution: + lines.append('execution environment: local') + else: + lines.append('execution environment: remote') + lines.append('loaded scenario: %s' % scenario_path) + lines.append('expanded args: %s' % config.extended_args) + return lines + + +def pytest_cmdline_preparse(args, config): + # Note: we can only do our magical args expansion if we aren't already in + # a remote node via xdist/execnet so return quickly if we can't do magic. + # TODO: allow setting an environment variable that helps to skip this kind + # of magical argument expansion + if os.getcwd().endswith('pyexecnetcache'): + return + + scenario_path = os.path.abspath(config.getoption('--scenario')) + + scenarios = load_scenario_config(scenario_path, args=args) + rsync_dir = os.path.dirname(str(config.rootdir.join('functional'))) + test_path = str(config.rootdir.join('functional/tests')) + nodes = [] + config.remote_execution = True + for node in scenarios.get('nodes', []): + nodes.append('--tx') + nodes.append('vagrant_ssh={node_name}//id={node_name}'.format(node_name=node)) + args[:] = args + ['--max-slave-restart', '0', '--dist=each'] + nodes + ['--rsyncdir', rsync_dir, test_path] + config.extended_args = ' '.join(args) From ab805824ea2360c51a0e6943c930344ee75dc2a7 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 15:43:35 -0400 Subject: [PATCH 09/21] tests: create an example scenario file Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/scenarios/example.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tests/scenarios/example.py diff --git a/tests/scenarios/example.py b/tests/scenarios/example.py new file mode 100644 index 000000000..7be1c2b55 --- /dev/null +++ b/tests/scenarios/example.py @@ -0,0 +1,24 @@ +# This is the most basic tests that can be executed remotely. It will trigger +# a series of checks for paths, permissions and flags. Whatever is not +# dependant on particular component of ceph should go here (for example, +# nothing related to just OSDs) + +# Basic information about ceph and its configuration +ceph = { + 'releases': ['jewel', 'infernalis'], + 'cluster_name': 'ceph' +} + +# remote nodes to test, with anything specific to them that might be useful for +# tests to get. Each one of these can get requested as a py.test fixture to +# validate information. +nodes = { + 'mon0': { + 'username': 'vagrant', + 'components': ['mon'] + }, + 'osd0': { + 'username': 'vagrant', + 'components': ['osd'] + }, +} From 69632b3ed2cd9320a1f5345979652b4b986dbacb Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 15:44:38 -0400 Subject: [PATCH 10/21] tests: define a requirements.txt file Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/requirements.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 tests/requirements.txt diff --git a/tests/requirements.txt b/tests/requirements.txt new file mode 100644 index 000000000..8bcfc2b5a --- /dev/null +++ b/tests/requirements.txt @@ -0,0 +1,3 @@ +# These are Python requirements needed to run the functional tests +pytest +pytest-xdist From 77281609f8026f9005c4b63c6a5dd57557b27954 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 27 Oct 2016 16:55:27 -0400 Subject: [PATCH 11/21] tests: create a README with some explanation on how to use the test harness Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/README.rst | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 tests/README.rst diff --git a/tests/README.rst b/tests/README.rst new file mode 100644 index 000000000..544adb941 --- /dev/null +++ b/tests/README.rst @@ -0,0 +1,50 @@ +Functional Testing +================== +The directory structure, files, and tests found in this directory all work +together to provide: + +* a set of machines (or even a single one) so that ceph-ansible can run against +* a "scenario" configuration file in Python, that defines what nodes are + configured to what roles and what 'components' they will test +* tests (in functional/tests/) that will all run unless skipped explicitly when + testing a distinct feature dependant on the ansible run. + + +Example run +----------- +The following is the easiest way to try this out locally. Both Vagrant and +VirtualBox are required. Ensure that ``py.test`` and ``pytest-xdist`` are +installed (with pip on a virtualenv) by using the ``requirements.txt`` file in +the ``tests`` directory:: + + pip install -r requirements.txt + +Choose a directory in ``tests/functional`` that has 3 files: + +* ``Vagrantfile`` +* ``vagrant_variables.yml`` +* A Python ("scenario") file. + +For example in: ``tests/functional/ubuntu/16.04/mon/initial_members``:: + + tree . + . + ├── Vagrantfile -> ../../../../../../Vagrantfile + ├── scenario.py + └── vagrant_variables.yml + + 0 directories, 3 files + +It is *required* to be in that directory. It is what triggers all the +preprocessing of complex arguments based on the cluster setup. + +Run vagrant first to setup the environment:: + + vagrant up --no-provision --provider=virtualbox + +Then run ceph-ansible against the hosts with the distinct role (in this case we +are deploying a monitor using ``initial_members``). + +And finally run ``py.test``:: + + py.test -v From 0b044c89f39b366eb03721abeb29f2f3c265ecbb Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 28 Oct 2016 07:23:33 -0400 Subject: [PATCH 12/21] tests: include the vagrant_variables.yml file specific to this scenario Signed-off-by: Alfredo Deza Resolves: pytest#harness --- .../mon/initial_members/vagrant_variables.yml | 64 +++++++++++++++++++ 1 file changed, 64 insertions(+) create mode 100644 tests/functional/ubuntu/16.04/mon/initial_members/vagrant_variables.yml diff --git a/tests/functional/ubuntu/16.04/mon/initial_members/vagrant_variables.yml b/tests/functional/ubuntu/16.04/mon/initial_members/vagrant_variables.yml new file mode 100644 index 000000000..4288b1e77 --- /dev/null +++ b/tests/functional/ubuntu/16.04/mon/initial_members/vagrant_variables.yml @@ -0,0 +1,64 @@ +--- + +# DEPLOY CONTAINERIZED DAEMONS +docker: false + +# DEFINE THE NUMBER OF VMS TO RUN +mon_vms: 1 +osd_vms: 0 +mds_vms: 0 +rgw_vms: 0 +nfs_vms: 0 +rbd_mirror_vms: 0 +client_vms: 0 +iscsi_gw_vms: 0 + +# Deploy RESTAPI on each of the Monitors +restapi: true + +# INSTALL SOURCE OF CEPH +# valid values are 'stable' and 'dev' +ceph_install_source: stable + +# SUBNETS TO USE FOR THE VMS +public_subnet: 192.168.42 +cluster_subnet: 192.168.43 + +# MEMORY +# set 1024 for CentOS +memory: 512 + +# Ethernet interface name +# use eth1 for libvirt and ubuntu precise, enp0s8 for CentOS and ubuntu xenial +eth: 'eth1' + +# Disks +# For libvirt use disks: "[ '/dev/vdb', '/dev/vdc' ]" +# For CentOS7 use disks: "[ '/dev/sda', '/dev/sdb' ]" +disks: "[ '/dev/sdb', '/dev/sdc' ]" + +# VAGRANT BOX +# Ubuntu: bento/ubuntu-16.04 or ubuntu/trusty64 or ubuntu/wily64 +# CentOS: bento/centos-7.1 or puppetlabs/centos-7.0-64-puppet +# libvirt CentOS: centos/7 +# parallels Ubuntu: parallels/ubuntu-14.04 +# Debian: deb/jessie-amd64 - be careful the storage controller is named 'SATA Controller' +# For more boxes have a look at: +# - https://atlas.hashicorp.com/boxes/search?utf8=✓&sort=&provider=virtualbox&q= +# - https://download.gluster.org/pub/gluster/purpleidea/vagrant/ +vagrant_box: bento/ubuntu-16.04 +#ssh_private_key_path: "~/.ssh/id_rsa" +# The sync directory changes based on vagrant box +# Set to /home/vagrant/sync for Centos/7, /home/{ user }/vagrant for openstack and defaults to /vagrant +#vagrant_sync_dir: /home/vagrant/sync +#vagrant_sync_dir: / +# VAGRANT URL +# This is a URL to download an image from an alternate location. vagrant_box +# above should be set to the filename of the image. +# Fedora virtualbox: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-22-20150521.x86_64.vagrant-virtualbox.box +# Fedora libvirt: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-22-20150521.x86_64.vagrant-libvirt.box +# vagrant_box_url: https://download.fedoraproject.org/pub/fedora/linux/releases/22/Cloud/x86_64/Images/Fedora-Cloud-Base-Vagrant-22-20150521.x86_64.vagrant-virtualbox.box + +os_tuning_params: + - { name: kernel.pid_max, value: 4194303 } + - { name: fs.file-max, value: 26234859 } From 1caacfd02b444bfdaa9a34fc760aa8c488986dbb Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 3 Nov 2016 08:07:38 -0400 Subject: [PATCH 13/21] tests: use a different vagrant box Signed-off-by: Alfredo Deza Resolves: pytest#harness --- .../ubuntu/16.04/mon/initial_members/vagrant_variables.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/functional/ubuntu/16.04/mon/initial_members/vagrant_variables.yml b/tests/functional/ubuntu/16.04/mon/initial_members/vagrant_variables.yml index 4288b1e77..97c9ce6c9 100644 --- a/tests/functional/ubuntu/16.04/mon/initial_members/vagrant_variables.yml +++ b/tests/functional/ubuntu/16.04/mon/initial_members/vagrant_variables.yml @@ -46,7 +46,7 @@ disks: "[ '/dev/sdb', '/dev/sdc' ]" # For more boxes have a look at: # - https://atlas.hashicorp.com/boxes/search?utf8=✓&sort=&provider=virtualbox&q= # - https://download.gluster.org/pub/gluster/purpleidea/vagrant/ -vagrant_box: bento/ubuntu-16.04 +vagrant_box: geerlingguy/ubuntu1604 #ssh_private_key_path: "~/.ssh/id_rsa" # The sync directory changes based on vagrant box # Set to /home/vagrant/sync for Centos/7, /home/{ user }/vagrant for openstack and defaults to /vagrant From 08e7103766ce684e849f23fac77792876fded586 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 3 Nov 2016 13:05:19 -0400 Subject: [PATCH 14/21] tests: fix helper to use the actual lines form ceph.conf Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/functional/tests/mon/test_initial_members.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/tests/functional/tests/mon/test_initial_members.py b/tests/functional/tests/mon/test_initial_members.py index db6d2f474..ea6a79576 100644 --- a/tests/functional/tests/mon/test_initial_members.py +++ b/tests/functional/tests/mon/test_initial_members.py @@ -13,7 +13,7 @@ class TestMon(object): def get_line_from_config(self, string, conf_path): with open(conf_path) as ceph_conf: ceph_conf_lines = ceph_conf.readlines() - for line in ceph_conf: + for line in ceph_conf_lines: if string in line: return line @@ -21,12 +21,12 @@ class TestMon(object): def test_ceph_config_has_inital_members_line(self, scenario_config): cluster_name = scenario_config.get('ceph', {}).get('cluster_name', 'ceph') ceph_conf_path = '/etc/ceph/%s.conf' % cluster_name - initial_members_line = self.get_line_from_config('mon_initial_members', ceph_conf_path) + initial_members_line = self.get_line_from_config('mon initial members', ceph_conf_path) assert initial_members_line @uses_mon_initial_members def test_initial_members_line_has_correct_value(self, scenario_config): cluster_name = scenario_config.get('ceph', {}).get('cluster_name', 'ceph') ceph_conf_path = '/etc/ceph/%s.conf' % cluster_name - initial_members_line = self.get_line_from_config('mon_initial_members', ceph_conf_path) - assert initial_members_line == 'mon_initial_members = mon0' + initial_members_line = self.get_line_from_config('mon initial members', ceph_conf_path) + assert initial_members_line == 'mon initial members = mon0' From 8cda2db9c3c9b5deec17bb2a5f3ffb04ab8ece16 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Thu, 3 Nov 2016 16:52:29 -0400 Subject: [PATCH 15/21] tests: mon_initial_members should look for the right hostname Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/functional/tests/mon/test_initial_members.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/functional/tests/mon/test_initial_members.py b/tests/functional/tests/mon/test_initial_members.py index ea6a79576..07390afea 100644 --- a/tests/functional/tests/mon/test_initial_members.py +++ b/tests/functional/tests/mon/test_initial_members.py @@ -15,7 +15,7 @@ class TestMon(object): ceph_conf_lines = ceph_conf.readlines() for line in ceph_conf_lines: if string in line: - return line + return line.strip().strip('\n') @uses_mon_initial_members def test_ceph_config_has_inital_members_line(self, scenario_config): @@ -29,4 +29,4 @@ class TestMon(object): cluster_name = scenario_config.get('ceph', {}).get('cluster_name', 'ceph') ceph_conf_path = '/etc/ceph/%s.conf' % cluster_name initial_members_line = self.get_line_from_config('mon initial members', ceph_conf_path) - assert initial_members_line == 'mon initial members = mon0' + assert initial_members_line == 'mon initial members = ceph-mon0' From 80e955cc408c36ed5abbaa5afe92460d48c272c6 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Fri, 4 Nov 2016 12:25:06 -0500 Subject: [PATCH 16/21] tests: adds a tox.ini to run the functional tests This currently tests the initial-members scenario for both ansible 2.1 and ansible 2.2. It assumes a hosts file and vagrant_ssh_config exists in the scenario directory. Signed-off-by: Andrew Schoen Resolves: pytest#harness --- tox.ini | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 tox.ini diff --git a/tox.ini b/tox.ini new file mode 100644 index 000000000..85fd08334 --- /dev/null +++ b/tox.ini @@ -0,0 +1,22 @@ +[tox] +envlist = {ansible2.1,ansible2.2}-{initial-members} +skipsdist = True + +[testenv] +whitelist_externals = vagrant +passenv=* +setenv= + initial-members: ANSIBLE_SSH_ARGS = -F {toxinidir}/tests/functional/ubuntu/16.04/mon/initial_members/vagrant_ssh_config + ANSIBLE_ACTION_PLUGINS = {toxinidir}/plugins/actions +deps= + ansible2.1: ansible==2.1 + ansible2.2: ansible==2.2 + -r{toxinidir}/tests/requirements.txt +changedir= + initial-members: {toxinidir}/tests/functional/ubuntu/16.04/mon/initial_members +commands= + vagrant up --no-provision --provider=virtualbox + + initial-members: ansible-playbook -i {toxinidir}/tests/functional/ubuntu/16.04/mon/initial_members/hosts --extra-vars "ceph_stable=True public_network=192.168.42.0/24 cluster_network=192.168.43.0/24 journal_size=100 monitor_interface=eth1" {toxinidir}/site.yml.sample + + py.test -v From e319ccf6910dd0e75110405eeb8c521cd88639a4 Mon Sep 17 00:00:00 2001 From: Andrew Schoen Date: Fri, 4 Nov 2016 12:49:18 -0500 Subject: [PATCH 17/21] tests: remove the need for a setenv entry per scenario in tox.ini Signed-off-by: Andrew Schoen Resolves: pytest#harness --- tox.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tox.ini b/tox.ini index 85fd08334..36c8adf6f 100644 --- a/tox.ini +++ b/tox.ini @@ -6,7 +6,7 @@ skipsdist = True whitelist_externals = vagrant passenv=* setenv= - initial-members: ANSIBLE_SSH_ARGS = -F {toxinidir}/tests/functional/ubuntu/16.04/mon/initial_members/vagrant_ssh_config + ANSIBLE_SSH_ARGS = -F {changedir}/vagrant_ssh_config ANSIBLE_ACTION_PLUGINS = {toxinidir}/plugins/actions deps= ansible2.1: ansible==2.1 From 74f9f2bff93bb44add67ab32cebcf7f85503f09d Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 4 Nov 2016 13:58:07 -0400 Subject: [PATCH 18/21] tests: add a helper script to generate vagrant ssh configs Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/scripts/generate_ssh_config.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 tests/scripts/generate_ssh_config.sh diff --git a/tests/scripts/generate_ssh_config.sh b/tests/scripts/generate_ssh_config.sh new file mode 100644 index 000000000..43e64a654 --- /dev/null +++ b/tests/scripts/generate_ssh_config.sh @@ -0,0 +1,14 @@ +#!/bin/bash +# Generate a custom ssh config from Vagrant so that it can then be used by +# ansible.cfg + +path=$1 + +if [ $# -eq 0 ] + then + echo "A path to the scenario is required as an argument and it wasn't provided" + exit 1 +fi + +cd "$path" +vagrant ssh-config > vagrant_ssh_config From 8427e5a4a3d8a96722bacd38cde50a3fe8a27604 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 4 Nov 2016 14:01:28 -0400 Subject: [PATCH 19/21] tests: make the tox.ini config call the ssh config helper script Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tox.ini | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tox.ini b/tox.ini index 36c8adf6f..808d33dad 100644 --- a/tox.ini +++ b/tox.ini @@ -1,9 +1,11 @@ [tox] -envlist = {ansible2.1,ansible2.2}-{initial-members} +envlist = {ansible2.1,ansible2.2}-{initial-members} skipsdist = True [testenv] -whitelist_externals = vagrant +whitelist_externals = + vagrant + bash passenv=* setenv= ANSIBLE_SSH_ARGS = -F {changedir}/vagrant_ssh_config @@ -13,10 +15,12 @@ deps= ansible2.2: ansible==2.2 -r{toxinidir}/tests/requirements.txt changedir= - initial-members: {toxinidir}/tests/functional/ubuntu/16.04/mon/initial_members + initial-members: {toxinidir}/tests/functional/ubuntu/16.04/mon/initial_members commands= vagrant up --no-provision --provider=virtualbox + bash {toxinidir}/tests/scripts/generate_ssh_config.sh {changedir} initial-members: ansible-playbook -i {toxinidir}/tests/functional/ubuntu/16.04/mon/initial_members/hosts --extra-vars "ceph_stable=True public_network=192.168.42.0/24 cluster_network=192.168.43.0/24 journal_size=100 monitor_interface=eth1" {toxinidir}/site.yml.sample py.test -v + vagrant destroy --force From 4d78be41ef09096576c226319c213431d0c01db6 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 4 Nov 2016 14:09:29 -0400 Subject: [PATCH 20/21] tests: gitignore the .tox subdir Signed-off-by: Alfredo Deza Resolves: pytest#harness --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2a02b511c..adfb76b16 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ rgw-standalone.yml take-over-existing-cluster.yml osd-configure.yml rolling_update.yml +.tox From 3511e12253c647760eda7210523eb715e13bf0b3 Mon Sep 17 00:00:00 2001 From: Alfredo Deza Date: Fri, 4 Nov 2016 14:47:59 -0400 Subject: [PATCH 21/21] tests: add a hosts file for the initial_members scenario Signed-off-by: Alfredo Deza Resolves: pytest#harness --- tests/functional/ubuntu/16.04/mon/initial_members/hosts | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 tests/functional/ubuntu/16.04/mon/initial_members/hosts diff --git a/tests/functional/ubuntu/16.04/mon/initial_members/hosts b/tests/functional/ubuntu/16.04/mon/initial_members/hosts new file mode 100644 index 000000000..b3fb91204 --- /dev/null +++ b/tests/functional/ubuntu/16.04/mon/initial_members/hosts @@ -0,0 +1,4 @@ + +[mons] +mon0 +