From 7cbb7d0fb1c876c81e8f0a24b64693d4be41c188 Mon Sep 17 00:00:00 2001 From: Nathan Cutler Date: Mon, 5 Jun 2017 17:08:43 +0200 Subject: [PATCH] qa: deepsea: add test yaml and tweak task * adds test yaml in qa/deepsea/basic * adds exec property * adds documentation * after cloning the DeepSea git repo, print the branch name and sha1 so we have it in the log for verification. * clone with --depth 1 Signed-off-by: Nathan Cutler --- qa/deepsea/2disks.yaml | 4 + qa/deepsea/2nodes.yaml | 4 + qa/deepsea/3nodes.yaml | 5 + qa/deepsea/4nodes.yaml | 6 + qa/deepsea/health-mds.yaml | 10 ++ qa/deepsea/health-ok.yaml | 8 ++ qa/suites/deepsea-test.yaml | 16 +++ qa/suites/deepsea/basic/2nodes/health-mds/+ | 0 .../basic/2nodes/health-mds/2disks.yaml | 1 + .../basic/2nodes/health-mds/2nodes.yaml | 1 + .../basic/2nodes/health-mds/health-mds.yaml | 1 + qa/suites/deepsea/basic/2nodes/health-ok/+ | 0 .../basic/2nodes/health-ok/2disks.yaml | 1 + .../basic/2nodes/health-ok/2nodes.yaml | 1 + .../basic/2nodes/health-ok/health-ok.yaml | 1 + qa/suites/deepsea/basic/3nodes/health-mds/+ | 0 .../basic/3nodes/health-mds/2disks.yaml | 1 + .../basic/3nodes/health-mds/3nodes.yaml | 1 + .../basic/3nodes/health-mds/health-mds.yaml | 1 + qa/suites/deepsea/basic/3nodes/health-ok/+ | 0 .../basic/3nodes/health-ok/2disks.yaml | 1 + .../basic/3nodes/health-ok/3nodes.yaml | 1 + .../basic/3nodes/health-ok/health-ok.yaml | 1 + qa/tasks/deepsea.py | 104 +++++++++++++++--- 24 files changed, 153 insertions(+), 16 deletions(-) create mode 100644 qa/deepsea/2disks.yaml create mode 100644 qa/deepsea/2nodes.yaml create mode 100644 qa/deepsea/3nodes.yaml create mode 100644 qa/deepsea/4nodes.yaml create mode 100644 qa/deepsea/health-mds.yaml create mode 100644 qa/deepsea/health-ok.yaml create mode 100644 qa/suites/deepsea-test.yaml create mode 100644 qa/suites/deepsea/basic/2nodes/health-mds/+ create mode 120000 qa/suites/deepsea/basic/2nodes/health-mds/2disks.yaml create mode 120000 qa/suites/deepsea/basic/2nodes/health-mds/2nodes.yaml create mode 120000 qa/suites/deepsea/basic/2nodes/health-mds/health-mds.yaml create mode 100644 qa/suites/deepsea/basic/2nodes/health-ok/+ create mode 120000 qa/suites/deepsea/basic/2nodes/health-ok/2disks.yaml create mode 120000 qa/suites/deepsea/basic/2nodes/health-ok/2nodes.yaml create mode 120000 qa/suites/deepsea/basic/2nodes/health-ok/health-ok.yaml create mode 100644 qa/suites/deepsea/basic/3nodes/health-mds/+ create mode 120000 qa/suites/deepsea/basic/3nodes/health-mds/2disks.yaml create mode 120000 qa/suites/deepsea/basic/3nodes/health-mds/3nodes.yaml create mode 120000 qa/suites/deepsea/basic/3nodes/health-mds/health-mds.yaml create mode 100644 qa/suites/deepsea/basic/3nodes/health-ok/+ create mode 120000 qa/suites/deepsea/basic/3nodes/health-ok/2disks.yaml create mode 120000 qa/suites/deepsea/basic/3nodes/health-ok/3nodes.yaml create mode 120000 qa/suites/deepsea/basic/3nodes/health-ok/health-ok.yaml diff --git a/qa/deepsea/2disks.yaml b/qa/deepsea/2disks.yaml new file mode 100644 index 0000000000000..f794a6f90ecfa --- /dev/null +++ b/qa/deepsea/2disks.yaml @@ -0,0 +1,4 @@ +openstack: +- volumes: # attached to each instance + count: 2 + size: 10 # GB diff --git a/qa/deepsea/2nodes.yaml b/qa/deepsea/2nodes.yaml new file mode 100644 index 0000000000000..3635a93b58714 --- /dev/null +++ b/qa/deepsea/2nodes.yaml @@ -0,0 +1,4 @@ +ceph_cm: salt +roles: +- [master.a] +- [node.1] diff --git a/qa/deepsea/3nodes.yaml b/qa/deepsea/3nodes.yaml new file mode 100644 index 0000000000000..5aa6c97f1ced2 --- /dev/null +++ b/qa/deepsea/3nodes.yaml @@ -0,0 +1,5 @@ +ceph_cm: salt +roles: +- [master.a] +- [node.1] +- [node.2] diff --git a/qa/deepsea/4nodes.yaml b/qa/deepsea/4nodes.yaml new file mode 100644 index 0000000000000..573dcb0e5c665 --- /dev/null +++ b/qa/deepsea/4nodes.yaml @@ -0,0 +1,6 @@ +ceph_cm: salt +roles: +- [master.a] +- [node.1] +- [node.2] +- [node.3] diff --git a/qa/deepsea/health-mds.yaml b/qa/deepsea/health-mds.yaml new file mode 100644 index 0000000000000..bdb3cfd21b5a5 --- /dev/null +++ b/qa/deepsea/health-mds.yaml @@ -0,0 +1,10 @@ +tasks: +- install: +- deepsea: + repo: https://github.com/smithfarm/DeepSea.git + branch: wip-qa-suite + exec: + - suites/basic/health-mds.sh +#- exec: +# master.a: +# - sleep 1000000000 # forever diff --git a/qa/deepsea/health-ok.yaml b/qa/deepsea/health-ok.yaml new file mode 100644 index 0000000000000..8a65699d15484 --- /dev/null +++ b/qa/deepsea/health-ok.yaml @@ -0,0 +1,8 @@ +tasks: +- install: +- deepsea: + repo: https://github.com/smithfarm/DeepSea.git + branch: wip-qa-suite +#- exec: +# master.a: +# - sleep 1000000000 # forever diff --git a/qa/suites/deepsea-test.yaml b/qa/suites/deepsea-test.yaml new file mode 100644 index 0000000000000..f5a93e4b2d959 --- /dev/null +++ b/qa/suites/deepsea-test.yaml @@ -0,0 +1,16 @@ +ceph_cm: salt +roles: +- [master.a] +- [node.1] +openstack: +- volumes: # attached to each instance + count: 2 + size: 10 # GB +tasks: +- install: +- deepsea: + repo: https://github.com/smithfarm/DeepSea.git + branch: wip-qa-suite +#- exec: +# master.a: +# - sleep 1000000000 # forever diff --git a/qa/suites/deepsea/basic/2nodes/health-mds/+ b/qa/suites/deepsea/basic/2nodes/health-mds/+ new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/qa/suites/deepsea/basic/2nodes/health-mds/2disks.yaml b/qa/suites/deepsea/basic/2nodes/health-mds/2disks.yaml new file mode 120000 index 0000000000000..610e5ed0be852 --- /dev/null +++ b/qa/suites/deepsea/basic/2nodes/health-mds/2disks.yaml @@ -0,0 +1 @@ +../../../../../deepsea/2disks.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/2nodes/health-mds/2nodes.yaml b/qa/suites/deepsea/basic/2nodes/health-mds/2nodes.yaml new file mode 120000 index 0000000000000..af3f574ba886e --- /dev/null +++ b/qa/suites/deepsea/basic/2nodes/health-mds/2nodes.yaml @@ -0,0 +1 @@ +../../../../../deepsea/2nodes.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/2nodes/health-mds/health-mds.yaml b/qa/suites/deepsea/basic/2nodes/health-mds/health-mds.yaml new file mode 120000 index 0000000000000..62622e045d845 --- /dev/null +++ b/qa/suites/deepsea/basic/2nodes/health-mds/health-mds.yaml @@ -0,0 +1 @@ +../../../../../deepsea/health-mds.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/2nodes/health-ok/+ b/qa/suites/deepsea/basic/2nodes/health-ok/+ new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/qa/suites/deepsea/basic/2nodes/health-ok/2disks.yaml b/qa/suites/deepsea/basic/2nodes/health-ok/2disks.yaml new file mode 120000 index 0000000000000..610e5ed0be852 --- /dev/null +++ b/qa/suites/deepsea/basic/2nodes/health-ok/2disks.yaml @@ -0,0 +1 @@ +../../../../../deepsea/2disks.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/2nodes/health-ok/2nodes.yaml b/qa/suites/deepsea/basic/2nodes/health-ok/2nodes.yaml new file mode 120000 index 0000000000000..af3f574ba886e --- /dev/null +++ b/qa/suites/deepsea/basic/2nodes/health-ok/2nodes.yaml @@ -0,0 +1 @@ +../../../../../deepsea/2nodes.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/2nodes/health-ok/health-ok.yaml b/qa/suites/deepsea/basic/2nodes/health-ok/health-ok.yaml new file mode 120000 index 0000000000000..6593a88aafc28 --- /dev/null +++ b/qa/suites/deepsea/basic/2nodes/health-ok/health-ok.yaml @@ -0,0 +1 @@ +../../../../../deepsea/health-ok.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/3nodes/health-mds/+ b/qa/suites/deepsea/basic/3nodes/health-mds/+ new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/qa/suites/deepsea/basic/3nodes/health-mds/2disks.yaml b/qa/suites/deepsea/basic/3nodes/health-mds/2disks.yaml new file mode 120000 index 0000000000000..610e5ed0be852 --- /dev/null +++ b/qa/suites/deepsea/basic/3nodes/health-mds/2disks.yaml @@ -0,0 +1 @@ +../../../../../deepsea/2disks.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/3nodes/health-mds/3nodes.yaml b/qa/suites/deepsea/basic/3nodes/health-mds/3nodes.yaml new file mode 120000 index 0000000000000..b6cef0da0f835 --- /dev/null +++ b/qa/suites/deepsea/basic/3nodes/health-mds/3nodes.yaml @@ -0,0 +1 @@ +../../../../../deepsea/3nodes.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/3nodes/health-mds/health-mds.yaml b/qa/suites/deepsea/basic/3nodes/health-mds/health-mds.yaml new file mode 120000 index 0000000000000..62622e045d845 --- /dev/null +++ b/qa/suites/deepsea/basic/3nodes/health-mds/health-mds.yaml @@ -0,0 +1 @@ +../../../../../deepsea/health-mds.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/3nodes/health-ok/+ b/qa/suites/deepsea/basic/3nodes/health-ok/+ new file mode 100644 index 0000000000000..e69de29bb2d1d diff --git a/qa/suites/deepsea/basic/3nodes/health-ok/2disks.yaml b/qa/suites/deepsea/basic/3nodes/health-ok/2disks.yaml new file mode 120000 index 0000000000000..610e5ed0be852 --- /dev/null +++ b/qa/suites/deepsea/basic/3nodes/health-ok/2disks.yaml @@ -0,0 +1 @@ +../../../../../deepsea/2disks.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/3nodes/health-ok/3nodes.yaml b/qa/suites/deepsea/basic/3nodes/health-ok/3nodes.yaml new file mode 120000 index 0000000000000..b6cef0da0f835 --- /dev/null +++ b/qa/suites/deepsea/basic/3nodes/health-ok/3nodes.yaml @@ -0,0 +1 @@ +../../../../../deepsea/3nodes.yaml \ No newline at end of file diff --git a/qa/suites/deepsea/basic/3nodes/health-ok/health-ok.yaml b/qa/suites/deepsea/basic/3nodes/health-ok/health-ok.yaml new file mode 120000 index 0000000000000..6593a88aafc28 --- /dev/null +++ b/qa/suites/deepsea/basic/3nodes/health-ok/health-ok.yaml @@ -0,0 +1 @@ +../../../../../deepsea/health-ok.yaml \ No newline at end of file diff --git a/qa/tasks/deepsea.py b/qa/tasks/deepsea.py index 373bb4a85c6c7..d2d62e1e763ad 100644 --- a/qa/tasks/deepsea.py +++ b/qa/tasks/deepsea.py @@ -2,6 +2,7 @@ Task to deploy clusters with DeepSea ''' import logging +import time from teuthology import misc from teuthology.orchestra import run @@ -12,16 +13,60 @@ from util import get_remote_for_role log = logging.getLogger(__name__) class DeepSea(Task): + """ + Automated DeepSea integration testing via teuthology: set up a Salt + cluster, clone the DeepSea git repo, run DeepSea integration test(s) + The number of machines in the cluster is determined by the roles stanza, as + usual. One, and only one, of the machines must have a role of type + "master", e.g. master.1 or master.a (the part following the dot is not + significant, but must be there). + + The task starts the Salt Master daemon on the master node, and Salt Minion + daemons on all the nodes (including the master node), and ensures that the + minions are properly linked to the master. TODO: The role types are stored + in the role grain on the minions. + + After that, the DeepSea git repo is cloned to the master node (in + accordance with the "repo" and "branch" options, if given). + + Finally, the task iterates over the list of commands given in the "exec" + property, executing each one inside the 'qa/' directory of the DeepSea repo + clone. + + Possible options for this task are: + + repo: (DeepSea git repo, defaults to https://github.com/SUSE/DeepSea.git) + branch: (DeepSea git branch, defaults to master) + exec: (list of commands, relative to qa/ of the DeepSea repo) + + Example: + + tasks + - deepsea: + exec: + - suites/basic/health-ok.sh + """ def __init__(self, ctx, config): super(DeepSea, self).__init__(ctx, config) + # make sure self.config dict has values for important keys if config is None: config = {} assert isinstance(config, dict), \ 'deepsea task only accepts a dict for configuration' self.config["repo"] = config.get('repo', 'https://github.com/SUSE/DeepSea.git') self.config["branch"] = config.get('branch', 'master') + self.config["exec"] = config.get('exec', ['suites/basic/health-ok.sh']) + assert isinstance(self.config["exec"], list), \ + 'exec property of deepsea yaml must be a list' + + # prepare the list of commands to be executed on the master node + self.exec_cmd = [] + assert len(self.config["exec"]) > 0, \ + 'deepsea exec list must have at least one element' + for cmd in self.config["exec"]: + self.exec_cmd.append('cd DeepSea/qa ; ' + cmd) # determine the role id of the master role if(misc.num_instances_of_type(self.cluster, 'master') != 1): @@ -34,6 +79,7 @@ class DeepSea(Task): # into a string self.config["master_remote"] = get_remote_for_role(self.ctx, master_role).name + self.log.info("master remote: {}".format(self.config["master_remote"])) self.salt = Salt(self.ctx, self.config) def setup(self): @@ -41,15 +87,34 @@ class DeepSea(Task): self.log.info("DeepSea repo: {}".format(self.config["repo"])) self.log.info("DeepSea branch: {}".format(self.config["branch"])) - self.log.info("master remote: {}".format(self.config["master_remote"])) self.salt.master_remote.run(args=[ 'git', 'clone', + '--depth', + '1', '--branch', self.config["branch"], self.config["repo"], + ]) + + self.log.info("printing DeepSea branch name and sha1...") + self.salt.master_remote.run(args=[ + 'cd', + 'DeepSea', run.Raw(';'), + 'git', + 'rev-parse', + '--abbrev-ref', + 'HEAD', + run.Raw(';'), + 'git', + 'rev-parse', + 'HEAD', + ]) + + self.log.info("Running \"make install\" in DeepSea clone...") + self.salt.master_remote.run(args=[ 'cd', 'DeepSea', run.Raw(';'), @@ -81,25 +146,32 @@ class DeepSea(Task): self.salt.ping_minions() - self.log.info("listing contents of DeepSea/qa/ directory tree...") - self.salt.master_remote.run(args=[ - 'ls', - '-lR', - '--color=never', - 'DeepSea/qa/' - ]) - - self.log.info("running basic-health-ok.sh workunit...") - self.salt.master_remote.run(args=[ - 'sudo', - 'DeepSea/qa/workunits/basic-health-ok.sh' - ]) - - def begin(self): super(DeepSea, self).begin() + for cmd in self.exec_cmd: + self.log.info( + "command to be executed on master node: {}".format(cmd) + ) + self.salt.master_remote.run(args=[ + 'sudo', 'sh', '-c', + cmd + ]) def end(self): + # replace this hack with DeepSea purge when it's ready + for _remote, _ in self.ctx.cluster.remotes.iteritems(): + self.log.info("stopping OSD services on {}" + .format(_remote.hostname)) + _remote.run(args=[ + 'sudo', 'sh', '-c', + 'systemctl stop ceph-osd.target ; sleep 10' + ]) + self.log.info("unmounting OSD data devices on {}" + .format(_remote.hostname)) + _remote.run(args=[ + 'sudo', 'sh', '-c', + 'umount /dev/vdb2 ; umount /dev/vdc2' + ]) super(DeepSea, self).end() task = DeepSea -- 2.39.5