Пример #1
0
    def test_01_request_condor_write_scitoken(self):
        core.state['token.condor_write_created'] = False
        core.config['token.condor_write'] = '/tmp/condor_write.scitoken'

        core.skip_ok_unless_installed('htcondor-ce', 'condor')
        self.skip_ok_if(
            core.PackageVersion('condor') <= '8.9.4',
            'HTCondor version does not support SciToken submission')
        self.skip_ok_if(os.path.exists(core.config['token.condor_write']),
                        'SciToken with HTCondor WRITE already exists')

        hostname = core.get_hostname()
        try:
            token = request_demo_scitoken('condor:/READ condor:/WRITE',
                                          audience=f'{hostname}:9619')
        except error.URLError as exc:
            self.fail(
                f"Failed to request token from demo.scitokens.org:\n{exc}")

        ids = (0, 0)
        if core.state['user.verified']:
            user = pwd.getpwnam(core.options.username)
            ids = (user.pw_uid, user.pw_gid)

        files.write(core.config['token.condor_write'],
                    core.to_str(token),
                    backup=False,
                    chown=ids)
        core.state['token.condor_write_created'] = True
Пример #2
0
 def test_02_xrootd_fetch_from_origin(self):
     name, contents = self.testfiles[0]
     path = os.path.join(getcfg("OriginExport"), name)
     result, _, _ = \
         core.check_system(["xrdcp", "-d1", "-N", "-f",
                            "root://localhost:%d/%s" % (getcfg("OriginXrootPort"), path),
                            "-"], "Checking xroot copy from origin")
     self.assertEqualVerbose(core.to_str(result), contents,
                             "downloaded file mismatch")
Пример #3
0
 def test_03_http_fetch_from_cache(self):
     name, contents = self.testfiles[1]
     path = os.path.join(getcfg("OriginExport"), name)
     try:
         f = urlopen("http://localhost:%d/%s" %
                     (getcfg("CacheHTTPPort"), path))
         result = core.to_str(f.read())
     except IOError as e:
         self.fail("Unable to download from cache via http: %s" % e)
     self.assertEqualVerbose(result, contents, "downloaded file mismatch")
     self.assertCached(name, contents)
Пример #4
0
 def assertCached(self, name, contents, auth=False):
     OriginExport = getcfg("OriginExport")
     if auth:
         OriginExport = getcfg("OriginAuthExport")
     fpath = os.path.join(getcfg("CacheRootdir"),
                          getcfg("OriginExport").lstrip("/"), name)
     self.assertTrue(os.path.exists(fpath), name + " not cached")
     self.assertEqualVerbose(actual=core.to_str(
         files.read(fpath, as_single_string=True)),
                             expected=contents,
                             message="cached file %s mismatch" % name)
Пример #5
0
 def test_05_stashcp(self):
     command = ["stashcp", "-d"]
     if core.PackageVersion('stashcache-client') < '5.1.0-5':
         command.append("--cache=root://localhost")
     name, contents = self.testfiles[3]
     path = os.path.join(getcfg("OriginExport"), name)
     with tempfile.NamedTemporaryFile(mode="r+b") as tf:
         core.check_system(command + [path, tf.name], "Checking stashcp")
         result = tf.read()
     self.assertEqualVerbose(core.to_str(result), contents,
                             "stashcp'ed file mismatch")
     self.assertCached(name, contents)
Пример #6
0
 def test_05_stashcp(self):
     command = ["stashcp", "-d"]
     if core.rpm_is_installed("stashcp"):
         # stashcp (the Go version) doesn't use caches.json so specify the cache on the command line
         # (it also doesn't use root://)
         command.append("--cache=http://localhost:%d" %
                        getcfg("CacheHTTPPort"))
     name, contents = self.testfiles[3]
     path = os.path.join(getcfg("OriginExport"), name)
     with tempfile.NamedTemporaryFile(mode="r+b") as tf:
         core.check_system(command + [path, tf.name], "Checking stashcp")
         result = tf.read()
     self.assertEqualVerbose(core.to_str(result), contents,
                             "stashcp'ed file mismatch")
     self.assertCached(name, contents)
Пример #7
0
 def test_07_ceview(self):
     core.config['condor-ce.view-listening'] = False
     core.skip_ok_unless_installed('htcondor-ce-view')
     view_url = 'http://%s:%s' % (core.get_hostname(), int(core.config['condor-ce.view-port']))
     try:
         src = core.to_str(urlopen(view_url).read())
         core.log_message(src)
     except EnvironmentError as err:
         debug_file = '/var/log/condor-ce/CEViewLog'
         debug_contents = 'Contents of %s\n%s\n' % (debug_file, '=' * 20)
         try:
             debug_contents += files.read(debug_file, True)
         except EnvironmentError:
             debug_contents += 'Failed to read %s\n' % debug_file
         core.log_message(debug_contents)
         self.fail('Could not reach HTCondor-CE View at %s: %s' % (view_url, err))
     self.assertTrue(re.search(r'HTCondor-CE Overview', src), 'Failed to find expected CE View contents')
     core.config['condor-ce.view-listening'] = True