Skip to content

Commit

Permalink
Add some tests
Browse files Browse the repository at this point in the history
Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Apr 28, 2022
1 parent b932f98 commit fc5d472
Show file tree
Hide file tree
Showing 3 changed files with 130 additions and 1 deletion.
33 changes: 32 additions & 1 deletion tests/whitebox/integration/pool/test_list.py
Original file line number Diff line number Diff line change
@@ -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.
Expand Down Expand Up @@ -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)
51 changes: 51 additions & 0 deletions tests/whitebox/integration/pool/test_start.py
Original file line number Diff line number Diff line change
@@ -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)
47 changes: 47 additions & 0 deletions tests/whitebox/integration/pool/test_stop.py
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit fc5d472

Please sign in to comment.