def test_full(self): status_file = os.path.join(self.rdir, "status") self.hpc.syscall("rm", ["-r", self.rdir]) self.hpc.syscall("mkdir", ["-p", self.rdir]) with open(self.testFiles[0], "w") as fh: fh.write('''#! /bin/bash sleep 8 echo "finished" > {status} '''.format(status=status_file, rdir=self.rdir)) self.hpc.put_files([self.testFiles[0]], self.rdir) qjob = self.hpc.submit_job(os.path.join(self.rdir, self.testFiles[0]), []) self.assertIsNotNone(qjob, "job submitted") qjob.status_file = StatusFile(status_file, "finished") count = 100 status = self.hpc.get_status(qjob) print(qjob.jobid) while not (status == QJobStatus.finished or status == QJobStatus.failed): sleep(5) count -= 1 if count == 0: break status = self.hpc.get_status(qjob) self.assertEqual(status, QJobStatus.finished, "remote job successfully running") self.hpc.get_files([status_file]) self.assertTrue(os.path.exists("status")) with open("status", "r") as sh: content = sh.read() self.assertEqual(content, "finished\n") self.hpc.syscall("rm", ["-r", self.rdir])
def test_full(self): status_file = os.path.join(self.rdir, "status") self.hpc.syscall("rm", ["-r", self.rdir]) self.hpc.syscall("mkdir", ["-p", self.rdir]) for f in self.strangeFiles: with open(f, 'w') as fh: fh.write(f) self.hpc.put_files([f], self.rdir) self.hpc.syscall("ls", [f]) with open(self.testFiles[0], "w") as fh: fh.write('''#! /bin/bash #SBATCH -A met #SBATCH --nodes=1 --ntasks-per-node=1 --time=01:00:00 #SBATCH -D {rdir}/ #SBATCH --mail-type=FAIL [email protected] #SBATCH -n1 sleep 8 echo "finished" > {status} '''.format(status=status_file, rdir=self.rdir)) self.hpc.put_files([self.testFiles[0]], self.rdir) qjob = self.hpc.submit_job(os.path.join(self.rdir, self.testFiles[0]), []) self.assertIsNotNone(qjob, "job submitted") qjob.status_file = StatusFile(status_file, "finished") count = 100 status = self.hpc.get_status(qjob) print(qjob.jobid) while not (status == QJobStatus.finished or status == QJobStatus.failed): sleep(5) count -= 1 if count == 0: break status = self.hpc.get_status(qjob) self.assertEqual(status, QJobStatus.finished, "remote job successfully running") self.hpc.get_files([status_file]) self.assertTrue(os.path.exists("status")) with open("status", "r") as sh: content = sh.read() self.assertEqual(content, "finished\n") self.hpc.syscall("rm", ["-r", self.rdir])
def test_full(self): status_file = os.path.join(self.rdir, "status") self.vilje.syscall("rm", ["-r", self.rdir]) self.vilje.syscall("mkdir", [self.rdir]) with open(self.testFiles[0], "w") as fh: fh.write(''' #! /bin/bash #PBS -l select=1:ncpus=1:mpiprocs=1:mem=1GB #PBS -lwalltime=00:00:10 #PBS -W umask=0022 #PBS -A mipa01kl sleep 8 echo "finished" > {} '''.format(status_file)) self.vilje.put_files([self.testFiles[0]], self.rdir) qjob = self.vilje.submit_job( os.path.join(self.rdir, self.testFiles[0]), []) self.assertIsNotNone(qjob, "job submitted") qjob.status_file = StatusFile(status_file, "finished") count = 100 status = self.vilje.get_status(qjob) while not (status == QJobStatus.finished or status == QJobStatus.failed): sleep(5) count -= 1 if count == 0: break status = self.vilje.get_status(qjob) self.assertEqual(status, QJobStatus.finished, "remote job successfully running") self.vilje.get_files([status_file]) self.assertTrue(os.path.exists("status")) with open("status", "r") as sh: content = sh.read() self.assertEqual(content, "finished\n") self.vilje.syscall("rm", ["-r", self.rdir])