예제 #1
0
 def test_action_namespaces(self):
     self.assertIsNotNone(self.server_job)
     self.assertIsNotNone(self.client_job)
     deploy_server = [
         action for action in self.server_job.pipeline.actions
         if action.name == "tftp-deploy"
     ][0]
     self.assertIn(MultinodeProtocol.name, deploy_server.parameters.keys())
     self.assertIn(VlandProtocol.name, deploy_server.parameters.keys())
     self.assertEqual(["common"],
                      get_test_action_namespaces(
                          self.server_job.parameters))
     namespace = self.server_job.parameters.get("namespace")
     self.assertIsNone(namespace)
     namespace = self.client_job.parameters.get("namespace")
     self.assertIsNone(namespace)
     deploy_client = [
         action for action in self.client_job.pipeline.actions
         if action.name == "tftp-deploy"
     ][0]
     self.assertIn(MultinodeProtocol.name, deploy_client.parameters.keys())
     self.assertIn(VlandProtocol.name, deploy_client.parameters.keys())
     key_list = []
     for block in self.client_job.parameters["actions"]:
         key_list.extend(block.keys())
     self.assertEqual(key_list,
                      ["deploy", "boot", "test"])  # order is important
     self.assertEqual(["common"],
                      get_test_action_namespaces(
                          self.client_job.parameters))
     key_list = []
     for block in self.server_job.parameters["actions"]:
         key_list.extend(block.keys())
     self.assertEqual(key_list,
                      ["deploy", "boot", "test"])  # order is important
예제 #2
0
 def test_action_namespaces(self):
     self.assertIsNotNone(self.server_job)
     self.assertIsNotNone(self.client_job)
     deploy_server = [
         action for action in self.server_job.pipeline.actions
         if action.name == 'tftp-deploy'
     ][0]
     self.assertIn(MultinodeProtocol.name, deploy_server.parameters.keys())
     self.assertIn(VlandProtocol.name, deploy_server.parameters.keys())
     self.assertEqual(['common'],
                      get_test_action_namespaces(
                          self.server_job.parameters))
     namespace = self.server_job.parameters.get('namespace', None)
     self.assertIsNone(namespace)
     namespace = self.client_job.parameters.get('namespace', None)
     self.assertIsNone(namespace)
     deploy_client = [
         action for action in self.client_job.pipeline.actions
         if action.name == 'tftp-deploy'
     ][0]
     self.assertIn(MultinodeProtocol.name, deploy_client.parameters.keys())
     self.assertIn(VlandProtocol.name, deploy_client.parameters.keys())
     key_list = []
     for block in self.client_job.parameters['actions']:
         key_list.extend(block.keys())
     self.assertEqual(key_list,
                      ['deploy', 'boot', 'test'])  # order is important
     self.assertEqual(['common'],
                      get_test_action_namespaces(
                          self.client_job.parameters))
     key_list = []
     for block in self.server_job.parameters['actions']:
         key_list.extend(block.keys())
     self.assertEqual(key_list,
                      ['deploy', 'boot', 'test'])  # order is important
예제 #3
0
 def test_action_namespaces(self):
     self.assertIsNotNone(self.server_job)
     self.assertIsNotNone(self.client_job)
     deploy_server = [action for action in self.server_job.pipeline.actions if action.name == 'tftp-deploy'][0]
     self.assertIn(MultinodeProtocol.name, deploy_server.parameters.keys())
     self.assertIn(VlandProtocol.name, deploy_server.parameters.keys())
     self.assertEqual(['common'], get_test_action_namespaces(self.server_job.parameters))
     namespace = self.server_job.parameters.get('namespace', None)
     self.assertIsNone(namespace)
     namespace = self.client_job.parameters.get('namespace', None)
     self.assertIsNone(namespace)
     deploy_client = [action for action in self.client_job.pipeline.actions if action.name == 'tftp-deploy'][0]
     self.assertIn(MultinodeProtocol.name, deploy_client.parameters.keys())
     self.assertIn(VlandProtocol.name, deploy_client.parameters.keys())
     key_list = []
     for block in self.client_job.parameters['actions']:
         key_list.extend(block.keys())
     self.assertEqual(key_list, ['deploy', 'boot', 'test'])  # order is important
     self.assertEqual(['common'], get_test_action_namespaces(self.client_job.parameters))
     key_list = []
     for block in self.server_job.parameters['actions']:
         key_list.extend(block.keys())
     self.assertEqual(key_list, ['deploy', 'boot', 'test'])  # order is important
예제 #4
0
파일: overlay.py 프로젝트: haoyujie/mylava
    def run(self, connection, max_end_time):  # pylint: disable=too-many-locals
        """
        Check if a lava-test-shell has been requested, implement the overlay
        * create test runner directories beneath the temporary location
        * copy runners into test runner directories
        """
        tmp_dir = self.mkdtemp()
        namespace = self.parameters.get('namespace')
        if namespace:
            if namespace not in get_test_action_namespaces(
                    self.job.parameters):
                self.logger.info("[%s] skipped %s - no test action.",
                                 namespace, self.name)
                return connection
        self.set_namespace_data(action='test',
                                label='shared',
                                key='location',
                                value=tmp_dir)
        lava_test_results_dir = self.get_namespace_data(
            action='test', label='results', key='lava_test_results_dir')
        if not lava_test_results_dir:
            raise LAVABug("Unable to identify top level lava test directory")
        shell = self.get_namespace_data(action='test',
                                        label='shared',
                                        key='lava_test_sh_cmd')
        self.logger.debug("[%s] Preparing overlay tarball in %s", namespace,
                          tmp_dir)
        lava_path = os.path.abspath("%s/%s" % (tmp_dir, lava_test_results_dir))
        for runner_dir in ['bin', 'tests', 'results']:
            # avoid os.path.join as lava_test_results_dir startswith / so location is *dropped* by join.
            path = os.path.abspath("%s/%s" % (lava_path, runner_dir))
            if not os.path.exists(path):
                os.makedirs(path, 0o755)
                self.logger.debug("makedir: %s", path)
        for fname in self.scripts_to_copy:
            with open(fname, 'r') as fin:
                foutname = os.path.basename(fname)
                output_file = '%s/bin/%s' % (lava_path, foutname)
                if "distro" in fname:
                    distribution = os.path.basename(os.path.dirname(fname))
                    self.logger.debug("Updating %s (%s)", output_file,
                                      distribution)
                else:
                    self.logger.debug("Creating %s", output_file)
                with open(output_file, 'w') as fout:
                    fout.write("#!%s\n\n" % shell)
                    if foutname == 'lava-target-mac':
                        fout.write("TARGET_DEVICE_MAC='%s'\n" %
                                   self.target_mac)
                    if foutname == 'lava-target-ip':
                        fout.write("TARGET_DEVICE_IP='%s'\n" % self.target_ip)
                    if foutname == 'lava-probe-ip':
                        fout.write("PROBE_DEVICE_IP='%s'\n" % self.probe_ip)
                    if foutname == 'lava-probe-channel':
                        fout.write("PROBE_DEVICE_CHANNEL='%s'\n" %
                                   self.probe_channel)
                    if foutname == 'lava-target-storage':
                        fout.write('LAVA_STORAGE="\n')
                        for method in self.job.device.get(
                                'storage_info', [{}]):
                            for key, value in method.items():
                                if key == 'yaml_line':
                                    continue
                                self.logger.debug("storage methods:\t%s\t%s",
                                                  key, value)
                                fout.write(r"\t%s\t%s\n" % (key, value))
                        fout.write('"\n')
                    fout.write(fin.read())
                    os.fchmod(fout.fileno(), self.xmod)

        # Generate the file containing the secrets
        if 'secrets' in self.job.parameters:
            self.logger.debug("Creating %s/secrets", lava_path)
            with open(os.path.join(lava_path, 'secrets'), 'w') as fout:
                for key, value in self.job.parameters['secrets'].items():
                    if key == 'yaml_line':
                        continue
                    fout.write("%s=%s\n" % (key, value))

        connection = super().run(connection, max_end_time)
        return connection
예제 #5
0
    def run(self, connection, max_end_time, args=None):  # pylint: disable=too-many-locals
        """
        Check if a lava-test-shell has been requested, implement the overlay
        * create test runner directories beneath the temporary location
        * copy runners into test runner directories
        """
        tmp_dir = self.mkdtemp()
        namespace = self.parameters.get('namespace', None)
        if namespace:
            if namespace not in get_test_action_namespaces(self.job.parameters):
                self.logger.info("[%s] skipped %s - no test action.", namespace, self.name)
                return connection
        self.set_namespace_data(action='test', label='shared', key='location', value=tmp_dir)
        lava_test_results_dir = self.get_namespace_data(action='test', label='results', key='lava_test_results_dir')
        if not lava_test_results_dir:
            raise LAVABug("Unable to identify top level lava test directory")
        shell = self.get_namespace_data(action='test', label='shared', key='lava_test_sh_cmd')
        self.logger.debug("[%s] Preparing overlay tarball in %s", namespace, tmp_dir)
        lava_path = os.path.abspath("%s/%s" % (tmp_dir, lava_test_results_dir))
        for runner_dir in ['bin', 'tests', 'results']:
            # avoid os.path.join as lava_test_results_dir startswith / so location is *dropped* by join.
            path = os.path.abspath("%s/%s" % (lava_path, runner_dir))
            if not os.path.exists(path):
                os.makedirs(path, 0o755)
                self.logger.debug("makedir: %s", path)
        for fname in self.scripts_to_copy:
            with open(fname, 'r') as fin:
                foutname = os.path.basename(fname)
                output_file = '%s/bin/%s' % (lava_path, foutname)
                if "distro" in fname:
                    distribution = os.path.basename(os.path.dirname(fname))
                    self.logger.debug("Updating %s (%s)", output_file, distribution)
                else:
                    self.logger.debug("Creating %s", output_file)
                with open(output_file, 'w') as fout:
                    fout.write("#!%s\n\n" % shell)
                    if foutname == 'lava-target-mac':
                        fout.write("TARGET_DEVICE_MAC='%s'\n" % self.target_mac)
                    if foutname == 'lava-target-ip':
                        fout.write("TARGET_DEVICE_IP='%s'\n" % self.target_ip)
                    if foutname == 'lava-probe-ip':
                        fout.write("PROBE_DEVICE_IP='%s'\n" % self.probe_ip)
                    if foutname == 'lava-probe-channel':
                        fout.write("PROBE_DEVICE_CHANNEL='%s'\n" % self.probe_channel)
                    if foutname == 'lava-target-storage':
                        fout.write('LAVA_STORAGE="\n')
                        for method in self.job.device.get('storage_info', [{}]):
                            for key, value in method.items():
                                if key == 'yaml_line':
                                    continue
                                self.logger.debug("storage methods:\t%s\t%s", key, value)
                                fout.write(r"\t%s\t%s\n" % (key, value))
                        fout.write('"\n')
                    fout.write(fin.read())
                    os.fchmod(fout.fileno(), self.xmod)

        # Generate the file containing the secrets
        if 'secrets' in self.job.parameters:
            self.logger.debug("Creating %s/secrets", lava_path)
            with open(os.path.join(lava_path, 'secrets'), 'w') as fout:
                for key, value in self.job.parameters['secrets'].items():
                    if key == 'yaml_line':
                        continue
                    fout.write("%s=%s\n" % (key, value))

        connection = super(OverlayAction, self).run(connection, max_end_time, args)
        return connection