diff --git a/tests/whitebox/integration/pool/test_list.py b/tests/whitebox/integration/pool/test_list.py index cc7672fb0..90fa9a6ec 100644 --- a/tests/whitebox/integration/pool/test_list.py +++ b/tests/whitebox/integration/pool/test_list.py @@ -1,4 +1,4 @@ -# Copyright 2016 Red Hat, Inc. +# Copyright 2022 Red Hat, Inc. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -90,3 +90,34 @@ def test_list_with_cache(self): TEST_RUNNER(command_line) command_line = self._MENU TEST_RUNNER(command_line) + + +class List3TestCase(SimTestCase): + """ + Test listing stopped pools. + """ + + _MENU = ["--propagate", "pool", "list-stopped"] + _POOLNAME = "deadpool" + + def setUp(self): + """ + Start the stratisd daemon with the simulator. Create a pool. + """ + super().setUp() + command_line = ["pool", "create", self._POOLNAME] + _DEVICE_STRATEGY() + RUNNER(command_line) + + def test_list(self): + """ + Test listing all with a stopped pool. + """ + command_line = ["pool", "stop", self._POOLNAME] + RUNNER(command_line) + TEST_RUNNER(self._MENU) + + def test_list_empty(self): + """ + Test listing when there are no stopped pools. + """ + TEST_RUNNER(self._MENU) diff --git a/tests/whitebox/integration/pool/test_start.py b/tests/whitebox/integration/pool/test_start.py new file mode 100644 index 000000000..309beb0c4 --- /dev/null +++ b/tests/whitebox/integration/pool/test_start.py @@ -0,0 +1,51 @@ +# Copyright 2022 Red Hat, Inc. +# +# 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. +""" +Test 'start'. +""" + +# isort: STDLIB +from uuid import uuid4 + +# isort: LOCAL +from stratis_cli import StratisCliErrorCodes +from stratis_cli._errors import StratisCliEngineError + +from .._misc import RUNNER, SimTestCase, device_name_list + +_ERROR = StratisCliErrorCodes.ERROR +_DEVICE_STRATEGY = device_name_list(1, 1) + + +class StartTestCase(SimTestCase): + """ + Test 'start' on a sim pool. + """ + + _MENU = ["--propagate", "pool", "start"] + _POOLNAME = "poolname" + + def setUp(self): + super().setUp() + command_line = ["pool", "create", self._POOLNAME] + _DEVICE_STRATEGY() + RUNNER(command_line) + command_line = ["pool", "stop", self._POOLNAME] + RUNNER(command_line) + + def test_bad_uuid(self): + """ + Test trying to start a pool with non-existent UUID. + """ + command_line = self._MENU + [str(uuid4())] + self.check_error(StratisCliEngineError, command_line, _ERROR) diff --git a/tests/whitebox/integration/pool/test_stop.py b/tests/whitebox/integration/pool/test_stop.py new file mode 100644 index 000000000..87e649b8d --- /dev/null +++ b/tests/whitebox/integration/pool/test_stop.py @@ -0,0 +1,47 @@ +# Copyright 2022 Red Hat, Inc. +# +# 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. +""" +Test 'stop'. +""" + +# isort: LOCAL +from stratis_cli import StratisCliErrorCodes + +from .._misc import RUNNER, TEST_RUNNER, SimTestCase, device_name_list + +_ERROR = StratisCliErrorCodes.ERROR +_DEVICE_STRATEGY = device_name_list(1, 1) + + +class StopTestCase(SimTestCase): + """ + Test 'stop' on a sim pool. + """ + + _MENU = ["--propagate", "pool", "stop"] + _POOLNAME = "poolname" + + def setUp(self): + super().setUp() + command_line = ["pool", "create", self._POOLNAME] + _DEVICE_STRATEGY() + RUNNER(command_line) + + def test_stop(self): + """ + Stopping with known name should always succeed. + """ + command_line = self._MENU + [ + self._POOLNAME, + ] + TEST_RUNNER(command_line)