Exemplo n.º 1
0
    def test_01_default_with_job(self):
        """Test default options with jobinfo set"""
        cfg = """
            load name=jobinfo plugin=faux_job
            config name=jobinfo
            smplr_add name=smp_job instance=jobinfo interval=2000000
            smplr_start name=smp_job

            load name=clk plugin=clock
            config name=clk
            smplr_add name=smp_clk instance=clk interval=2000000
            smplr_start name=smp_clk
        """ % {
            "host": HOSTNAME,
            "port": self.SMP_PORT,
        }
        daemon = LDMSD(port = self.SMP_PORT, auth = self.AUTH,
                       auth_opt = self.LDMSD_AUTH_OPT,
                       cfg = cfg)
        daemon.run()
        time.sleep(2.0)
        xprt = ldms.LDMS_xprt_new_with_auth(self.XPRT, self.AUTH,
                                            self.LDMSD_AUTH_OPT)
        rc = ldms.LDMS_xprt_connect_by_name(xprt, "localhost", self.SMP_PORT)
        assert(rc == 0)
        self.__verify(xprt, job = self.PRDCR + "/jobinfo",
                            clk = self.PRDCR + "/clk")
        daemon.term()
Exemplo n.º 2
0
 def test_cfg_good(self):
     cfg = """\
         prdcr_add name=%(prdcr)s xprt=%(xprt)s host=%(host)s port=%(port)s \
                   type=active interval=1000000
         prdcr_start name=%(prdcr)s
         updtr_add name=%(updtr)s interval=1000000 offset=500000
         updtr_prdcr_add name=%(updtr)s regex=%(prdcr)s
         updtr_start name=%(updtr)s
     """ % {
         "prdcr": "prdcr",
         "updtr": "updtr",
         "xprt": "sock",
         "host": "localhost",
         "port": self.SMP_PORT,
     }
     daemon = LDMSD(port="10000",
                    auth=self.AUTH,
                    auth_opt=self.LDMSD_AUTH_OPT,
                    cfg=cfg)
     daemon.run()
     time.sleep(0.5)
     xprt = ldms.LDMS_xprt_new_with_auth(self.XPRT, self.AUTH,
                                         self.LDMSD_AUTH_OPT)
     rc = ldms.LDMS_xprt_connect_by_name(xprt, "localhost", "10000")
     assert (rc == 0)
     dir_resp = ldms.LDMS_xprt_dir(xprt)
     daemon.term()
     self.assertEqual(dir_resp, ["smp/meminfo"])
Exemplo n.º 3
0
 def test_cfg_semi_bad(self):
     cfg = """\
         prdcr_add name=abc bogus=bogus
     """
     daemon = LDMSD(port="10000",
                    auth=self.AUTH,
                    auth_opt=self.LDMSD_AUTH_OPT,
                    cfg=cfg)
     daemon.run()
     time.sleep(1)
     # bad config should not terminate the daemon
     self.assertTrue(daemon.is_running())
     daemon.term()
Exemplo n.º 4
0
    def test_lv1_store(self):
        # ldmsd_aaggregator conf
        shutil.rmtree("csv/csv1", ignore_errors=True)
        os.makedirs("csv/csv1")
        cfg = """\
        prdcr_add name=prdcr xprt=%(xprt)s host=localhost port=%(port)s \
                  interval=1000000 type=active
        prdcr_start name=prdcr

        updtr_add name=updtr interval=%(interval)d offset=50000
        updtr_prdcr_add name=updtr regex=prdcr
        updtr_start name=updtr

        load name=store_csv
        config name=store_csv action=init path=csv buffer=0
        strgp_add name=strgp plugin=store_csv container=csv1 schema=meminfo
        strgp_prdcr_add name=strgp regex=prdcr
        strgp_start name=strgp
        """ % {
            "xprt": self.XPRT,
            "port": self.SMP_PORT,
            "interval": self.AGG_INT,
        }
        agg = LDMSD(port=self.AGG_PORT,
                    cfg=cfg,
                    logfile=self.AGG_LOG,
                    gdb_port=self.AGG_GDB_PORT)
        DEBUG.agg = agg
        log.info("starting aggregator")
        agg.run()
        log.info("collecting data")
        time.sleep(2 + 2 * self.AGG_INT * uS)
        agg.term()
        time.sleep(0.25)
        log.info("Verifying Data")
        # expecting to see a bunch of data, with dt ~ self.SMP_INT usec
        f = open("csv/csv1/meminfo")
        lines = f.readlines()
        lines = lines[1:]  # the [0] is the header
        rexp = re.compile("^(\d+\.\d+),.*$")
        ts = [float(rexp.match(l).group(1)) for l in lines]
        for a, b in zip(ts, ts[1:]):
            dt = b - a
            # allowing 1 millisec error
            self.assertLess(abs(dt - self.SMP_INT * uS), 0.001)
        log.info("%d data timestamps verified" % len(ts))
Exemplo n.º 5
0
    def test_00_default(self):
        """Test default options."""
        cfg = """
            load name=clk plugin=clock
            config name=clk

            smplr_add name=smp_clk instance=clk interval=2000000
            smplr_start name=smp_clk
        """
        daemon = LDMSD(port = self.SMP_PORT, auth = self.AUTH,
                       auth_opt = self.LDMSD_AUTH_OPT,
                       cfg = cfg)
        daemon.run()
        time.sleep(2.0)
        xprt = ldms.LDMS_xprt_new_with_auth(self.XPRT, self.AUTH,
                                            self.LDMSD_AUTH_OPT)
        rc = ldms.LDMS_xprt_connect_by_name(xprt, "localhost", self.SMP_PORT)
        assert(rc == 0)
        self.__verify(xprt, clk = self.PRDCR + "/clk")
        daemon.term()
Exemplo n.º 6
0
    def test_02_customized_options(self):
        """Test customized options"""
        pass
        cfg = """
            load name=job plugin=faux_job_alt
            config name=job instance=myjob
            smplr_add name=smp_job instance=job interval=2000000 offset=0
            smplr_start name=smp_job

            load name=clk plugin=clock
            config name=clk producer=myprdcr component_id=20 instance=myclk \
                   uid=2222 \
                   gid=3333 \
                   perm=0660 \
                   job_set=myjob \
                   job_id=alt_job_id \
                   app_id=alt_app_id \
                   job_start=alt_job_start \
                   job_end=alt_job_end
            smplr_add name=smp_clk instance=clk interval=2000000 offset=0
            smplr_start name=smp_clk
        """ % {
            "host": HOSTNAME,
            "port": self.SMP_PORT,
        }
        daemon = LDMSD(port = self.SMP_PORT, auth = self.AUTH,
                       auth_opt = self.LDMSD_AUTH_OPT,
                       cfg = cfg)
        log.info("")
        log.info("Starting ldmsd")
        daemon.run()
        time.sleep(4.0)

        # verify with uid/gid 2222
        log.info("Verifying with uid/gid 2222")
        xprt = ldms.LDMS_xprt_new_with_auth(self.XPRT, self.AUTH,
                                            {"uid": "2222", "gid": "2222"})
        rc = ldms.LDMS_xprt_connect_by_name(xprt, "localhost", self.SMP_PORT)
        assert(rc == 0)
        self.__verify(xprt, job="myjob", clk="myclk", component_id=20,
                            job_id="alt_job_id", app_id="alt_app_id",
                            job_start="alt_job_start", job_end="alt_job_end")

        # verify with uid/gid 3333
        log.info("Verifying with uid/gid 3333")
        xprt = ldms.LDMS_xprt_new_with_auth(self.XPRT, self.AUTH,
                                            {"uid": "3333", "gid": "3333"})
        rc = ldms.LDMS_xprt_connect_by_name(xprt, "localhost", self.SMP_PORT)
        assert(rc == 0)
        self.__verify(xprt, job="myjob", clk="myclk", component_id=20,
                            job_id="alt_job_id", app_id="alt_app_id",
                            job_start="alt_job_start", job_end="alt_job_end")

        log.info("Verifying with uid/gid 4444")
        xprt = ldms.LDMS_xprt_new_with_auth(self.XPRT, self.AUTH,
                                            {"uid": "4444", "gid": "4444"})
        rc = ldms.LDMS_xprt_connect_by_name(xprt, "localhost", self.SMP_PORT)
        assert(rc == 0)
        # shouldn't see 'myclk'
        self.__verify(xprt, job="myjob", clk=None, component_id=20,
                            job_id="alt_job_id", app_id="alt_app_id",
                            job_start="alt_job_start", job_end="alt_job_end")

        # terminate ldmsd
        daemon.term()