예제 #1
0
def openstack_test1():
    """
    1. test for vm
    """
    vm = Vm('chameleon')
    refactor = VmRefactor(vm)

    names = vm.list()  # instances
    sizes = refactor.list_sizes()  # available sizes
    images = refactor.list_images()  # available images

    # create new instance if necessary
    # create and auto start

    print("creating instance with provider: chameleon")
    node = vm.provider.create('testgroup-experiment-01')
    node_id = node.id
    name = node.name
    while vm.info(name).state == 'pending':
        sleep(3)
    print("At time " + str(datetime.datetime.now()) + " the state is " +
          vm.info(name).state)
    print(node)
    print("Node:" + node_id + " has been set up")

    # name = vm.list()[0].name
    # print("We are testing with cloud provider: chameleon, node name: %s " % name)
    # print("At time " + str(datetime.datetime.now()) + " the state is " + str(vm.info(name).state))

    # resize test - checked
    # *** chameleon requires extra confirmation for resizing request
    input("Press Enter to continue...")
    print("resizing.........")
    sizes = refactor.list_sizes()
    print(sizes)
    refactor.resize(name=name, size=sizes[2])  # resize to medium
    print("resizing finished")

    input("Press Enter to continue...")
    node = refactor.confirm_resize(name)
    print("resizing confirmed")

    # change image test - checked
    input("Press Enter to continue...")
    print("refactoring image.............")
    print(images)
    node = refactor.rebuild(name, image=images[2])
    print("image changed")

    # rename test - checked
    input("Press Enter to continue...")
    node = refactor.rename(name, "new name")

    # destroy
    input("Press Enter to continue...")
    print("call d.destroy() function")
    vm.destroy(name)
    sleep(10)
예제 #2
0
class TestCloudAzure:

    def setup(self):
        self.config = Config()
        self.azure = Vm("azure")
        self.test_node_name = 'test1'
        self.test_node_id = ''

    def _wait_and_get_state(self, name, how_long=15):
        time.sleep(how_long)
        node = self.azure.provider.driver._get_node(name)
        return node.state if node else None

    def test_azure_010_create(self):
        HEADING(myself())
        vm = self.azure.create(self.test_node_name)
        assert vm is not None

    def test_azure_020_nodes(self):
        HEADING(myself())
        results = self.azure.nodes()
        assert isinstance(results, list)

    def test_azure_025_info(self):
        HEADING(myself())
        info = self.azure.info(self.test_node_name)
        assert info is not None

    def test_azure_030_suspend(self):
        HEADING(myself())
        self.azure.suspend(name=self.test_node_name)
        state = self._wait_and_get_state(self.test_node_name)
        assert state == 'stopped'

    def test_azure_050_start(self):
        HEADING(myself())
        self.azure.start(name=self.test_node_name)
        state = self._wait_and_get_state(self.test_node_name, 30)
        assert state == 'running'

    def test_azure_060_stop(self):
        HEADING(myself())
        self.azure.stop(name=self.test_node_name)
        state = self._wait_and_get_state(self.test_node_name, 30)
        assert state == 'deallocating' or state == 'stopped'

    def test_azure_070_destroy(self):
        HEADING(myself())
        self.azure.destroy(name=self.test_node_name)

    def test_azure_100_list_sizes(self):
        HEADING(myself())
        vols = self.azure.provider.list_sizes()
        assert vols is not None
예제 #3
0
class TestCloudAzure:

    def setup(self):
        self.config = Config()
        self.azure = Vm('azure')
        self.test_node_name = 'cm-test-vm-1'
        self.test_node_id = ''

    def _wait_and_get_state(self, name, how_long=15):
        time.sleep(how_long)
        node = self.azure.provider._get_node(name)
        return node.state if node else None

    def test_azure_005_getname(self):
        name = self.azure.new_name()
        assert name is not None

    def test_azure_010_create(self):
        vm = self.azure.create('cm-test-vm-1')
        assert vm is not None

    def test_azure_020_ls(self):
        ls_results = self.azure.list()
        assert isinstance(ls_results, list)

    def test_azure_030_suspend(self):
        self.azure.suspend(self.test_node_name)
        state = self._wait_and_get_state(self.test_node_name)
        assert state == 'stopped'
        # assert state == 'paused'

    def test_azure_050_stop(self):
        self.azure.stop(self.test_node_name)
        state = self._wait_and_get_state(self.test_node_name, 30)
        assert state == 'stopped'

    def test_azure_060_start(self):
        self.azure.start(self.test_node_name)
        state = self._wait_and_get_state(self.test_node_name, 30)
        assert state == 'running'

    def test_azure_070_destroy(self):
        self.azure.destroy(self.test_node_name)

    def test_azure_create_network(self):
        self.azure._create_network("cmnet")

    def test_azure_list_volumes(self):
        vols = self.azure.list_volumes()

    def test_azure_delete_network(self):
        self.azure._ex_delete_network("cmnetwork")

    def test_azure_get_node(self):
        vm = self.azure._get_node(self.test_node_name)
        assert vm is not None

    def test_azure_run(self):
        cmd = "lsb_release -a"
        res = self.azure.run(self.test_node_name, cmd)
        # getting output
        # https://stackoverflow.com/questions/38152873/how-can-i-get-the-output-of-a-customscriptextenstion-when-using-azure-resource-m

        assert res is not None