Exemplo n.º 1
0
def get_metadata(opts):
    """
    return a list of metadata objects that we would like to
    run test for.  If buildbot option is set then we read
    from the config file, otherwise we return the current
    IDK driver metadata
    @param opts: command line options dictionary.
    @return: list of all metadata data objects we would
             like to run tests for.
    """
    result = []
    if (opts.buildbot):
        devices = read_buildbot_config()
        ret = True
        for (key, config) in devices:
            make = config.get(BuildBotConfig.MAKE)
            model = config.get(BuildBotConfig.MODEL)
            flavor = config.get(BuildBotConfig.FLAVOR)
            metadata = Metadata(make, model, flavor)
            result.append(metadata)
        pass
    else:
        result.append(Metadata())

    return result
Exemplo n.º 2
0
    def get_metadata(self):
        # get which dataset agent is selected from the current metadata, use
        # this to get metadata from the cloned repo
        tmp_metadata = Metadata()

        # read metadata from the cloned repo
        self.metadata = Metadata(tmp_metadata.driver_make,
                                 tmp_metadata.driver_model,
                                 tmp_metadata.driver_name,
                                 REPODIR + '/marine-integrations')

        return self.metadata
Exemplo n.º 3
0
    def test_constructor(self):
        """
        Test object creation
        """
        default_metadata = Metadata()
        self.assertTrue(default_metadata)

        specific_metadata = Metadata('seabird', 'sbe37smb', 'ooicore')
        self.assertTrue(specific_metadata)

        failure_metadata = None
        try:
            failure_metadata = Metadata('seabird')
        except InvalidParameters, e:
            self.assertTrue(e)
Exemplo n.º 4
0
    def test_list(self):
        """
        Test the full file manifest
        """
        filelist = DriverFileList(Metadata(), ROOTDIR, self.implfile(), self.nosefile())
        self.assertTrue(filelist)

        known_files = [
                      'mi/__init__.py',
                      'mi/base.py',
                      'mi/base2.py',
                      'mi/base3.py',
                      'mi/base4.py',
                      'mi/foo/__init__.py',
                      'mi/foo/impl.py',
                      'mi/foo/res/test_file',
                      'mi/foo/test/__init__.py',
                      'mi/foo/test/test_process.py',
                      'res/config/mi-logging.yml'
        ]
        
        files = filelist.files()
        #log.debug( "F: %s" % files)

        self.assertEqual(sorted(files), sorted(known_files))
Exemplo n.º 5
0
 def test_sbe37_list(self):
     metadata = Metadata('seabird', 'sbe37smb', 'ooicore')
     filelist = DriverFileList(metadata, Config().get('working_repo'))
     known_files = [
         'mi/instrument/seabird/sbe37smb/ooicore/comm_config.yml',
         'mi/instrument/seabird/sbe37smb/ooicore/metadata.yml',
         'mi/__init__.py', 'mi/core/__init__.py', 'mi/core/common.py',
         'mi/core/exceptions.py', 'mi/core/instrument/__init__.py',
         'mi/core/instrument/data_particle.py',
         'mi/core/instrument/instrument_driver.py',
         'mi/core/instrument/instrument_fsm.py',
         'mi/core/instrument/instrument_protocol.py',
         'mi/core/instrument/protocol_param_dict.py',
         'mi/instrument/__init__.py', 'mi/instrument/seabird/__init__.py',
         'mi/instrument/seabird/sbe37smb/__init__.py',
         'mi/instrument/seabird/sbe37smb/ooicore/__init__.py',
         'mi/instrument/seabird/sbe37smb/ooicore/driver.py',
         'mi/core/instrument/driver_client.py',
         'mi/core/instrument/driver_process.py',
         'mi/core/instrument/zmq_driver_client.py',
         'mi/core/instrument/zmq_driver_process.py', 'mi/idk/__init__.py',
         'mi/idk/comm_config.py', 'mi/idk/common.py', 'mi/idk/config.py',
         'mi/idk/exceptions.py', 'mi/idk/prompt.py', 'mi/core/log.py',
         'mi/core/tcp_client.py', 'mi/core/unit_test.py', 'mi/idk/util.py',
         'mi/idk/instrument_agent_client.py',
         'mi/core/instrument/port_agent_client.py',
         'mi/core/instrument/logger_client.py', 'mi/idk/unit_test.py',
         'mi/instrument/seabird/sbe37smb/ooicore/test/__init__.py',
         'mi/instrument/seabird/sbe37smb/ooicore/test/test_driver.py'
     ]
     self.maxDiff = None
     files = filelist.files()
     log.debug("FILES = " + str(sorted(files)))
     self.assertEqual(sorted(files), sorted(known_files))
Exemplo n.º 6
0
 def overwrite(self):
     """
     @brief Overwrite the current files with what is stored in the current metadata file.
     """
     self.metadata = Metadata()
     config_path = "%s/%s" % (self.metadata.driver_dir(), CommConfig.config_filename())
     self.comm_config = CommConfig.get_config_from_file(config_path)
     self.generate_code(force = True)
Exemplo n.º 7
0
 def setUp(self):
     """
     Setup the test case
     """
     metadata = Metadata(TEST_DRIVER_MAKE, TEST_DRIVER_MODEL,
                         TEST_DRIVER_FLAVOR)
     self.assertTrue(metadata)
     self.nose = NoseTest(metadata)
     self.assertTrue(self.nose)
Exemplo n.º 8
0
    def run(self):
        print "*** Starting Driver Packaging Process***"

        # store the original directory since we will be navigating away from it
        original_dir = os.getcwd()

        # first create a temporary clone of ooici to work with
        self.clone_repo()

        # get which dataset agent is selected from the current metadata, use
        # this to get metadata from the cloned repo
        tmp_metadata = Metadata()
        # read metadata from the cloned repo
        self.metadata = Metadata(tmp_metadata.driver_make,
                                 tmp_metadata.driver_model,
                                 tmp_metadata.driver_name,
                                 REPODIR + '/marine-integrations')

        if "--repackage" in sys.argv:
            self.get_repackage_version(self.build_name())
        else:
            new_version = self.update_version()
            base_name = self.build_name() + '_' + new_version.replace('.', '_')
            self.make_branch(base_name)

        if "--no-test" in sys.argv:
            f = open(self.log_path(), "w")
            f.write("Tests manually bypassed with --no-test option\n")
            f.close()
            self.package_driver()
        else:
            if (self.run_qualification_tests()):
                self.package_driver()

        if not "--no-push" in sys.argv and not "--repackage" in sys.argv:
            cmd = 'git push'
            output = subprocess.check_output(cmd, shell=True)
            if len(output) > 0:
                log.debug('git push returned: %s', output)

        # go back to the original directory
        os.chdir(original_dir)

        print "Package Created: " + self.archive_path()
Exemplo n.º 9
0
    def fetch_metadata(self):
        """
        @brief collect metadata from the user
        """

        self.metadata = Metadata()
        self.driver_make = self.metadata.driver_make
        self.driver_model = self.metadata.driver_model
        self.driver_name = self.metadata.driver_name

        if not (self.driver_make and self.driver_model and self.driver_name):
            self.driver_make = prompt.text('Driver Make', self.driver_make)
            self.driver_model = prompt.text('Driver Model', self.driver_model)
            self.driver_name = prompt.text('Driver Name', self.driver_name)

        if not (self.driver_class):
            self.driver_class = prompt.text('Driver Class', self.driver_class)

        self.metadata = Metadata(self.driver_make, self.driver_model,
                                 self.driver_name)
Exemplo n.º 10
0
    def fetch_metadata(self):
        """
        @brief collect metadata from the user
        """
        if not (self.driver_make and self.driver_model and self.driver_name):
            self.driver_make = prompt.text('Driver Make', self.driver_make)
            self.driver_model = prompt.text('Driver Model', self.driver_model)
            self.driver_name = prompt.text('Driver Name', self.driver_name)

        self.metadata = Metadata(self.driver_make, self.driver_model,
                                 self.driver_name)
        self.driver_version = prompt.text('Driver Version',
                                          self.metadata.version)
Exemplo n.º 11
0
    def setUp(self):
        IDKPackageNose.setUp(self)


        self._metadata = Metadata('seabird', 'sbe37smb', 'ooicore')
        self._generator = EggGenerator(self._metadata)

        # Ensure the base build dir doesnt exists
        build_dir = path.join(self._generator._tmp_dir(), self._generator._build_name())
        if exists(build_dir):
            rmtree(build_dir)
            self._generator._generate_build_dir()

        self._repo_dir = Config().get('working_repo')
        self._tmp_dir  = Config().get('tmp_dir')
Exemplo n.º 12
0
    def test_extra_list(self):
        """
        Find all the files in the driver directory
        """
        rootdir = dirname(TESTDIR)
        filelist = DriverFileList(Metadata(), ROOTDIR, self.implfile(), self.nosefile())
        self.assertTrue(filelist)
        
        known_files = [
            '%s/res/test_file' % TESTDIR
        ]
        
        files = filelist._extra_files()

        #log.debug(sorted(files))
        #log.debug(sorted(known_files))

        self.assertEqual(sorted(files), sorted(known_files))
Exemplo n.º 13
0
def _get_file():
    """
    build the data file name.  Then loop until the file can be open successfully
    @return: file pointer to the data file
    """
    metadata = Metadata()
    config_path = "%s/%s" % (metadata.driver_dir(), CommConfig.config_filename())
    comm_config = CommConfig.get_config_from_file(config_path)
    date = time.strftime("%Y%m%d")

    filename = "%s/port_agent_%d.%s.data" % (DATADIR, comm_config.command_port, date)

    file = None
    while(not file):
        try:
            file = open(filename)
        except Exception as e:
            sys.stderr.write("file open failed: %s\n" % e)
            time.sleep(SLEEP)

    return file
Exemplo n.º 14
0
 def checkout_version(self):
     """
     @brief Check out this driver version from the repository if it exists
     """
     base_name = '%s_%s_%s_%s' % (self.driver_make, self.driver_model,
                                  self.driver_name,
                                  self.driver_version.replace('.', '_'))
     cmd = 'git tag -l ' + 'release_' + base_name
     output = subprocess.check_output(cmd, shell=True)
     if len(output) > 0:
         # this tag exists, check out the branch
         #(tag is the branch name with 'release_' in front)
         # checkout the branch so changes can be saved
         cmd = 'git checkout ' + base_name
         output = subprocess.check_output(cmd, shell=True)
         # re-read metadata file since it has changed
         self.metadata = Metadata(self.driver_make, self.driver_model,
                                  self.driver_name)
     else:
         raise DriverDoesNotExist("Driver version %s does not exist",
                                  self.driver_version)
Exemplo n.º 15
0
    def test_nose_with_testname(self):
        '''
        Test nose when specifying a specific test name
        '''

        metadata = Metadata(TEST_DRIVER_MAKE, TEST_DRIVER_MODEL,
                            TEST_DRIVER_FLAVOR)
        self.assertTrue(metadata)
        self.nose = NoseTest(metadata, testname='test_autosample')
        self.assertTrue(self.nose)

        # Verify we can get the test module name and file
        self.assertEqual(self.nose._driver_test_module(), DRIVER_TEST_MODULE)
        test_file = self.nose._driver_test_module().replace('.', '/') + ".py"

        self.assertTrue(test_file in self.nose._driver_test_filename())

        self.assertEqual(self.nose._unit_test_class, 'SBEUnitTestCase')
        self.assertEqual(self.nose._int_test_class, 'SBEIntTestCase')
        self.assertEqual(self.nose._qual_test_class,
                         'SBEQualificationTestCase')

        self.assertEqual(self.nose._testname, 'test_autosample')

        self.assertEqual(
            self.nose._unit_test_module_param(),
            "%s:%s.%s" % (self.nose._driver_test_filename(),
                          self.nose._unit_test_class, 'test_autosample'))

        self.assertEqual(
            self.nose._int_test_module_param(),
            "%s:%s.%s" % (self.nose._driver_test_filename(),
                          self.nose._int_test_class, 'test_autosample'))

        self.assertEqual(
            self.nose._qual_test_module_param(),
            "%s:%s.%s" % (self.nose._driver_test_filename(),
                          self.nose._qual_test_class, 'test_autosample'))
Exemplo n.º 16
0
    def _store_package_files(self):
        """
        @brief Store all files in zip archive and add them to the manifest file
        """
        # make sure metadata is up to date
        self.metadata = Metadata(self.metadata.driver_make,
                                 self.metadata.driver_model,
                                 self.metadata.driver_name,
                                 REPODIR + '/marine-integrations')

        self.generator = DriverGenerator(self.metadata)
        egg_generator = EggGenerator(self.metadata)
        egg_file = egg_generator.save()

        # Add egg
        self._add_file(egg_file, 'egg', 'python driver egg package')

        # Add the package metadata file
        self._add_file(self.metadata.metadata_path(),
                       description='package metadata')

        # Add the qualification test log
        self._add_file(self.log_path(),
                       description='qualification tests results')

        # Store parameter/command string description file
        str_path = "%s/%s" % (self.generator.resource_dir(),
                              self.string_file())
        if os.path.exists(str_path):
            self._add_file(str_path, 'resource', 'driver string file')

        # Store additional resource files
        self._store_resource_files()

        # Finally save the manifest file.  This must be last of course
        self._add_file(self.manifest().manifest_path(),
                       description='package manifest file')
Exemplo n.º 17
0
 def fetch_metadata(self):
     """
     @brief collect metadata from the user
     """
     self.metadata = Metadata()
     self.metadata.get_from_console()
Exemplo n.º 18
0
 def get_metadata(self):
     self.metadata = Metadata(self.driver_make, self.driver_model, self.driver_name)
     return self.metadata
Exemplo n.º 19
0
            except IOError as e:
                print "Encountered problem writing strings template, complete by hand"

    def display_report(self):
        """
        @brief Display a report of the files created to STDOUT
        """
        print("*** Generation Complete ***")
        print(" - Driver File: " + self.driver_dir() + "/" +
              self.driver_filename())
        print(" - Test File: " + self.driver_test_dir() + "/" +
              self.driver_test_filename())
        print(" - Resource Directory: " + self.resource_dir())

    def generate(self):
        """
        @brief Main method for generating drivers.  Assumption: this is run from the console.
        """
        print("*** Generating Driver Code ***")

        self.build_directories()
        self.generate_code()
        self.display_report()


if __name__ == '__main__':
    metadata = Metadata()
    driver = DriverGenerator(metadata)

    driver.generate()
Exemplo n.º 20
0
 def fetch_metadata(self):
     """
     @brief collect metadata from the user
     """
     self.metadata = Metadata()