Пример #1
0
    def setUp(self):

        self.__log = DozerLogger("DozerGraph_unittest.log",
                                 "test_DozerGraph",
                                 toConsole=True)

        self.package = "DummyTestPackage"
        self.framework = "RTT"
        self.nightly = "dev"
        self.install = "build"
        self.cmtconfig = "i686-slc4-gcc34-opt"
        self.project = "AtlasProduction"
        self.jobId = "job_1"

        self.channel = DozerChannel("test channel", "test channel description")
        self.channel += DozerData("double test data", "Double", "GeV")
        self.channel += DozerData("double test data;error", "Double", "GeV")
        self.channel += DozerData("int test data", "Int", "counts")
        self.channel += DozerData("int test data;uperror", "Double", "counts")
        self.channel += DozerData("int test data;downerror", "Double",
                                  "counts")

        today = DozerIOV()

        self.pointsInTime = []

        try:
            import random
        except ImportError:
            exit(0)

        for i in range(0, 30):

            since = today.lastNDays(i)
            until = today.lastNDays(i - 1)

            if (i in (5, 10)): continue

            chan = DozerChannel.fromXMLDoc(self.channel.xml())

            if (i in (15, 20, 25)):
                self.pointsInTime.append((since, until, chan))
            else:

                chan["double test data"].setValue(i + random.gauss(0.0, 3.0))
                chan["double test data;error"].setValue(random.gauss(5.0, 5.0))

                chan["int test data"].setValue(i + random.randrange(10, 20))
                chan["int test data;uperror"].setValue(random.randrange(
                    10, 15))
                chan["int test data;downerror"].setValue(
                    random.randrange(10, 15))

                self.pointsInTime.append((since, until, chan))
            print i

        self.graph = DozerGraph(self.package, self.framework, self.nightly,
                                self.install, self.cmtconfig, self.project,
                                self.jobId, self.pointsInTime)
        self.graph.style()
Пример #2
0
    def setUp(self):
        self.package = "Dummy"
        self.framework = "RTT"
        self.nightly = "dev"
        self.install = "build"
        self.cmtconfig = "i686-slc4-gcc34-opt"
        self.project = "AtlasProduction"
        self.jobId = "job_1"

        globals()["test_DozerRecordSet_logger"] = DozerLogger(
            "DozerRecordSet_unittest.log", toConsole=True)

        self.__log = globals()["test_DozerRecordSet_logger"]

        self.since = DozerIOV.fromRelease("rel_0").AsCool()
        self.until = DozerIOV.fromRelease("rel_6").AsCool()

        self.payload = DozerRecordSet(self.package, self.framework,
                                      self.nightly, self.install,
                                      self.cmtconfig, self.project, self.jobId,
                                      self.since, self.until)

        channel = DozerChannel("test channel", "test channel description")
        channel += DozerData("IntDataRTT", "Int", "counts")
        channel += DozerData("IntDataRTT;error", "Int", "counts")
        channel += DozerData("FloatDataRTT", "Float", "some unit")
        channel += DozerData("FloatDataRTT;uperror", "Float", "some unit")
        channel += DozerData("FloatDataRTT;downerror", "Float", "some unit")

        pointsInTime = {}

        today = DozerIOV()

        for i in range(30):
            since = today.lastNDays(i - 1)
            until = today.lastNDays(i)

            ichan = DozerChannel.fromXMLDoc(channel.xml())
            if (i != 10):
                ichan.get("IntDataRTT").setValue(i)
                ichan.get("IntDataRTT;error").setValue(5)

            if (i % 3 != 0):
                ichan.get("FloatDataRTT").setValue(i)
                ichan.get("FloatDataRTT;uperror").setValue(i / 2.0)
                ichan.get("FloatDataRTT;downerror").setValue(i / 4.0)

            pointsInTime[(since, until)] = ichan

        for k in sorted(pointsInTime.keys()):
            since, until = k
            val = pointsInTime[k].get("IntDataRTT").value()
            self.__log.info("since %s until %s value %s" %
                            (str(since), str(until), str(val)))
            self.payload += (since, until, pointsInTime[k])
Пример #3
0
    def setUp(self):
        self.__log = DozerLogger("test_CoolDozer.log",
                                 "test_DozerDB",
                                 toConsole=True)
        self.__log.toConsole(True)

        globals()["laoggerdjsfhksdj"] = self.__log

        self.dataRTT = DozerData("testDataRTT", "Int", "N_{obs}")
        self.chanRTT = DozerChannel("testChannelRTT",
                                    "testChannelDescriptionRTT")
        self.scheRTT = DozerSchema("*", "build", "i686-slc4-gcc34-opt",
                                   "AtlasProduction", "job_1")
        self.confRTT = DozerConfig("RTT")

        self.chanRTT += self.dataRTT
        self.scheRTT += self.chanRTT
        self.confRTT += self.scheRTT

        self.db = DozerDB("DummyTestPackage", "RTT", dry=True)
Пример #4
0
    def setUp(self):

        self.__log = DozerLogger("DozerData_unittest.log", toConsole=True)
        globals()["mylog"] = self.__log

        print globals()["mylog"]

        self.data1 = None
        self.data2 = None
        self.data3 = None
        self.data4 = None
        self.data5 = None
        self.data6 = None
        self.data7 = None
        self.data8 = None

        self.data1 = DozerData("test_Bool", "Bool", "")
        self.data2 = DozerData("test_Int", "Int", "1/N")
        self.data3 = DozerData("test_Long", "Long")
        self.data4 = DozerData("test_Float", "Float")
        self.data5 = DozerData("test_Double", "Double", "GeV")
        self.data6 = DozerData("test_String", "String255")
        self.data7 = DozerData("test_Clob", "Clob")
        self.data8 = DozerData("test_Blob", "Blob", mime="image/gif")
Пример #5
0
 def setUp(self):
     self.__log = DozerLogger("DozerIOV_unittest.log",
                              "test_DozerIOV",
                              toConsole=True)
     self.__log.toConsole(True)
Пример #6
0
class test_DozerIOV(unittest.TestCase):

    ## setup
    # @param self "Me, myself and Irene"
    def setUp(self):
        self.__log = DozerLogger("DozerIOV_unittest.log",
                                 "test_DozerIOV",
                                 toConsole=True)
        self.__log.toConsole(True)

    ## __init__()
    # @param self "Me, myself and Irene"
    def test_01_constructor(self):
        iov = DozerIOV(log=self.__log)
        self.assertEqual(isinstance(iov, DozerIOV), True)

    ## AsCool(), AsUnix(), AsTDatime(), AsISO(), AsRelease()
    # @param self "Me, myself and Irene"
    def test_02_conversions(self):
        iov = DozerIOV(log=self.__log)

        self.assertEqual(iov(), iov.AsCool())
        self.__log.getLogger(self).info(iov)
        self.__log.getLogger(self).info(iov())
        self.__log.getLogger(self).info(iov.AsCool())
        self.__log.getLogger(self).info(iov.AsUnix())
        self.__log.getLogger(self).info(iov.AsTDatime().AsString())
        self.__log.getLogger(self).info(iov.AsISO())
        self.__log.getLogger(self).info(iov.AsRelease())

    ##  fromCool(), fromUnix(), fromTDatime(), fromISO(), fromReleaes() max()
    # @param self "Me, myself and Irene"
    def test_03_from(self):

        iov = DozerIOV(log=self.__log)
        self.__log.getLogger(self).info(iov)
        asCool = iov.AsCool()
        asUnix = iov.AsUnix()
        asTDatime = iov.AsTDatime()
        asISO = iov.AsISO()
        asRelease = iov.AsRelease()

        iov = DozerIOV.fromCool(asCool, log=self.__log)
        self.__log.getLogger(self).info(iov)
        self.assertEqual(isinstance(iov, DozerIOV), True)

        iov = DozerIOV.fromUnix(asUnix, log=self.__log)
        self.__log.getLogger(self).info(iov)
        self.assertEqual(isinstance(iov, DozerIOV), True)

        iov = DozerIOV.fromTDatime(asTDatime, log=self.__log)
        self.__log.getLogger(self).info(iov)
        self.assertEqual(isinstance(iov, DozerIOV), True)

        iov = DozerIOV.fromISO(asISO, log=self.__log)
        self.__log.getLogger(self).info(iov)
        self.assertEqual(isinstance(iov, DozerIOV), True)

        iov = DozerIOV.fromRelease(asRelease, log=self.__log)
        asTDatime = iov.AsTDatime()
        self.__log.getLogger(self).info(iov)
        self.assertEqual(isinstance(iov, DozerIOV), True)

        iov = DozerIOV.fromRelease("rel_0", log=self.__log)
        asRelease = iov.AsRelease()
        self.__log.getLogger(self).info(str(iov) + " asRelease " + asRelease)
        self.assertEqual(isinstance(iov, DozerIOV), True)
        self.assertEqual(asRelease, "rel_0")

        iov = DozerIOV.fromRelease("rel_1", log=self.__log)
        asRelease = iov.AsRelease()
        self.__log.getLogger(self).info(str(iov) + " asRelease " + asRelease)
        self.assertEqual(isinstance(iov, DozerIOV), True)
        self.assertEqual(asRelease, "rel_1")

        iov = DozerIOV.fromRelease("rel_5", log=self.__log)
        nextDay = DozerIOV(iov.lastNDays(-1))
        asRelease = iov.AsRelease()
        self.__log.getLogger(self).info(str(iov) + " asRelease " + asRelease)
        self.__log.getLogger(self).info(str(nextDay))

        self.assertEqual(isinstance(iov, DozerIOV), True)
        self.assertEqual(asRelease, "rel_5")

    ## max()
    # @param self "Me, myself and Irene"
    def test_04_max(self):
        iov = DozerIOV(DozerIOV.max(), log=self.__log)
        self.__log.getLogger(self).info(iov)
        self.assertEqual(isinstance(iov, DozerIOV), True)

    ## == , != , <, <=, >, >= operators
    # @param self "Me, myself and Irene"
    def test_05_eqnegtltgele(self):

        tod = DozerIOV()
        tom = DozerIOV(tod.lastNDays(-1))
        yes = DozerIOV(tod.lastNDays(1))

        self.assertEqual(tod == DozerIOV.today(), True)
        self.assertEqual(tod != tom, True)

        self.assertEqual(tod > yes, True)
        self.assertEqual(tod >= yes, True)

        self.assertEqual(tod < tom, True)
        self.assertEqual(tod <= tom, True)

    def test_06_fromRelease(self):

        for i in range(7):
            print i, DozerIOV.fromRelease("rel_%d" % i)
Пример #7
0
class test_DozerDB(unittest.TestCase):
    def setUp(self):
        self.__log = DozerLogger("test_CoolDozer.log",
                                 "test_DozerDB",
                                 toConsole=True)
        self.__log.toConsole(True)

        globals()["laoggerdjsfhksdj"] = self.__log

        self.dataRTT = DozerData("testDataRTT", "Int", "N_{obs}")
        self.chanRTT = DozerChannel("testChannelRTT",
                                    "testChannelDescriptionRTT")
        self.scheRTT = DozerSchema("*", "build", "i686-slc4-gcc34-opt",
                                   "AtlasProduction", "job_1")
        self.confRTT = DozerConfig("RTT")

        self.chanRTT += self.dataRTT
        self.scheRTT += self.chanRTT
        self.confRTT += self.scheRTT

        self.db = DozerDB("DummyTestPackage", "RTT", dry=True)

    ## __init__()
    # @param self "Me, myself and Irene"
    def test_01_constructor(self):

        try:
            db = DozerDB("Dummy", "RTT", dry=True)
        except:
            pass
        self.assertEqual(isinstance(db, DozerDB), True)

        try:
            db = DozerDB("Dummy", "RTT", dry="PROD_READ")
        except:
            pass
        self.assertEqual(isinstance(db, DozerDB), True)

        try:
            db = DozerDB("Dummy", "RTT", dry="FUBAR")
        except DozerError:
            self.epanic("it was intentional, don't panic!")

        try:
            db = DozerDB("Dummy", "RTT", dry=True)
        except:
            pass
        self.assertEqual(isinstance(self.db, DozerDB), True)

    ## += DozerSchema
    # @param self "Me, myself and Irene"
    def test_02_addSchema(self):
        schema = self.confRTT["dev"]["build"]["i686-slc4-gcc34-opt"][
            "AtlasProduction"]["job_1"]
        path = schema.pathChunk()
        self.db += schema
        schema = self.confRTT["bugfix"]["build"]["i686-slc4-gcc34-opt"][
            "AtlasProduction"]["job_1"]
        self.db += schema

        self.assertEqual(isinstance(self.db, DozerDB), True)

        print path

        schema = self.db.getSchema(path)

        print "*******", schema

        self.assertEqual(isinstance(schema, DozerSchema), True)

        print schema.nightly()

    ## addPayload()
    # @param self "Me, myself and Irene"
    def test_03_addPayload(self):
        iov = DozerIOV()
        schema = self.confRTT["bugfix"]["build"]["i686-slc4-gcc34-opt"][
            "AtlasProduction"]["job_1"]

        today = iov.today()
        schema["testChannelRTT"]["testDataRTT"].setValue(7)
        self.db.addSchemaPayload(schema, iov.lastNDays(6))
        schema["testChannelRTT"]["testDataRTT"].setValue(6)
        self.db.addSchemaPayload(schema, iov.lastNDays(5))
        schema["testChannelRTT"]["testDataRTT"].setValue(5)
        self.db.addSchemaPayload(schema, iov.lastNDays(4))
        schema["testChannelRTT"]["testDataRTT"].setValue(4)
        self.db.addSchemaPayload(schema, iov.lastNDays(3))
        schema["testChannelRTT"]["testDataRTT"].setValue(3)
        self.db.addSchemaPayload(schema, iov.lastNDays(2))
        schema["testChannelRTT"]["testDataRTT"].setValue(2)
        self.db.addSchemaPayload(schema, iov.lastNDays(1))
        schema["testChannelRTT"]["testDataRTT"].setValue(1)
        self.db.addSchemaPayload(schema, today)

        channel = schema["testChannelRTT"]
        channel["testDataRTT"].setValue(10)
        since = DozerIOV(iov.lastNDays(7))
        until = DozerIOV(iov.lastNDays(6))
        self.assertEqual(self.db.addChannelPayload(channel, since, until),
                         True)

    ## ls() cd() get()
    # @param self "Me, myself and Irene"
    def test_04_fs(self):

        spath = self.confRTT["bugfix"]["build"]["i686-slc4-gcc34-opt"][
            "AtlasProduction"]["job_1"].pathChunk()

        dbpath = self.db.pathChunk()

        print spath
        print dbpath

        recordSet = self.db.get(dbpath + "/" + spath + "/" + "testChannelRTT")

        print recordSet

        graph = recordSet.getDozerGraph()

        print graph.plotables()

        graph.trend("testDataRTT", True, "trend_testDataRTT.png")
        graph.histogram("testDataRTT", True, "histo_testDataRTT.png")

    def test_05_evolution(self):

        rtSchema = DozerSchema("bugfix", "build", "i686-slc4-gcc34-opt",
                               "AtlasProduction", "evo")

        self.db = DozerDB("DummyTestPackage", "RTT", dry=True)

        for i in range(1, 6):
            self.db.openDB()
            newChannel = DozerChannel(str(i), str(i))
            newChannel += DozerData(str(i), "Int")
            rtSchema += newChannel
            self.db += rtSchema
            self.db.closeDB()