Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DAOS-15645 test: create cont with daos instead of API #15568

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions src/tests/ftest/checksum/csum_basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
"""
(C) Copyright 2019-2024 Intel Corporation.
(C) Copyright 2025 Hewlett Packard Enterprise Development LP

SPDX-License-Identifier: BSD-2-Clause-Patent
"""
Expand Down Expand Up @@ -33,25 +34,22 @@ def test_single_object_with_checksum(self):
:avocado: tags=checksum
:avocado: tags=CsumContainerValidation,test_single_object_with_checksum
"""
no_of_dkeys = self.params.get("no_of_dkeys", '/run/dkeys/*')[0]
no_of_akeys = self.params.get("no_of_akeys", '/run/akeys/*')[0]
no_of_dkeys = self.params.get("no_of_dkeys", '/run/dkeys/*')
no_of_akeys = self.params.get("no_of_akeys", '/run/akeys/*')
record_length = self.params.get("length", '/run/record/*')

pool = add_pool(self, connect=False)
pool.connect(2)

enable_checksum = self.params.get("enable_checksum", '/run/container/*')
container = add_container(self, pool, create=False)
container.input_params.enable_chksum = enable_checksum
container.create()
container = add_container(self, pool)
container.open()

obj = DaosObj(self.context, container.container)
obj.create(objcls=1)
obj.open()
ioreq = IORequest(self.context, container.container, obj, objtype=4)

self.d_log.info("Writing the Single Dataset")
self.log_step("Write single dataset")
record_index = 0
for dkey in range(no_of_dkeys):
for akey in range(no_of_akeys):
Expand All @@ -66,7 +64,7 @@ def test_single_object_with_checksum(self):
if record_index == len(record_length):
record_index = 0

self.d_log.info("Single Dataset Verification -- Started")
self.log_step("Verify single dataset")
record_index = 0
for dkey in range(no_of_dkeys):
for akey in range(no_of_akeys):
Expand All @@ -79,7 +77,7 @@ def test_single_object_with_checksum(self):
"ERROR:Data mismatch for dkey={}, akey={}: indata={}, "
"val={}".format(
dkey, akey, indata, val.value.decode('utf-8')))
self.d_log.error(message)
self.log.error(message)
self.fail(message)
record_index = record_index + 1
if record_index == len(record_length):
Expand Down
27 changes: 13 additions & 14 deletions src/tests/ftest/checksum/csum_basic.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# change host names to your reserved nodes, the
# required quantity is indicated by the placeholders
hosts:
test_servers: 1
test_clients: 1

timeout: 100

server_config:
name: daos_server
engines_per_host: 1
Expand All @@ -16,21 +16,20 @@ server_config:
class: ram
scm_mount: /mnt/daos
system_ram_reserved: 1

pool:
scm_size: 3000000000
svcn: 1
container: !mux
control_method: API
properties:
enable_checksum: true
dkeys: !mux
single:
no_of_dkeys:
- 50
akeys: !mux
single:
no_of_akeys:
- 10

container:
properties: cksum:crc16,cksum_size:16384

dkeys:
no_of_dkeys: 50

akeys:
no_of_akeys: 10

record: !mux
1Byte:
length:
Expand Down
25 changes: 13 additions & 12 deletions src/tests/ftest/container/api_basic_attribute.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'''
(C) Copyright 2018-2023 Intel Corporation.
(C) Copyright 2025 Hewlett Packard Enterprise Development LP

SPDX-License-Identifier: BSD-2-Clause-Patent
'''
Expand Down Expand Up @@ -165,8 +166,8 @@ def test_basic_attribute_sync(self):
if set_exp_result == 'FAIL':
self.fail("set_attr() was expected to fail but it worked!")
except DaosApiError as error:
print(error)
print(traceback.format_exc())
self.log.error(error)
self.log.error(traceback.format_exc())
if self.expected_result == "PASS":
self.fail(
"set_attr was supposed to work, but failed! name-value = {}".format(
Expand All @@ -176,8 +177,8 @@ def test_basic_attribute_sync(self):
try:
size, buf = self.container.container.list_attr()
except DaosApiError as excep:
print(excep)
print(traceback.format_exc())
self.log.error(excep)
self.log.error(traceback.format_exc())
self.fail("list_attr failed!")

if self.expected_result == 'PASS':
Expand All @@ -195,8 +196,8 @@ def test_basic_attribute_sync(self):
if self.expected_result == 'FAIL':
self.fail("get_attr() was expected to fail but it worked!")
except (DaosApiError, DaosTestError) as excep:
print(excep)
print(traceback.format_exc())
self.log.error(excep)
self.log.error(traceback.format_exc())
if self.expected_result == 'PASS':
msg = "get_attr was supposed to work, but failed! attr_name = {}".format(
self.attr_name)
Expand Down Expand Up @@ -238,8 +239,8 @@ def test_basic_attribute_async(self):
ret_code=callback_handler.ret_code, expected_result=set_exp_result,
method_name="set_attr")
except DaosApiError as error:
print(error)
print(traceback.format_exc())
self.log.error(error)
self.log.error(traceback.format_exc())
if self.expected_result == "PASS":
self.fail(
"set_attr was supposed to work, but failed! name-value = {}".format(
Expand All @@ -256,8 +257,8 @@ def test_basic_attribute_async(self):
if ret_code != 0:
self.fail("Unexpected RC after list_attr! {}".format(ret_code))
except DaosApiError as excep:
print(excep)
print(traceback.format_exc())
self.log.error(excep)
self.log.error(traceback.format_exc())
self.fail("list_attr failed!")

if self.expected_result == 'PASS':
Expand All @@ -281,8 +282,8 @@ def test_basic_attribute_async(self):
ret_code=callback_handler.ret_code, expected_result=self.expected_result,
method_name="get_attr")
except DaosApiError as excep:
print(excep)
print(traceback.format_exc())
self.log.error(excep)
self.log.error(traceback.format_exc())
if self.expected_result == 'PASS':
msg = "get_attr was supposed to work, but failed! attr_name = {}".format(
self.attr_name)
Expand Down
3 changes: 0 additions & 3 deletions src/tests/ftest/container/api_basic_attribute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,3 @@ attrtests:
value:
- NULL
- FAIL

container:
control_method: API
3 changes: 0 additions & 3 deletions src/tests/ftest/container/basic_snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,3 @@ object_class: !mux
obj_class: OC_RP_2G1
OC_RP_2G2:
obj_class: OC_RP_2G2

container:
control_method: API
3 changes: 0 additions & 3 deletions src/tests/ftest/container/destroy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ server_config:
pool:
scm_size: 1G

container:
control_method: API

destroy_variants:
destroy_uuid: !mux
good_uid:
Expand Down
3 changes: 1 addition & 2 deletions src/tests/ftest/container/query_attribute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@ server_config:
system_ram_reserved: 1
pool:
scm_size: 1G

container:
control_method: API
properties: cksum:crc16,cksum_size:16384
131 changes: 14 additions & 117 deletions src/tests/ftest/container/query_properties.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
'''
(C) Copyright 2018-2023 Intel Corporation.
(C) Copyright 2025 Hewlett Packard Enterprise Development LP

SPDX-License-Identifier: BSD-2-Clause-Patent
'''
import ctypes

from apricot import TestWithServers
from pydaos.raw import DaosApiError, DaosContPropEnum, conversion, daos_cref
from test_utils_container import add_container
from test_utils_pool import add_pool


class QueryPropertiesTest(TestWithServers):
"""
Test Class Description: Verify container properties are set during container query
over pydaos API.
Test Class Description: Verify daos container get-prop

:avocado: recursive
"""
Expand All @@ -26,124 +23,24 @@ def test_query_properties(self):
some properties during create.

Use Cases:
1. Create a container with some properties related to checksum, type, etc.
configured.
2. Call container query. it returns container info such as UUID, snapshots, etc.,
but not properties. We verify the property by passing in an empty data structure
as pass by reference.
3. Verify the property data structure passed in during step 2.
1. Create a container with some properties related to checksum, type, etc. configured.
2. Verify container get-prop returns the same properties set on create.

:avocado: tags=all,full_regression
:avocado: tags=vm
:avocado: tags=container
:avocado: tags=QueryPropertiesTest,test_query_properties
"""
errors = []

self.log_step("Create pool and container with properties")
pool = add_pool(self)
container = add_container(self, pool, create=False)

# Prepare DaosContProperties. Update some items from default. These are
# properties that determine the values, not the actual values. The actual values
# are set in DaosContainer.create() based on these configurations.
chksum_type_conf = self.params.get("configured", "/run/properties/chksum_type/*")
srv_verify_conf = self.params.get("configured", "/run/properties/srv_verify/*")
chunk_size_conf = self.params.get("configured", "/run/properties/chunk_size/*")

cont_prop_type = bytes("POSIX", "utf-8") # Updated
enable_chksum = True # Updated
srv_verify = srv_verify_conf
chksum_type = ctypes.c_uint64(chksum_type_conf)
chunk_size = ctypes.c_uint64(chunk_size_conf)
rd_lvl = ctypes.c_uint64(daos_cref.DAOS_PROP_CO_REDUN_DEFAULT)
con_in = [
cont_prop_type,
enable_chksum,
srv_verify,
chksum_type,
chunk_size,
rd_lvl
]

# Create container with the DaosContProperties.
container.create(con_in=con_in)

# Open the container.
container.open(pool_handle=pool.pool.handle)

# Prepare the DaosProperty data structure that stores the values that are
# configured based on the properties we used during create. Here, we create
# the empty data structure and set the dpe_type fields. The values (dpe_val) will
# be filled during query. See DaosContainer.create() and DaosContProperties for
# more details.

# If DaosContProperties.type is not "Unknown", there will be 4 elements.

# Element 0: Layout type, which is determined by the container type. If the
# container type is POSIX, we expect the value to be
# DaosContPropEnum.DAOS_PROP_CO_LAYOUT_POSIX.value

# Note: enable_chksum needs to be set to True to get the following 3 elements.
# Element 1: Checksum. In default, we expect it to be 1.
# Element 2: Checksum server verify. Since we updated the srv_verify to True, we
# expect the value to be 1.
# Element 3: Checksum chunk size. In default we expect it to be 16384.
cont_prop = daos_cref.DaosProperty(4)

cont_prop.dpp_entries[0].dpe_type = ctypes.c_uint32(
DaosContPropEnum.DAOS_PROP_CO_LAYOUT_TYPE.value)
cont_prop.dpp_entries[1].dpe_type = ctypes.c_uint32(
DaosContPropEnum.DAOS_PROP_CO_CSUM.value)
cont_prop.dpp_entries[2].dpe_type = ctypes.c_uint32(
DaosContPropEnum.DAOS_PROP_CO_CSUM_SERVER_VERIFY.value)
cont_prop.dpp_entries[3].dpe_type = ctypes.c_uint32(
DaosContPropEnum.DAOS_PROP_CO_CSUM_CHUNK_SIZE.value)

try:
cont_info = container.container.query(cont_prop=cont_prop)
except DaosApiError as error:
self.log.info("Container query error! %s", error)

# Sanity check that query isn't broken.
uuid_query = conversion.c_uuid_to_str(cont_info.ci_uuid)
uuid_create = container.container.get_uuid_str()
if uuid_query != uuid_create:
msg = ("Container UUID obtained after create and after query don't match! "
"Create: {}, Query: {}".format(uuid_create, uuid_query))
errors.append(msg)

# Verify values set in cont_prop.
chksum_type_exp = self.params.get("expected", "/run/properties/chksum_type/*")
srv_verify_exp = self.params.get("expected", "/run/properties/srv_verify/*")
chunk_size_exp = self.params.get("expected", "/run/properties/chunk_size/*")

# Verify layout type.
actual_layout_type = cont_prop.dpp_entries[0].dpe_val
expected_layout_type = DaosContPropEnum.DAOS_PROP_CO_LAYOUT_POSIX.value
if actual_layout_type != expected_layout_type:
msg = "Layout type is not POSIX! Expected = {}; Actual = {}".format(
expected_layout_type, actual_layout_type)
errors.append(msg)

# Verify checksum.
if cont_prop.dpp_entries[1].dpe_val != chksum_type_exp:
msg = "Unexpected checksum from query! Expected = {}; Actual = {}".format(
chksum_type_exp, cont_prop.dpp_entries[1].dpe_val)
errors.append(msg)

# Verify server verify.
if cont_prop.dpp_entries[2].dpe_val != srv_verify_exp:
msg = ("Unexpected server verify from query! "
"Expected = {}; Actual = {}".format(
srv_verify_exp, cont_prop.dpp_entries[2].dpe_val))
errors.append(msg)
container = add_container(self, pool)

# Verify checksum chunk size.
if cont_prop.dpp_entries[3].dpe_val != chunk_size_exp:
msg = ("Unexpected checksum chunk size from query! "
"Expected = {}; Actual = {}".format(
chunk_size_exp, cont_prop.dpp_entries[3].dpe_val))
errors.append(msg)
expected_props = {
"layout_type": self.params.get("layout_type", "/run/expected_get_prop/*"),
"cksum": self.params.get("cksum", "/run/expected_get_prop/*"),
"cksum_size": self.params.get("cksum_size", "/run/expected_get_prop/*"),
"srv_cksum": self.params.get("srv_cksum", "/run/expected_get_prop/*")}

if errors:
self.fail("\n----- Errors detected! -----\n{}".format("\n".join(errors)))
self.log_step("Verify container get-prop matches create")
if not container.verify_prop(expected_props):
self.fail("Unexpected properties from daos container get-prop")
18 changes: 7 additions & 11 deletions src/tests/ftest/container/query_properties.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,11 @@ pool:
scm_size: 1G

container:
control_method: API
type: POSIX
properties: cksum:crc16,cksum_size:16384,srv_cksum:on

properties:
chksum_type:
configured: 100 # Default
expected: 1
srv_verify:
configured: true # Updated
expected: 1
chunk_size:
configured: 0 # Default
expected: 16384
expected_get_prop:
layout_type: "POSIX (1)"
cksum: "crc16"
cksum_size: 16384
srv_cksum: "on"
3 changes: 0 additions & 3 deletions src/tests/ftest/container/snapshot.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@ object_class: !mux
obj_class: OC_SX
OC_RP_2GX:
obj_class: OC_RP_2GX

container:
control_method: API
Loading