예제 #1
0
    def runJob(self, db, nodepool):
        if self.node_id:
            nodepool.deleteNode(self.node_id)
            self.update(db, node_id=0)

        node_id, node_ip = nodepool.getNode()

        if not node_id:
            return
        self.log.info("Running job for %s on %s/%s"%(self, node_id, node_ip))

        if not utils.testSSH(node_ip, Configuration().NODE_USERNAME, Configuration().NODE_KEY):
            self.log.error('Failed to get SSH object for node %s/%s.  Deleting node.'%(node_id, node_ip))
            nodepool.deleteNode(node_id)
            self.update(db, node_id=0)
            return

        self.update(db, node_id=node_id, node_ip=node_ip, result='')

        cmd = 'echo %s >> run_tests_env' % ' '.join(instructions.check_out_testrunner())
        utils.execute_command('ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i %s %s@%s %s'%(
                Configuration().NODE_KEY, Configuration().NODE_USERNAME, node_ip, cmd))
        cmd = 'echo "%s %s" >> run_tests_env' % (
            ' '.join(environment.get_environment(self.change_ref)),
            ' '.join(instructions.execute_test_runner()))
        utils.execute_command('ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i %s %s@%s %s'%(
                Configuration().NODE_KEY, Configuration().NODE_USERNAME, node_ip, cmd))
        # For some reason invoking this immediately fails...
        time.sleep(5)
        utils.execute_command('ssh$-q$-o$BatchMode=yes$-o$UserKnownHostsFile=/dev/null$-o$StrictHostKeyChecking=no$-i$%s$%s@%s$nohup bash /home/jenkins/run_tests_env < /dev/null > run_tests.log 2>&1 &'%(
                Configuration().NODE_KEY, Configuration().NODE_USERNAME, node_ip), '$')
        self.update(db, state=constants.RUNNING)
예제 #2
0
    def __call__(self):
        self.executor.run(
            self.node.scp(
                'tempest_exclusion_list', '/tmp/tempest_exclusion_list')
        )

        self.executor.run(
            self.node.run(instructions.check_out_testrunner())
        )

        self.executor.run(
            self.node.run(
                environment.get_environment(self.change_ref)
                + instructions.execute_test_runner())
        )
예제 #3
0
    def test_execution(self):
        cmd = commands.RunTests(dict(change_ref='CHANGE'))
        cmd()

        self.maxDiff = 4096

        self.assertEquals(
            [
                SCP + ['tempest_exclusion_list', 'NODE_USERNAME@NODE_HOST:/tmp/tempest_exclusion_list'],
                SSH_TO_NODE + instructions.check_out_testrunner(),
                SSH_TO_NODE
                + environment.get_environment('CHANGE')
                + instructions.execute_test_runner()
            ],
            cmd.executor.executed_commands
        )
예제 #4
0
    def test_execution_with_explicit_test_runner(self):
        cmd = commands.RunTests(dict(
            project_name='PROJECT', change_ref='CHANGE', test_runner_url='AA'))
        cmd()

        self.maxDiff = 4096

        self.assertEquals(
            [
                SSH_TO_NODE + instructions.check_out_testrunner('AA'),
                SSH_TO_NODE
                + environment.get_environment('PROJECT', 'CHANGE')
                + instructions.execute_test_runner()
            ],
            cmd.executor.executed_commands
        )
예제 #5
0
    def test_execution_update_testrunner(self):
        cmd = commands.RunTests(dict(project_name='stackforge/xenapi-os-testing', change_ref='CHANGE'))
        cmd()

        self.maxDiff = 4096

        expected = [
                SSH_TO_NODE + instructions.check_out_testrunner()]
        for instruction in instructions.update_testrunner('CHANGE'):
            expected.append(SSH_TO_NODE + instruction)
        expected.extend([
                SSH_TO_NODE + environment.get_environment('stackforge/xenapi-os-testing', 'CHANGE')
                + instructions.execute_test_runner()
            ])

        self.assertEquals(expected, cmd.executor.executed_commands)
    def __call__(self):
        self.executor.run(
            self.node.run(
                instructions.check_out_testrunner(self.test_runner_url)
            )
        )

        if self.project_name == 'openstack/xenapi-os-testing':
            for instruction in instructions.update_testrunner(self.change_ref):
                self.executor.run(
                    self.node.run(instruction)
                )

        self.executor.run(
            self.node.run(
                environment.get_environment(self.project_name, self.change_ref, self.branch)
                + instructions.execute_test_runner())
        )
예제 #7
0
    def __call__(self):
        self.executor.run(
            self.node.run(
                instructions.check_out_testrunner(self.test_runner_url)
            )
        )

        if self.project_name == 'stackforge/xenapi-os-testing':
            for instruction in instructions.update_testrunner(self.change_ref):
                self.executor.run(
                    self.node.run(instruction)
                )

        self.executor.run(
            self.node.run(
                environment.get_environment(self.project_name, self.change_ref)
                + instructions.execute_test_runner())
        )
예제 #8
0
    def runJob(self, db, nodepool):
        if self.node_id:
            nodepool.deleteNode(self.node_id)
            self.update(db, node_id=0)

        node_id, node_ip = nodepool.getNode()

        if not node_id:
            return
        self.log.info("Running job for %s on %s/%s"%(self, node_id, node_ip))

        if not utils.testSSH(node_ip, Configuration().NODE_USERNAME, Configuration().NODE_KEY):
            self.log.error('Failed to get SSH object for node %s/%s.  Deleting node.'%(node_id, node_ip))
            nodepool.deleteNode(node_id)
            self.update(db, node_id=0)
            return

        self.update(db, node_id=node_id, node_ip=node_ip, result='')

        instruction_list = ["#!/bin/bash"]
        for instruction in instructions.update_devstackgate('origin/master'):
            instruction_list.append(" ".join(instruction))
        instruction_list.append(" ".join(instructions.check_out_testrunner()))
        if self.project_name == 'openstack/xenapi-os-testing':
            for instruction in instructions.update_testrunner(self.change_ref):
                instruction_list.append(" ".join(instruction))
        instruction_list.append("%s %s"%(" ".join(environment.get_environment(self.project_name, self.change_ref, self.branch)),
                                         " ".join(instructions.execute_test_runner())))

        for instruction in instruction_list:
            cmd = 'echo "%s" >> run_tests_env' % instruction
            utils.execute_command('ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i %s %s@%s %s'%(
                Configuration().NODE_KEY, Configuration().NODE_USERNAME, node_ip, cmd))
        cmd = "chmod +x run_tests_env"
        utils.execute_command('ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i %s %s@%s %s'%(
            Configuration().NODE_KEY, Configuration().NODE_USERNAME, node_ip, cmd))
        # For some reason invoking this immediately fails...
        time.sleep(5)
        utils.execute_command('ssh$-q$-o$BatchMode=yes$-o$UserKnownHostsFile=/dev/null$-o$StrictHostKeyChecking=no$-i$%s$%s@%s$'\
                              'nohup bash -c "source /opt/git/openstack-infra/devstack-gate/functions.sh; tsfilter /home/jenkins/run_tests_env" < /dev/null > run_tests.log 2>&1 &'%(
                Configuration().NODE_KEY, Configuration().NODE_USERNAME, node_ip), '$')
        self.update(db, state=constants.RUNNING)
예제 #9
0
    def runJob(self, db, nodepool):
        if self.node_id:
            nodepool.deleteNode(self.node_id)
            self.update(db, node_id=0)

        node_id, node_ip = nodepool.getNode()

        if not node_id:
            return
        self.log.info("Running job for %s on %s/%s"%(self, node_id, node_ip))

        if not utils.testSSH(node_ip, Configuration().NODE_USERNAME, Configuration().NODE_KEY):
            self.log.error('Failed to get SSH object for node %s/%s.  Deleting node.'%(node_id, node_ip))
            nodepool.deleteNode(node_id)
            self.update(db, node_id=0)
            return

        self.update(db, node_id=node_id, node_ip=node_ip, result='')

        instruction_list = ["#!/bin/bash"]
        for instruction in instructions.update_devstackgate('origin/master'):
            instruction_list.append(" ".join(instruction))
        instruction_list.append(" ".join(instructions.check_out_testrunner()))
        if self.project_name == 'stackforge/xenapi-os-testing':
            for instruction in instructions.update_testrunner(self.change_ref):
                instruction_list.append(" ".join(instruction))
        instruction_list.append("%s %s"%(" ".join(environment.get_environment(self.project_name, self.change_ref)),
                                         " ".join(instructions.execute_test_runner())))

        for instruction in instruction_list:
            cmd = 'echo "%s" >> run_tests_env' % instruction
            utils.execute_command('ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i %s %s@%s %s'%(
                Configuration().NODE_KEY, Configuration().NODE_USERNAME, node_ip, cmd))
        cmd = "chmod +x run_tests_env"
        utils.execute_command('ssh -q -o BatchMode=yes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -i %s %s@%s %s'%(
            Configuration().NODE_KEY, Configuration().NODE_USERNAME, node_ip, cmd))
        # For some reason invoking this immediately fails...
        time.sleep(5)
        utils.execute_command('ssh$-q$-o$BatchMode=yes$-o$UserKnownHostsFile=/dev/null$-o$StrictHostKeyChecking=no$-i$%s$%s@%s$'\
                              'nohup bash -c "source /opt/git/openstack-infra/devstack-gate/functions.sh; tsfilter /home/jenkins/run_tests_env" < /dev/null > run_tests.log 2>&1 &'%(
                Configuration().NODE_KEY, Configuration().NODE_USERNAME, node_ip), '$')
        self.update(db, state=constants.RUNNING)
 def test_command(self):
     self.assertEquals(
         "/usr/bin/git clone"
         " https://git.openstack.org/stackforge/xenapi-os-testing"
         " /home/jenkins/xenapi-os-testing".split(),
         instructions.check_out_testrunner())
 def test_command_with_explicit_repository(self):
     self.assertEquals(
         "/usr/bin/git clone"
         " SOMETHING"
         " /home/jenkins/xenapi-os-testing".split(),
         instructions.check_out_testrunner('SOMETHING'))
 def test_command(self):
     self.assertEquals(
         "/usr/bin/git clone"
         " https://github.com/citrix-openstack/xenapi-os-testing"
         " /home/jenkins/xenapi-os-testing".split(),
         instructions.check_out_testrunner())
 def test_command_with_explicit_repository(self):
     self.assertEquals(
         "/usr/bin/git clone"
         " SOMETHING"
         " /home/jenkins/xenapi-os-testing".split(),
         instructions.check_out_testrunner('SOMETHING'))