diff --git a/.gitattributes b/.gitattributes index 0371817b1bde5abf367da574dd91698216506184..6b2164803d565f461b8430ba8370fe5ffc0e4364 100644 --- a/.gitattributes +++ b/.gitattributes @@ -4533,6 +4533,7 @@ RTCP/Cobalt/GPUProc/test/tMPIReceive.in_parset -text RTCP/Cobalt/GPUProc/test/tMPIReceive.sh eol=lf RTCP/Cobalt/GPUProc/test/t_cpu_utils.in_parset -text RTCP/Cobalt/GPUProc/test/t_generate_globalfs_locations.in_parset -text +RTCP/Cobalt/GPUProc/test/t_generate_globalfs_locations.sh eol=lf RTCP/Cobalt/InputProc/doc/Cobalt-New-InputSection.jpg -text svneol=unset#image/jpeg RTCP/Cobalt/InputProc/src/Delays/printDelays.log_prop -text RTCP/Cobalt/InputProc/test/tMPI.run eol=lf diff --git a/RTCP/Cobalt/GPUProc/test/t_generate_globalfs_locations.py b/RTCP/Cobalt/GPUProc/test/t_generate_globalfs_locations.py new file mode 100644 index 0000000000000000000000000000000000000000..cef56e81940d34bc8d7cf6b824ab9667fa385fee --- /dev/null +++ b/RTCP/Cobalt/GPUProc/test/t_generate_globalfs_locations.py @@ -0,0 +1,53 @@ +#!/usr/bin/env python + +import unittest + +# Be able to find service python file +import sys, os +sys.path.insert(0, "{srcdir}/../src/scripts".format(**os.environ)) + +import generate_globalfs_locations as ggl + +from lofar.parameterset import PyParameterSet + +class ReplaceHost(unittest.TestCase): + def test_replace(self): + # Replace the host + self.assertEqual(ggl.replace_host("CEP4:/foo/bar", "CEP4", ["host"]), "host:/foo/bar") + + # Don't replace the host + self.assertEqual(ggl.replace_host("locus001:/foo/bar", "CEP4", ["host"]), "locus001:/foo/bar") + + def test_rotate(self): + # See if host array rotates + hosts = ["foo", "bar", "baz"] + + self.assertEqual(ggl.replace_host("CEP4:/foo/bar", "CEP4", hosts), "foo:/foo/bar") + self.assertEqual(hosts, ["bar","baz","foo"]) + + self.assertEqual(ggl.replace_host("CEP4:/foo/bar", "CEP4", hosts), "bar:/foo/bar") + self.assertEqual(ggl.replace_host("CEP4:/foo/bar", "CEP4", hosts), "baz:/foo/bar") + +class ProcessParset(unittest.TestCase): + def test(self): + parset = PyParameterSet("t_generate_globalfs_locations.in_parset", False) + + # obtain & check the cluster name + cluster_name = parset.getString("Observation.Cluster.ProcessingCluster.clusterName") + self.assertEqual(cluster_name, "CEP4") + + # process + ggl.process_parset(parset, cluster_name, ["foo", "bar"]) + + # check if hosts are replaced + locations = parset._getStringVector1("Observation.DataProducts.Output_CoherentStokes.locations", True) + for l in locations: + self.assertTrue(l.startswith("foo:") or l.startswith("bar:")) + +def main(argv): + unittest.main(verbosity=2) + +if __name__ == "__main__": + # run all tests + import sys + main(sys.argv[1:]) diff --git a/RTCP/Cobalt/GPUProc/test/t_generate_globalfs_locations.sh b/RTCP/Cobalt/GPUProc/test/t_generate_globalfs_locations.sh new file mode 100755 index 0000000000000000000000000000000000000000..7ed8774848835405de99457545cea42c9deb5820 --- /dev/null +++ b/RTCP/Cobalt/GPUProc/test/t_generate_globalfs_locations.sh @@ -0,0 +1,4 @@ +#!/bin/bash +# + +./runctest.sh t_generate_globalfs_locations