def test_121(self): """ Provision, fs.ext4 """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "set", "--kw", "disk#0.type=loop", "--kw", "disk#0.file=/var/tmp/{svcname}.dd", "--kw", "disk#0.size=10m", "--kw", "fs#0.type=ext4", "--kw", "fs#0.mkfs_opt=-L {svcname}.fs.0", "--kw", "fs#0.dev={disk#0.file}", "--kw", "fs#0.mnt=/var/tmp/{svcname}", "--kw", "fs#0.mnt_opt=rw,noatime", ]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "provision", "--local"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "resinfo"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "devs"]) assert ret == 0
def test_131(self): """ Provision, fs.btrfs """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "set", "--kw", "disk#0.type=loop", "--kw", "disk#0.file=/var/tmp/{svcname}.dd", "--kw", "disk#0.size=1g", "--kw", "fs#0.type=btrfs", "--kw", "fs#0.dev={disk#0.file}", "--kw", "fs#0.mnt=/var/tmp/{svcname}", "--kw", "fs#0.mnt_opt=rw,noatime,subvol=init", ]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "provision", "--local"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "resinfo"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "devs"]) assert ret == 0
def test_031(self): """ Provision, disk.md """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "set", "--kw", "disk#0.type=loop", "--kw", "disk#0.file=/var/tmp/{svcname}.1.dd", "--kw", "disk#0.size=10m", "--kw", "disk#1.type=loop", "--kw", "disk#1.file=/var/tmp/{svcname}.2.dd", "--kw", "disk#1.size=10m", "--kw", "disk#2.type=md", "--kw", "disk#2.level=raid0", "--kw", "disk#2.devs={disk#0.exposed_devs[0]} {disk#1.exposed_devs[0]}", ]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "provision", "--local"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "resinfo"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "devs"]) assert ret == 0
def test_201(self): """ Provision, container.docker (shared) """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "set", "--kw", "docker_daemon_private=false", "--kw", "container#0.type=docker", "--kw", "container#0.image=alpine:latest", "--kw", "container#0.run_args=-it --net=none", "--kw", "container#0.run_command=/bin/sh", ]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "provision", "--local"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "resinfo"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "devs"]) assert ret == 0
def test_011(self): """ Provision, disk.vg """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "set", "--kw", "disk#0.type=loop", "--kw", "disk#0.file=/var/tmp/{svcname}.dd", "--kw", "disk#0.size=10m", "--kw", "disk#1.type=vg", "--kw", "disk#1.name={svcname}", "--kw", "disk#1.pvs={disk#0.file}", ]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "provision", "--local"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "resinfo"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "devs"]) assert ret == 0
def test_026_delete(self): """ Delete local service instance """ ret = svcmgr.main(argv=["delete", "-s", SVCNAME, "--local"]) assert ret == 0 ret = svcmgr.main(argv=["delete", "-s", SVCNAME + '2', "--local"]) assert ret == 0
def test_001_create_empty(self): """ Create a trivial service """ ret = svcmgr.main(argv=["create", "-s", SVCNAME]) assert ret == 0 ret = svcmgr.main(argv=["create", "-s", SVCNAME + '2']) assert ret == 0
def test_014_frozen(self): """ The service is frozen after create. """ ret = svcmgr.main(argv=["frozen", "-s", SVCNAME]) assert ret > 1 ret = svcmgr.main(argv=["thaw", "-s", SVCNAME, "--local"]) assert ret == 0
def test_302(self): """ Unprovision, ip """ ret = svcmgr.main( argv=["-s", SVCNAME, "delete", "--unprovision", "--rid", "ip#0"]) assert ret == 0
def test_002(self): """ Unprovision, disk.loop """ ret = svcmgr.main( argv=["-s", SVCNAME, "delete", "--unprovision", "--rid", "disk#0"]) assert ret == 0
def test_0257_compliance(self): """ Service compliance list ruleset """ ret = svcmgr.main( argv=["-s", SVCNAME, "compliance", "list", "ruleset"]) assert ret == 0
def test_0256_compliance(self): """ Service compliance show ruleset """ ret = svcmgr.main( argv=["-s", SVCNAME, "compliance", "show", "ruleset"]) assert ret == 0
def test_0165_multi_get(self): """ Multi-service get """ ret = svcmgr.main( argv=["get", "-s", "unittest*", "--param", "nodes", "--eval"]) assert ret == 0
def test_01612_freeze(self): """ Freeze the services (parallel) """ ret = svcmgr.main( argv=["freeze", "-s", "unittest*", "--parallel", "--local"]) assert ret == 0
def test_132(self): """ Unprovision, fs.btrfs """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "delete", "--unprovision", "--rid", "disk#0,fs#0" ]) assert ret == 0
def test_202(self): """ Unprovision, container.docker (shared) """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "delete", "--unprovision", "--rid", "container#0" ]) assert ret == 0
def test_0248_svc_selector(self): """ Service selector: OSVC_SERVICE_LINK=unittest """ os.environ["OSVC_SERVICE_LINK"] = SVCNAME ret = svcmgr.main(argv=["ls"]) assert ret == 0 del os.environ["OSVC_SERVICE_LINK"]
def test_312(self): """ Unprovision, ip.docker """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "delete", "--unprovision", "--rid", "container#0,ip#0" ]) assert ret == 0
def test_0259_compliance(self): """ Service compliance detach """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "compliance", "detach", "--ruleset", "abcdef", "--moduleset", "abcdef" ]) assert ret == 0
def test_0081_set_default(self): """ Set DEFAULT.comment to an unicode string """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "set", "--param", "comment", "--value", UNICODE_STRING ]) assert ret == 0
def test_002_set_default(self): """ Set references """ refs = ["--kw", "nodes=%s" % NODENAME] for idx, (name, val, exp_val) in enumerate(REFS): refs += ["--kw", "%s=%s" % (name, val)] ret = svcmgr.main(argv=["-s", SVCNAME, "set"] + refs) assert ret == 0
def test_0083_set_env(self): """ Set env.list_entry_ref_indirect_eval2 to {nodes[$(0//(3//{#nodes}))]} """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "set", "--param", "env.list_entry_ref_indirect_eval2", "--value", "{nodes[$(0//(3//{#nodes}))]}" ]) assert ret == 0
def test_301(self): """ Provision, ip """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "set", "--kw", "ip#0.provisioner=collector", "--kw", "ip#0.ipdev=lo", "--kw", "ip#0.network=192.168.0.0", ]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "provision", "--local"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "resinfo"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "devs"]) assert ret == 0
def test_311(self): """ Provision, ip.docker """ ret = svcmgr.main(argv=[ "-s", SVCNAME, "set", "--kw", "docker_daemon_private=false", "--kw", "container#0.type=docker", "--kw", "container#0.image=alpine:latest", "--kw", "container#0.run_args=-it --net=none", "--kw", "container#0.run_command=/bin/sh", "--kw", "ip#0.type=docker", "--kw", "ip#0.ipname=172.17.172.17", "--kw", "ip#0.ipdev=docker0", "--kw", "ip#0.network=172.17.0.0", "--kw", "ip#0.netmask=16", "--kw", "ip#0.container_rid=container#0", ]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "provision", "--local"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "resinfo"]) assert ret == 0 ret = svcmgr.main(argv=["-s", SVCNAME, "print", "devs"]) assert ret == 0
def test_011_get_default_not_found(self): """ Get unset keyword """ _stderr = sys.stderr try: err = StringIO() sys.stderr = err ret = svcmgr.main( argv=["-s", SVCNAME, "get", "--param", "comment"]) output = err.getvalue().strip() finally: sys.stderr = _stderr assert ret == 1
def test_0082_get_default(self): """ Get DEFAULT.comment """ _stdout = sys.stdout try: out = StringIO() sys.stdout = out ret = svcmgr.main( argv=["-s", SVCNAME, "get", "--param", "comment"]) output = out.getvalue().strip() finally: sys.stdout = _stdout assert ret == 0 assert try_decode(output) == UNICODE_STRING
def __get_ref(self, idx): """ Get ref """ name, val, exp_val = REFS[idx] _stdout = sys.stdout try: out = StringIO() sys.stdout = out ret = svcmgr.main( argv=["-s", SVCNAME, "get", "--eval", "--kw", name]) output = out.getvalue().strip() finally: sys.stdout = _stdout print(ret, output, exp_val) assert ret == 0 assert try_decode(output) == exp_val
def test_0084_get_env(self): """ Get evaluated env.list_entry_ref_indirect_eval2 """ nodename = socket.gethostname().lower() _stdout = sys.stdout try: out = StringIO() sys.stdout = out ret = svcmgr.main(argv=[ "-s", SVCNAME, "get", "--param", "env.list_entry_ref_indirect_eval2", "--eval" ]) output = out.getvalue().strip() finally: sys.stdout = _stdout assert ret == 0 assert output == nodename
def test_005_svcmgr_print_config_json(self): """ Print all services config (json format) """ _stdout = sys.stdout try: out = StringIO() sys.stdout = out ret = svcmgr.main(argv=[ "-s", "*", "print", "config", "--format", "json", "--color", "no" ]) output = out.getvalue().strip() finally: sys.stdout = _stdout print(output) data = json.loads(output) assert ret == 0 assert isinstance(json.loads(output), dict)
def teardown_class(cls): ret = svcmgr.main( argv=["-s", SVCNAME, "delete", "--unprovision", "--local"]) assert ret == 0