Esempio n. 1
0
    def test_server_create_delete(self):
        self.assert_no_server(self.ctx.node.id)
        server_plugin.start()
        server = self.assert_server_exist_and_get(self.ctx.node.id)
        self.assert_server_started(server)

        server_plugin.delete()
        self.assert_no_server(self.ctx.node.id)
Esempio n. 2
0
    def test_server_create_with_prefix(self):
        prefix = 'prefix_'
        self.ctx.bootstrap_context.resources_prefix = prefix

        server_plugin.start()
        self.addCleanup(server_plugin.delete)
        server = self.assert_server_exist_and_get(prefix + self.ctx.node.id)
        self.assert_server_started(server)
Esempio n. 3
0
    def test_server_start_stop(self):
        server_plugin.start()
        server = self.assert_server_exist_and_get(self.ctx.node.id)
        self.assert_server_started(server)

        server_plugin.stop()
        self.assert_server_stopped(server)

        server_plugin.start()
        self.assert_server_started(server)
Esempio n. 4
0
    def test_server_resize_up(self):
        old_cpus = self.ctx.node.properties['server']['cpus']
        old_memory = self.ctx.node.properties['server']['memory']
        new_cpus = old_cpus + 1
        new_memory = old_memory + 64

        server_plugin.start()
        server = self.assert_server_exist_and_get(self.ctx.node.id)
        self.assertEqual(old_cpus, server.config.hardware.numCPU)
        self.assertEqual(old_memory, server.config.hardware.memoryMB)
        self.ctx.instance.runtime_properties['cpus'] = new_cpus
        self.ctx.instance.runtime_properties['memory'] = new_memory

        server_plugin.stop()

        server_plugin.resize()

        server = self.assert_server_exist_and_get(self.ctx.node.id)
        self.assertEqual(new_cpus, server.config.hardware.numCPU)
        self.assertEqual(new_memory, server.config.hardware.memoryMB)
Esempio n. 5
0
    def test_get_state(self):
        server_plugin.start()
        server = self.assert_server_exist_and_get(self.ctx.node.id)
        self.assert_server_started(server)

        get_state_verified = False
        for _ in range(WAIT_COUNT):
            if server_plugin.get_state():
                get_state_verified = True
                break
            time.sleep(WAIT_TIMEOUT)
        self.assertTrue(get_state_verified)

        self.assertTrue('networks' in self.ctx.instance.runtime_properties)
        self.assertTrue('ip' in self.ctx.instance.runtime_properties)
        ip_valid = True
        try:
            socket.inet_aton(self.ctx.instance.runtime_properties['ip'])
        except socket.error:
            ip_valid = False
        self.assertTrue(ip_valid)
Esempio n. 6
0
    def test_server_resize_down(self):
        old_cpus = self.ctx.node.properties['server']['cpus']
        self.assertTrue(
            old_cpus > 1,
            "To test server shrink we need more than 1 cpu predefined")
        old_memory = self.ctx.node.properties['server']['memory']
        new_cpus = old_cpus - 1
        new_memory = old_memory - 64

        server_plugin.start()
        server = self.assert_server_exist_and_get(self.ctx.node.id)
        self.assertEqual(old_cpus, server.config.hardware.numCPU)
        self.assertEqual(old_memory, server.config.hardware.memoryMB)
        self.ctx.instance.runtime_properties['cpus'] = new_cpus
        self.ctx.instance.runtime_properties['memory'] = new_memory

        server_plugin.stop()

        server_plugin.resize()

        server = self.assert_server_exist_and_get(self.ctx.node.id)
        self.assertEqual(new_cpus, server.config.hardware.numCPU)
        self.assertEqual(new_memory, server.config.hardware.memoryMB)
Esempio n. 7
0
    def test_server_shutdown_guest(self):
        server_plugin.start()
        server = self.assert_server_exist_and_get(self.ctx.node.id)
        self.assert_server_started(server)

        for _ in range(WAIT_COUNT):
            if self.is_server_guest_running(server):
                break
            time.sleep(WAIT_TIMEOUT)

        server_plugin.shutdown_guest()

        for _ in range(WAIT_COUNT):
            if not self.is_server_guest_running(server):
                break
            time.sleep(WAIT_TIMEOUT)

        self.assert_server_guest_stopped(server)
        for _ in range(WAIT_COUNT):
            if self.is_server_stopped(server):
                break
            time.sleep(WAIT_TIMEOUT)

        self.assert_server_stopped(server)
Esempio n. 8
0
 def test_server_create_with_autoplacement(self):
     self.ctx.node.properties['connection_config']['auto_placement'] = True
     self.assert_no_server(self.ctx.node.id)
     server_plugin.start()
     server = self.assert_server_exist_and_get(self.ctx.node.id)
     self.assert_server_started(server)