-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathtest_human_readable_logs.py
More file actions
98 lines (82 loc) · 3.71 KB
/
test_human_readable_logs.py
File metadata and controls
98 lines (82 loc) · 3.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you 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
from marvin.cloudstackAPI import updateConfiguration
from marvin.cloudstackTestCase import cloudstackTestCase
from marvin.sshClient import SshClient
from nose.plugins.attrib import attr
class TestHumanReadableLogs(cloudstackTestCase):
"""
Test correct output when logging byte size values.
"""
def setUp(self):
self.apiClient = self.testClient.getApiClient()
self.mgtSvrDetails = self.config.__dict__["mgtSvr"][0].__dict__
@attr(tags=["devcloud", "basic", "advanced"], required_hardware="false")
def test_01_disableHumanReadableLogs(self):
"""
Test log file output after disabling human readable sizes feature
"""
#create ssh client
sshClient = getSSHClient(self)
# Disable feature
updateConfig(self, "false")
# Restart service
command = "systemctl restart cloudstack-management"
sshClient.execute(command)
# CapacityChecker runs as soon as management server is up
# Check if "usedMem: (" is printed out within 120 seconds while server is starting
command = "timeout 120 tail -f /var/log/cloudstack/management/management-server.log | grep 'usedMem: ('"
sshClient.timeout = 120
result = sshClient.runCommand(command)
self.assertTrue(result['status'] == "FAILED")
@attr(tags=["devcloud", "basic", "advanced"], required_hardware="false")
def test_02_enableHumanReadableLogs(self):
"""
Test log file output after enabling human readable sizes feature
"""
# create ssh client
sshClient = getSSHClient(self)
# Enable feature
updateConfig(self, "true")
# Restart service
command = "systemctl restart cloudstack-management"
sshClient.execute(command)
# CapacityChecker runs as soon as management server is up
# Check if "usedMem: (" is printed out within 120 seconds while server is restarting
command = "timeout 120 tail -f /var/log/cloudstack/management/management-server.log | grep 'usedMem: ('"
sshClient.timeout = 120
result = sshClient.runCommand(command)
if result['status'] == "SUCCESS":
pass
else:
self.warn("We're not sure if test didn't pass due to timeout, so skipping failing the test")
def updateConfig(self, enableFeature):
updateConfigurationCmd = updateConfiguration.updateConfigurationCmd()
updateConfigurationCmd.name = "display.human.readable.sizes"
updateConfigurationCmd.value = enableFeature
updateConfigurationResponse = self.apiClient.updateConfiguration(updateConfigurationCmd)
self.debug("updated the parameter %s with value %s" % (
updateConfigurationResponse.name, updateConfigurationResponse.value))
def getSSHClient(self):
sshClient = SshClient(
self.mgtSvrDetails["mgtSvrIp"],
22,
self.mgtSvrDetails["user"],
self.mgtSvrDetails["passwd"]
)
return sshClient