|
| 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