Skip to content

Commit 0de1d90

Browse files
cocopam73nAhYUN22
authored andcommitted
Add functional tests for volume service list/set
This patch adds functional coverage for the 'volume service list' and 'volume service set' commands. It covers filtering by host and service, long output, and enabling/disabling a service with a disabled reason. Change-Id: I3810f6422ac2cadf3ae7d0629d5d2ba4590cc31d Signed-off-by: ljy2855 <ljy2855@gmail.com>
1 parent 23deadb commit 0de1d90

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Licensed under the Apache License, Version 2.0 (the "License"); you may
2+
# not use this file except in compliance with the License. You may obtain
3+
# a copy of the License at
4+
#
5+
# http://www.apache.org/licenses/LICENSE-2.0
6+
#
7+
# Unless required by applicable law or agreed to in writing, software
8+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10+
# License for the specific language governing permissions and limitations
11+
# under the License.
12+
13+
14+
from openstackclient.tests.functional.volume.v3 import common
15+
16+
17+
class VolumeServiceTests(common.BaseVolumeTests):
18+
"""Functional tests for 'openstack volume service'."""
19+
20+
def test_volume_service(self):
21+
"""Verify listing works and host/service filters narrow results."""
22+
23+
# List all services and ensure we have at least one cinder-volume
24+
rows = self.openstack('volume service list', parse_output=True)
25+
self.assertTrue(rows, 'no volume services returned')
26+
27+
# Pick one row for filter checks
28+
row = rows[0]
29+
host = row['Host']
30+
binary = row['Binary']
31+
self.assertIsNotNone(host)
32+
self.assertIsNotNone(binary)
33+
34+
# Filter by host+service should return matching entries only
35+
filtered = self.openstack(
36+
'volume service list --host ' + host + ' --service ' + binary,
37+
parse_output=True,
38+
)
39+
self.assertTrue(filtered, 'filtered list is empty')
40+
for r in filtered:
41+
self.assertEqual(host, r['Host'])
42+
self.assertEqual(binary, r['Binary'])
43+
44+
# --long should include additional details but at least must succeed
45+
long_rows = self.openstack(
46+
'volume service list --long --host '
47+
+ host
48+
+ ' --service '
49+
+ binary,
50+
parse_output=True,
51+
)
52+
self.assertEqual(1, len(long_rows))
53+
# Ensure disabled reason column exists (value may be None)
54+
lr0 = long_rows[0]
55+
self.assertIn('Disabled Reason', lr0)

0 commit comments

Comments
 (0)