Esempio n. 1
0
def test_fetcher_cmd_no_revision(mocker, init_env):
    """ docstring """

    # pylint: disable=redefined-outer-name, unused-variable

    scm = {
        'type': 'svn',
        'url': 'svn://toto.fr/trunk',
        'revisions': ['20'],
        'files': ['file1']
    }
    mock_popen = mocker.patch("ubench.core.fetcher.Popen")
    mock_credentials = mocker.patch(
        "ubench.core.fetcher.Fetcher.get_credentials")
    fetch_bench = fetcher.Fetcher(
        resource_dir=init_env.config['resources_path'],
        benchmark_name='simple')
    fetch_bench.scm_fetch(scm['url'], scm['files'], scm['type'], [''], None,
                          None)
    username = os.getlogin()
    fetch_command = "svn export {0}/{1} {1} --username {2} --password '' ".format(
        scm['url'], scm['files'][0], username)
    fetch_command += "--trust-server-cert --non-interactive --no-auth-cache"
    mock_popen.assert_called_with(fetch_command,
                                  cwd=os.path.join(
                                      init_env.config['resources_path'],
                                      'simple', 'svn'),
                                  shell=True,
                                  universal_newlines=True)
Esempio n. 2
0
def test_fetcher_dir_rev(mocker,init_env):
  # Test directory creation for each revision
  # if you want to test real repo: svn://scm.gforge.inria.fr/svnroot/darshan-ruby/trunk,  https://github.com/poelzi/git-clone-test
  scms = [
    {'type': 'svn','url' : 'svn://toto.fr/trunk','revisions': ['20'],'files': ['file1','file2']},
          {'type': 'git','url' : 'https://toto.fr/git-repo','revisions': ['e2be38ed38e4'],'files': ['git-repo']}]

  def mocksubpopen(args,shell,cwd):
    # simulating directory creation by scms
    for scm in scms:
      for rev in scm['revisions']:
        for f in scm['files']:
          path = os.path.join(cwd,f)
          if not os.path.exists(path):
            os.makedirs(path)
    return Popen("date")

  mock_popen = mocker.patch("ubench.core.fetcher.Popen",side_effect=mocksubpopen)
  mock_credentials = mocker.patch("ubench.core.fetcher.Fetcher.get_credentials")
  fetch_bench = fetcher.Fetcher(resource_dir=init_env.config['resources_path'],benchmark_name='simple')
  for scm in scms:
    fetch_bench.scm_fetch(scm['url'],scm['files'],scm['type'],scm['revisions'])
    for rev in scm['revisions']:
      assert os.path.exists(os.path.join(init_env.config['resources_path'],'simple',scm['type'],rev))
      assert os.path.exists(os.path.join(init_env.config['resources_path'],'simple',scm['type'],rev + "_"+os.path.basename(scm['files'][0])))
    def fetch(self):
        """ TOCOMMENT """
        for benchmark_name in self.benchmark_list:
            benchmark_dir = os.path.join(self.uconf.benchmark_dir,
                                         benchmark_name)
            benchmark_files = [file_b for  file_b in os.listdir(benchmark_dir) \
                               if file_b.endswith(".xml")]
            jube_xml_files = jube_xml_parser.JubeXMLParser(
                benchmark_dir, benchmark_files)
            multisource = jube_xml_files.get_bench_multisource()

            if multisource is None:
                print "ERROR !! : Multisource information for benchmark not found"
                return None

            fetch_bench = fetcher.Fetcher(resource_dir=self.uconf.resource_dir,\
                                          benchmark_name=benchmark_name)
            for source in multisource:

                if not source.has_key('do_cmds'):
                    source['do_cmds'] = None

                if source['protocol'] == 'https':
                    fetch_bench.https(source['url'], source['files'])
                elif source['protocol'] == 'svn' or source['protocol'] == 'git':
                    if not source.has_key('revision'):
                        source['revision'] = None
                    if not source.has_key('branch'):
                        source['branch'] = None

                    fetch_bench.scm_fetch(source['url'], source['files'], \
                                          source['protocol'], source['revision'], \
                                          source['branch'], source['do_cmds'])
                elif source['protocol'] == 'local':
                    fetch_bench.local(source['files'], source['do_cmds'])
Esempio n. 4
0
def test_fetcher_cmd(mocker,init_env):
  scm = {'type': 'svn','url' : 'svn://toto.fr/trunk','revisions': ['20'],'files': ['file1']}
  mock_popen = mocker.patch("ubench.core.fetcher.Popen")
  mock_credentials = mocker.patch("ubench.core.fetcher.Fetcher.get_credentials")
  fetch_bench = fetcher.Fetcher(resource_dir=init_env.config['resources_path'],benchmark_name='simple')
  fetch_bench.scm_fetch(scm['url'],scm['files'],scm['type'],scm['revisions'])
  username = os.getlogin()
  fetch_command = "svn export -r {0} {1}/{2} {2} --username {3} --password '' ".format(scm['revisions'][0],scm['url'],scm['files'][0],username)
  fetch_command += "--trust-server-cert --non-interactive --no-auth-cache"
  mock_popen.assert_called_with(fetch_command,cwd=os.path.join(init_env.config['resources_path'],'simple','svn',scm['revisions'][0]) , shell=True)
Esempio n. 5
0
def test_fetcher_dir_rev(mocker, init_env):
    """ docstring """

    # pylint: disable=redefined-outer-name, unused-argument, unused-variable

    scms = [{
        'type': 'svn',
        'url': 'svn://toto.fr/trunk',
        'revisions': ['20'],
        'files': ['file1', 'file2']
    }, {
        'type': 'git',
        'url': 'https://toto.fr/git-repo',
        'revisions': ['e2be38ed38e4'],
        'files': ['git-repo']
    }]

    def mocksubpopen(args, shell, cwd, universal_newlines=False):
        """ docstring """

        # simulating directory creation by scms
        for scm in scms:
            for rev in scm['revisions']:
                for f in scm['files']:  # pylint: disable=invalid-name
                    path = os.path.join(cwd, f)
                    if not os.path.exists(path):
                        os.makedirs(path)
        return Popen("date")

    mock_popen = mocker.patch("ubench.core.fetcher.Popen",
                              side_effect=mocksubpopen)
    mock_credentials = mocker.patch(
        "ubench.core.fetcher.Fetcher.get_credentials")
    fetch_bench = fetcher.Fetcher(
        resource_dir=init_env.config['resources_path'],
        benchmark_name='simple')
    for scm in scms:
        fetch_bench.scm_fetch(scm['url'], scm['files'], scm['type'],
                              scm['revisions'])
        for rev in scm['revisions']:
            assert os.path.exists(
                os.path.join(init_env.config['resources_path'], 'simple',
                             scm['type'], rev))
            assert os.path.exists(
                os.path.join(init_env.config['resources_path'], 'simple',
                             scm['type'],
                             rev + "_" + os.path.basename(scm['files'][0])))

    assert mock_popen.call_count == 2