def setUpClass(cls): log.info("Setting up TestLDMSAuthNaive") ldms.ldms_init(512 * 1024 * 1024) # 512MB should suffice cls.ldmsd = LDMSD(port=cls.PORT, auth=cls.AUTH, auth_opt=cls.AUTH_OPT) log.info("starting ldmsd") cls.ldmsd.run() cls.cfg = ldmsdInbandConfig(host="localhost", port=cls.PORT, xprt=cls.XPRT, auth=cls.AUTH, auth_opt=cls.AUTH_OPT) # NOTE: cls.cfg automatically create an LDMS xprt and connect to the # target ldmsd. cmds = [] for _set, _perm in zip(cls.SETS, cls.PERMS): cmds.append("load name=%s" % _set) cmds.append("config name=%(set)s producer=test1 instance=%(set)s \ schema=%(set)s component_id=1 \ uid=%(uid)s gid=%(gid)s perm=%(perm)s" % { "set": _set, "uid": cls.UID, "gid": cls.GID, "perm": _perm, }) cmds.append("start name=%s interval=1000000" % _set) log.info("configuring ldmsd over LDMS xprt") for cmd in cmds: req = LDMSD_Request.from_str(cmd) req.send(cls.cfg) resp = req.receive(cls.cfg) errcode = resp["errcode"] if "errcode" in resp else 0 if errcode: raise RuntimeError("LDMSD request errcode: %d" % errcode) time.sleep(1) log.info("TestLDMSAuthNaive setup complete")
def _ldmsd_ctrl(self, cmd, uid=LDMSD_UID, gid=LDMSD_GID): cfg = ldmsdInbandConfig(host="localhost", port=self.AGG_PORT, xprt=self.XPRT, auth=self.AUTH, auth_opt={ "uid": str(uid), "gid": str(gid) }) req = LDMSD_Request.from_str(cmd) req.send(cfg) resp = req.receive(cfg) cfg.close() return resp
def setUpClass(cls): # Need 3 ldmsd .. the config objects are for aggregators log.info("Setting up TestLDMSDPerm") try: # samplers (producers) for prdcr in cls.PRDCRS: smp_cfg = """ load name=meminfo config name=meminfo producer=%(prdcr)s \ instance=%(prdcr)s/meminfo schema=meminfo start name=meminfo interval=1000000 offset=0 """ % prdcr log.debug("smp_cfg: %s" % smp_cfg) ldmsd = LDMSD(port=prdcr["port"], xprt=cls.XPRT, auth=cls.AUTH, auth_opt=cls.LDMSD_AUTH_OPT, cfg=smp_cfg, logfile=prdcr["logfile"]) log.info("starting %s" % prdcr["prdcr"]) ldmsd.run() cls.prdcrs.append(ldmsd) # aggregator cls.agg = LDMSD(port=cls.AGG_PORT, xprt=cls.XPRT, auth=cls.AUTH, auth_opt=cls.LDMSD_AUTH_OPT, logfile=cls.AGG_LOG) log.info("starting aggregator") cls.agg.run() time.sleep(1) # need to config separately so that prdcr,updtr pairs are owned by # different users. log.info("configuring aggregator") for prdcr in cls.PRDCRS: log.info("....adding %(prdcr)s" % prdcr) agg_cfg = """\ prdcr_add name=%(prdcr)s xprt=%(xprt)s host=localhost \ port=%(port)s type=active interval=1000000 \ perm=0600 prdcr_start name=%(prdcr)s updtr_add name=%(updtr)s interval=1000000 offset=500000 \ perm=0600 updtr_prdcr_add name=%(updtr)s regex=%(prdcr)s updtr_start name=%(updtr)s """ % prdcr log.debug("agg_cfg: %s" % agg_cfg) ctrl = ldmsdInbandConfig(host="localhost", port=cls.AGG_PORT, xprt=prdcr["xprt"], auth=prdcr["auth"], auth_opt=prdcr["auth_opt"]) for cmd in agg_cfg.splitlines(): cmd = cmd.strip() if not cmd: continue log.debug("cmd: %s" % cmd) req = LDMSD_Request.from_str(cmd) req.send(ctrl) resp = req.receive(ctrl) errcode = resp["errcode"] if errcode: raise RuntimeError("LDMSD Ctrl errcode: %d" % errcode) ctrl.close() time.sleep(1) # Verify that the agg is working as configured log.info("verifying aggregator") xprt = ldms.LDMS_xprt_new_with_auth(cls.XPRT, cls.AUTH, cls.LDMSD_AUTH_OPT) rc = ldms.LDMS_xprt_connect_by_name(xprt, "localhost", cls.AGG_PORT) if rc: raise RuntimeError("LDMS connect failed: %d" % rc) _dir = ldms.LDMS_xprt_dir(xprt) log.debug("dirs: %s" % str(_dir)) ldms.ldms_xprt_close(xprt) _edirs = [p["prdcr"] + "/meminfo" for p in cls.PRDCRS] if set(_dir) != set(_edirs): raise RuntimeError("Bad set ...") except: del cls.agg del cls.prdcrs raise log.info("TestLDMSDPerm set up done")