Skip to content

Commit

Permalink
DAOS-4474 test: Use daos command to destroy container to avoid error (#…
Browse files Browse the repository at this point in the history
…2447)

If we open container with invalid parameter, destroying it
during tearDown causes an error with API, so use daos command
to create and destroy. This way, we don't get any error during
teardown.

Signed-off-by: Makito Kano <[email protected]>
  • Loading branch information
shimizukko authored Apr 22, 2020
1 parent 95545e8 commit ab5f529
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 13 deletions.
17 changes: 8 additions & 9 deletions src/tests/ftest/container/open.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@
Any reproduction of computer software, computer software documentation, or
portions thereof marked with this legend must also reproduce the markings.
'''
from __future__ import print_function

import traceback
import uuid

from apricot import TestWithServers
from test_utils_pool import TestPool
from test_utils_container import TestContainer
from avocado.core.exceptions import TestFail
from daos_utils import DaosCommand

RESULT_PASS = "PASS"
RESULT_FAIL = "FAIL"
Expand Down Expand Up @@ -64,7 +63,7 @@ def test_container_open(self):
Open container with valid and invalid pool handle and container
UUID
:avocado: tags=all,container,tiny,full_regression,containeropen
:avocado: tags=all,container,tiny,full_regression,container_open
"""
self.pool = []
self.container = []
Expand Down Expand Up @@ -93,7 +92,7 @@ def test_container_open(self):
expected_result = RESULT_FAIL
break

# Prepare the messages for the 3 test cases
# Prepare the messages for the 3 test cases.
# Test Bug! indicates that there's something wrong with the test since
# it shouldn't reach that point
messages_case_1 = [
Expand Down Expand Up @@ -125,19 +124,18 @@ def test_container_open(self):
# Create the pool and connect. Then create the container from the pool
# Add the pool and the container created into a list
container_uuids = []
#for i in range(2):
i = 0
while i < 2:
for _ in range(2):
self.pool.append(TestPool(
self.context, dmg_command=self.get_dmg_command()))
self.pool[-1].get_params(self)
self.pool[-1].create()
self.pool[-1].connect()
self.container.append(TestContainer(self.pool[-1]))
self.container.append(
TestContainer(pool=self.pool[-1],
daos_command=DaosCommand(self.bin)))
self.container[-1].get_params(self)
self.container[-1].create()
container_uuids.append(uuid.UUID(self.container[-1].uuid))
i += 1

# Decide which pool handle and container UUID to use. The PASS/FAIL
# number corresponds to the index for self.pool and container_uuids
Expand All @@ -156,6 +154,7 @@ def test_container_open(self):
print(traceback.format_exc())
self.assertEqual(expected_result, RESULT_FAIL,
result_messages[test_case][1])

# Case 2. Symmetric to Case 1. Use the other handle and UUID
pool_handle_index = pool_handle_index ^ 1
container_uuid_index = container_uuid_index ^ 1
Expand Down
6 changes: 3 additions & 3 deletions src/tests/ftest/container/open.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# change host names to your reserved nodes, the
# required quantity is indicated by the placeholders
hosts:
test_servers:
- server-A
Expand All @@ -8,8 +6,10 @@ server_config:
pool:
mode: 511
name: daos_server
scm_size: 1073741824
scm_size: 1G
control_method: dmg
container:
control_method: daos
container_uuid_states: !mux
gooduuid:
uuid:
Expand Down
4 changes: 3 additions & 1 deletion src/tests/ftest/util/test_utils_container.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,7 @@ def create(self, uuid=None, con_in=None):
# Populte the empty DaosContainer object with the properties of the
# container created with daos container create.
self.container.uuid = str_to_c_uuid(uuid)
self.container.attached = 1

elif self.control_method.value == self.USE_DAOS:
self.log.error("Error: Undefined daos command")
Expand Down Expand Up @@ -438,7 +439,8 @@ def destroy(self, force=1):
# Destroy the container with the daos command
kwargs["pool"] = self.pool.uuid
kwargs["sys_name"] = self.pool.name.value
kwargs["svc"] = ",".join(self.pool.svc_ranks)
kwargs["svc"] = ",".join(
[str(item) for item in self.pool.svc_ranks])
kwargs["cont"] = self.uuid
self._log_method("daos.container_destroy", kwargs)
self.daos.container_destroy(**kwargs)
Expand Down

0 comments on commit ab5f529

Please sign in to comment.