|
7 | 7 | class TestCvmfs(osgunittest.OSGTestCase):
|
8 | 8 |
|
9 | 9 | __check_path = '/cvmfs/cms.cern.ch/cmsset_default.sh'
|
| 10 | + __cvmfs_image = '/cvmfs/singularity.opensciencegrid.org/opensciencegrid/osg-wn:3.3-el6' |
10 | 11 | core.config['cvmfs.debug-dirs'] = []
|
11 | 12 |
|
| 13 | + def mountSingularityCVMFSRepo(self, repo): |
| 14 | + command = ('mkdir', '-p', /cvmfs + repo) |
| 15 | + status, stdout, stderr = core.system(command, False) |
| 16 | + if status != 0: |
| 17 | + self.fail("failed to mkdir /cvmfs/%s" % repo) |
| 18 | + |
| 19 | + command = ('mount', '-t', 'cvmfs', 'repo', '/cvmfs/' + repo) |
| 20 | + status, stdout, stderr = core.system(command, False) |
| 21 | + if status != 0: |
| 22 | + self.fail("failed to mount: %s, error: %s" % (repo,stdout)) |
| 23 | + |
12 | 24 | def debug_cvmfs(self, repo):
|
13 | 25 | temp_dir = tempfile.mkdtemp()
|
14 | 26 | core.config['cvmfs.debug-dirs'].append(temp_dir)
|
@@ -97,3 +109,32 @@ def test_03_oasis_config(self):
|
97 | 109 | # If the previous command failed, output better debug info
|
98 | 110 | if status != 0:
|
99 | 111 | self.debug_cvmfs(oasis_repo)
|
| 112 | + |
| 113 | + def test_04_singularity(self): |
| 114 | + core.skip_ok_unless_installed('singularity-runtime') |
| 115 | + core.skip_ok_unless_installed('cvmfs') |
| 116 | + singularity_repo = 'singularity.opensciencegrid.org' |
| 117 | + if core.el_release() <= 6: |
| 118 | + self.mountSingularityCVMFSRepo(singularity_repo) |
| 119 | + core.state['cvmfs.mounted'] = False |
| 120 | + |
| 121 | + command = ('ls', '/cvmfs') |
| 122 | + status, stdout, stderr = core.system(command, False) |
| 123 | + file_exists = os.path.exists('/cvmfs') |
| 124 | + self.assert_(file_exists, 'Cvmfs mount point missing') |
| 125 | + core.state['cvmfs.mounted'] = True |
| 126 | + |
| 127 | + command = ('ls', '/cvmfs/' + singularity_repo) |
| 128 | + status, stdout, stderr = core.system(command, False) |
| 129 | + |
| 130 | + # If the previous command failed, output better debug info |
| 131 | + if status != 0: |
| 132 | + self.fail("failed to find /cvmfs/%s" % singularity_repo) |
| 133 | + |
| 134 | + command = ('ls', self.__cvmfs_image) |
| 135 | + status, stdout, stderr = core.system(command, False) |
| 136 | + self.assert_(file_exists, 'cvfms image missing') |
| 137 | + command= ('singularity', 'exec', '--bind', '/cvmfs', self.__cvmfs_image, 'echo', 'working singularity image') |
| 138 | + status, stdout, stderr = core.system(command, False) |
| 139 | + fail = core.diagnose('singularity checking a file', command, status, stdout, stderr) |
| 140 | + self.assertEqual(status, 0, fail) |
0 commit comments