Beispiel #1
0
    def test_list(self):
        HEADING()
        src = '/'
        StopWatch.start("list")
        contents = provider.list(src)
        StopWatch.stop("list")
        for c in contents:
            pprint(c)

        assert len(contents) > 0
 def test_rename_blob(self):
     HEADING()
     from cloudmesh.google.storage.Provider import Provider
     provider = Provider(service=cloud)
     blob_name = 'top_folder11/sub_folder7/test2'
     provider.create_dir(blob_name)
     new_name = 'top_folder11/sub_folder7/test2_new'
     StopWatch.start("test_rename_blob")
     provider.rename_blob(blob_name, new_name)
     StopWatch.stop("test_rename_blob")
Beispiel #3
0
    def test_get(self):
        HEADING()
        src = "/a.txt"
        dst = "~/.cloudmesh/storage/test"
        StopWatch.start("get")
        file = provider.get(src, dst)
        StopWatch.stop("get")
        pprint(file)

        assert file is not None
Beispiel #4
0
    def test_create_dir(self):
        HEADING()
        src = 'created_dir'
        StopWatch.start("create dir")
        directory = provider.create_dir(src)
        StopWatch.stop("create dir")

        pprint(directory)

        assert directory is not None
Beispiel #5
0
 def test_search(self):
     HEADING()
     src = '/'
     filename = "a1.txt"
     StopWatch.start("SEARCH file")
     search_files = self.p.search(src, filename, True)
     StopWatch.stop("SEARCH file")
     pprint(search_files)
     assert len(search_files) > 0
     assert search_files[0]["name"] == filename
Beispiel #6
0
    def test_recursive_put(self):
        # must be implemented by student from ~/.cloudmesh/storage/test
        # make sure all files are in the list see self.content which contains all files
        home = self.sourcedir
        StopWatch.start("PUT Directory --recursive")
        upl_files = self.p.put(self.p.service, f"{home}", "/a", True)
        StopWatch.stop("PUT Directory --recursive")
        pprint(upl_files)

        assert upl_files is not None
Beispiel #7
0
    def test_create_dir(self):
        HEADING()
        src = '/a/created_dir'
        StopWatch.start("CREATE DIR")
        directory = self.p.createdir(src)
        StopWatch.stop("CREATE DIR")
        pprint(directory)

        assert dir is not None
        assert "a/created_dir" in directory[0]["name"]
Beispiel #8
0
    def test_vm_start1(self):
        HEADING()

        StopWatch.start("cms vm start1")
        result = Shell.execute("cms newawsvm start test1 --dryrun", shell=True)
        StopWatch.stop("cms vm start1")

        VERBOSE(result)

        assert "restarted" in result
    def test_get(self):
        HEADING()
        src = path_expand("/a.txt")
        dst = path_expand("~/test.txt")
        StopWatch.start("get")
        file = self.p.get(src, dst)
        StopWatch.stop("get")
        pprint(file)

        assert file is not None
Beispiel #10
0
    def test_vm_status3(self):
        HEADING()

        StopWatch.start("cms vm status3")
        result = Shell.execute("cms newawsvm status all", shell=True)
        StopWatch.stop("cms vm status3")

        VERBOSE(result)

        assert "Currently" in result
Beispiel #11
0
    def test_vm_boot2(self):
        HEADING()

        StopWatch.start("cms vm boot2")
        result = Shell.execute("cms newawsvm boot --n=10 --dryrun", shell=True)
        StopWatch.stop("cms vm boot2")

        VERBOSE(result)

        assert "Started 10 node" in result
Beispiel #12
0
    def test_vm_default(self):
        HEADING()

        StopWatch.start("cms vm default")
        result = Shell.execute("cms newawsvm default", shell=True)
        StopWatch.stop("cms vm default")

        VERBOSE(result)

        assert "yaml" in result
 def test_selective_list(self):
     # must be implemented by student into ~/.cloudmesh/storage/test/a/b
     # see self.content which contains all files that you can test against
     # in the list return. all of them must be in there but not more?
     # I am unsure if we implemented a secive list. If not let us know
     # full list for now is fine
     StopWatch.start("LIST Sub-directory --recursive")
     contents = self.p.list("a/a/b", True)
     StopWatch.stop("LIST Sub-directory --recursive")
     assert len(contents) > 0
    def _create(self, **arguments):

        arguments = dotdict(arguments)

        r = []

        StopWatch.start(f"create vm {arguments.name}")

        cm = {
            'kind': "vm",
            'name': arguments.name,
            'group': arguments.group,
            'cloud': self.cloudname(),
            'status': 'booting'
        }
        entry = {}
        entry.update(cm=cm, name=arguments.name)

        result = CmDatabase.UPDATE(entry, progress=False)[0]

        data = {}
        dryrun = False
        if "dryrun" in arguments:
            dryrun = arguments.dryrun
            data = {"dryrun": True}
        else:
            arguments.timeout = 360
            data = self.p.create(**arguments)

        entry.update(data)

        StopWatch.stop(f"create vm {arguments.name}")
        t = format(StopWatch.get(f"create vm {arguments.name}"), '.2f')
        cm['creation_time'] = t

        entry.update({'cm': cm})

        if arguments.metadata:
            entry.update({"metadata": arguments.metadata})
        else:
            entry.update({
                "metadata":
                str({
                    "cm": cm,
                    "image": arguments.image,
                    "size": arguments.size
                })
            })

        cm['status'] = 'available'
        self.p.set_server_metadata(arguments.name, cm)

        result = CmDatabase.UPDATE(entry, progress=False)[0]

        return result
Beispiel #15
0
def provider_vm_terminate():
    HEADING()
    name = str(Name())
    try:
        StopWatch.start(f"terminate {name}")
        data = provider.destroy(name=name)
        StopWatch.stop(f"terminate {name}")

    except Exception as e:
        Console.error(f"could not terminate VM {name}")
        print(e)
    def test_config(self):
        print()
        for n in range(1, 10):
            self.config_n_load(n)
            n_1 = StopWatch.get(f"test_config_load n=1")
            n_n = StopWatch.get(f"test_config_load n={n}")
            print(n, n_1 >= n_n, n_1, n_n, n_1 - n_n)

        n_1 = StopWatch.get(f"test_config_load n=1")
        n_n = StopWatch.get(f"test_config_load n=9")
        assert (n_1 * 9 >= n_n)
    def test_list_clusters(self):
        emr = Manager()

        args = {'status': 'all'}

        StopWatch.start("List Clusters")
        clusters = emr.list_clusters(args)
        StopWatch.stop("List Clusters")

        assert clusters is not None
        assert 'cm' in clusters[0]
Beispiel #18
0
    def test_help(self):
        HEADING()

        StopWatch.start("cms help")
        result = Shell.execute("cms help", shell=True)
        StopWatch.stop("cms help")

        VERBOSE(result)

        assert "quit" in result
        assert "clear" in result
Beispiel #19
0
    def test_vm_terminate(self):
        HEADING()

        StopWatch.start("cms vm terminate")
        result = Shell.execute("cms newawsvm terminate test1 --dryrun",
                               shell=True)
        StopWatch.stop("cms vm terminate")

        VERBOSE(result)

        assert "terminated" in result
Beispiel #20
0
    def test_put(self):
        HEADING()
        home = self.sourcedir
        local_path = f"{home}/a/a1.txt"
        cloud_path = "/"

        StopWatch.start("PUT file")
        test_file = self.p.put(local_path, cloud_path, False)
        StopWatch.stop("PUT file")

        assert test_file is not None
Beispiel #21
0
    def f(test):
        msg = "This is a test {test}".format(**locals())
        print("  jj   ", locals())
        from cloudmesh.common.debug import VERBOSE
        d = {'test': 'Gergor'}
        VERBOSE(d, "a", "RED", 100)
        from cloudmesh.common.console import Console

        msg = 'my message'

        Console.ok(msg)  # prins a green message
        Console.error(msg)  # prins a red message proceeded with ERROR
        Console.msg(msg)  # prins a regular black message

        from cloudmesh.common.variables import Variables

        variables = Variables()

        variables['debug'] = True
        variables['trace'] = True
        variables['verbose'] = 10
        m = {'key': 'value'}
        VERBOSE(m)
        a = {'p': "ac"}
        print(a['p'])

        from cloudmesh.common.Shell import Shell

        result = Shell.execute('pwd')
        print(result)

        result = Shell.execute('ls', ['-l', '-a'])
        print(result)

        result = Shell.execute('ls', '-l -a')
        print(result)

        result = Shell.ls('-aux')
        print(result)

        result = Shell.ls('-a')
        print(result)

        result = Shell.pwd()
        print(result)

        from cloudmesh.common.StopWatch import StopWatch
        from time import sleep

        StopWatch.start('test')
        sleep(1)
        StopWatch.stop('test')

        print(StopWatch.get('test'))
    def test_list_dir_only(self):
        HEADING()
        src = '/'
        dir = "a"
        StopWatch.start("list")
        contents = provider.list(src, dir, True)
        StopWatch.stop("list")
        for c in contents:
            pprint(c)

        assert len(contents) > 0
    def test_04_start(self):
        HEADING("this test will fail, press Ctrl-C to skip")

        StopWatch.start("cms aws start")
        result = Shell.execute(
            "cms aws start test_boot_02 --parallel --processors=3", shell=True)
        StopWatch.stop("cms aws start")

        VERBOSE(result)

        assert "'name': 'test_boot_02'" in result
Beispiel #24
0
    def test_02_list(self):
        HEADING()
        StopWatch.start("list")
        src = '/'
        contents = self.p.list(source=src)

        VERBOSE(contents, label="c")

        for c in contents:
            VERBOSE(c)
        StopWatch.stop("list")
Beispiel #25
0
    def test_remove_nodes(self):
        HEADING()

        StopWatch.start("del nodes")
        results = []

        for node in range(num_nodes):
            node_name = f"node{str(node)}"
            results.append(Shell.execute("cms flow node remove "  + node_name, shell=True))
        StopWatch.stop("del nodes")
        VERBOSE(results)
Beispiel #26
0
    def test_vm_stop2(self):
        HEADING()

        StopWatch.start("cms vm stop2")
        result = Shell.execute("cms newawsvm stop test1,test2 --dryrun",
                               shell=True)
        StopWatch.stop("cms vm stop2")

        VERBOSE(result)

        assert "stopped" in result
Beispiel #27
0
    def test_dict(self):
        HEADING()
        config = Config()
        StopWatch.start("dict")
        result = config.dict()
        StopWatch.stop("dict")
        pprint(result)
        print(config)
        print(type(config.data))

        assert config is not None
 def test_copy_blob_btw_buckets(self):
     HEADING()
     from cloudmesh.google.storage.Provider import Provider
     provider = Provider(service=cloud)
     blob_name = 'a/a.txt'
     bucket_name_dest = 'cloudmesh_gcp2'
     blob_name_dest = 'a/a.txt'
     StopWatch.start("test_copy_blob_btw_buckets")
     provider.copy_blob_btw_buckets(blob_name, bucket_name_dest,
                                    blob_name_dest)
     StopWatch.stop("test_copy_blob_btw_buckets")
def provider_vm_terminate(name):
    HEADING()
    try:
        StopWatch.start(f"terminate {name}")
        print("terminate", name)
        data = provider.destroy(name)
        StopWatch.stop(f"terminate {name}")

    except Exception as e:
        Console.error(f"could not terminate VM {name}", traceflag=True)
        print(e)
    def test_put(self):
        HEADING()
        src = path_expand("~/.cloudmesh/storage/test/a/a.txt")
        dst = "/"
        StopWatch.start("put")
        test_file = self.p.put(src, dst)
        StopWatch.stop("put")

        pprint(test_file)

        assert test_file is not None