Test console and console output of a server

1. Test get console url from servers api.
2. Test get console output from servers api.

Change-Id: I69dc6c70385553797b1767408f5b10574581795c
This commit is contained in:
Sumanth Nagadavalli
2013-07-22 15:21:59 +05:30
parent 49e5964c26
commit 8070a1a73d
3 changed files with 78 additions and 4 deletions

View File

@@ -0,0 +1,15 @@
"""
Copyright 2013 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""

View File

@@ -0,0 +1,47 @@
"""
Copyright 2013 Rackspace
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
"""
import time
import unittest2 as unittest
from cloudroast.compute.fixtures import CreateServerFixture
class ConsoleOutputTests(CreateServerFixture):
def test_get_console_output(self):
timeout = self.servers_config.server_boot_timeout
expected_console_output_length = 100
console = self.console_output_client.get_console_output(
self.created_server.id, expected_console_output_length).entity
self.assertIsNotNone(console)
#Retry getting console output, as the server might take some
#time to boot up and then log to output stream.
start = int(time.time())
while console.output in ["0", None]:
console = self.console_output_client.get_console_output(
self.created_server.id, expected_console_output_length).entity
if int(time.time() - start) >= timeout:
break
self.assertNotIn(console.output, ["0", None],
"No Console Output")
self.assertGreaterEqual(
expected_console_output_length,
len(console.output.split("\n")),
"Console output length is not matching the "
"expected length.")

View File

@@ -15,15 +15,24 @@ limitations under the License.
"""
from cafe.drivers.unittest.fixtures import BaseTestFixture
from cloudcafe.common.resources import ResourcePool
from cloudcafe.compute.common.exceptions import TimeoutException, \
BuildErrorException
from cloudcafe.compute.common.types import NovaServerStatusTypes \
as ServerStates
from cloudcafe.common.tools.datagen import rand_name
from cloudcafe.compute.config import ComputeEndpointConfig, \
ComputeAdminEndpointConfig, MarshallingConfig
from cloudcafe.compute.common.exception_handler import ExceptionHandler
from cloudcafe.compute.extensions.vnc_console_api.client\
import VncConsoleClient
from cloudcafe.compute.extensions.console_output_api.client\
import ConsoleOutputClient
from cloudcafe.compute.flavors_api.client import FlavorsClient
from cloudcafe.compute.quotas_api.client import QuotasClient
from cloudcafe.compute.servers_api.client import ServersClient
@@ -33,13 +42,13 @@ from cloudcafe.compute.hypervisors_api.client import HypervisorsClient
from cloudcafe.compute.extensions.keypairs_api.client import KeypairsClient
from cloudcafe.compute.extensions.security_groups_api.client import \
SecurityGroupsClient, SecurityGroupRulesClient
from cloudcafe.compute.extensions.rescue_api.client import RescueClient
from cloudcafe.compute.extensions.vnc_console_api.client import \
VncConsoleClient
from cloudcafe.compute.servers_api.behaviors import ServerBehaviors
from cloudcafe.compute.images_api.behaviors import ImageBehaviors
from cloudcafe.auth.config import UserAuthConfig, UserConfig, \
ComputeAdminAuthConfig, ComputeAdminUserConfig
from cloudcafe.auth.provider import AuthProvider
from cloudcafe.compute.flavors_api.config import FlavorsConfig
from cloudcafe.compute.images_api.config import ImagesConfig
@@ -105,8 +114,11 @@ class ComputeFixture(BaseTestFixture):
cls.marshalling.serializer,
cls.marshalling.deserializer)
cls.vnc_client = VncConsoleClient(url, access_data.token.id_,
cls.marshalling.serializer,
cls.marshalling.deserializer)
cls.marshalling.serializer,
cls.marshalling.deserializer)
cls.console_output_client = ConsoleOutputClient(
url, access_data.token.id_, cls.marshalling.serializer,
cls.marshalling.deserializer)
cls.server_behaviors = ServerBehaviors(cls.servers_client,
cls.servers_config,
cls.images_config,