From 132bb69b85529b63e11b6eeb02af7c72f4a0fdf9 Mon Sep 17 00:00:00 2001 From: caleb Date: Wed, 4 Sep 2024 13:31:36 -0400 Subject: [PATCH] remove REST from test_330 (and rename) --- tests/api2/test_330_pool_acltype.py | 63 ----------------------------- tests/api2/test_acltype.py | 43 ++++++++++++++++++++ 2 files changed, 43 insertions(+), 63 deletions(-) delete mode 100644 tests/api2/test_330_pool_acltype.py create mode 100644 tests/api2/test_acltype.py diff --git a/tests/api2/test_330_pool_acltype.py b/tests/api2/test_330_pool_acltype.py deleted file mode 100644 index 577f880a1b8b9..0000000000000 --- a/tests/api2/test_330_pool_acltype.py +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/env python3 - -import pytest -import sys -import os -from pytest_dependency import depends -apifolder = os.getcwd() -sys.path.append(apifolder) -from auto_config import pool_name -from functions import POST, GET, PUT, DELETE, SSH_TEST -from middlewared.test.integration.utils import call, ssh -from middlewared.test.integration.assets.pool import dataset as make_dataset - -test1_dataset = f'{pool_name}/test1' -dataset_url = test1_dataset.replace("/", "%2F") - - -@pytest.fixture(scope='module') -def create_test_dataset(): - with make_dataset('test1') as ds: - yield ds - - -def test_01_verify_default_acltype_from_pool_dataset_with_api(request): - results = GET(f'/pool/dataset/id/{pool_name}/') - assert results.status_code == 200, results.text - assert results.json()['acltype']['rawvalue'] == 'posix', results.text - - -def test_04_verify_test1_dataset_inherited_parent_acltype_with_api(create_test_dataset, request): - results = GET(f'/pool/dataset/id/{dataset_url}/') - assert results.status_code == 200, results.text - assert results.json()['acltype']['rawvalue'] == 'posix', results.text - - -def test_06_change_acltype_to_nfsv4(create_test_dataset, request): - call('pool.dataset.update', test1_dataset, { - 'acltype': 'NFSV4', 'aclmode': 'PASSTHROUGH' - }) - - res = call('zfs.dataset.query', [['id', '=', test1_dataset]], - {'get': True, 'extra': {'retrieve_children': False}} - ) - props = res['properties'] - - assert props['acltype']['value'] == 'nfsv4', str(props) - assert props['aclmode']['value'] == 'passthrough', str(props) - assert props['aclinherit']['value'] == 'passthrough', str(props) - - -def test_07_reset_acltype_to_posix(create_test_dataset, request): - call('pool.dataset.update', test1_dataset, { - 'acltype': 'POSIX', 'aclmode': 'DISCARD' - }) - - res = call('zfs.dataset.query', [['id', '=', test1_dataset]], - {'get': True, 'extra': {'retrieve_children': False}} - ) - props = res['properties'] - - assert props['acltype']['value'] == 'posix', str(props) - assert props['aclmode']['value'] == 'discard', str(props) - assert props['aclinherit']['value'] == 'discard', str(props) diff --git a/tests/api2/test_acltype.py b/tests/api2/test_acltype.py new file mode 100644 index 0000000000000..81bc2f90dac08 --- /dev/null +++ b/tests/api2/test_acltype.py @@ -0,0 +1,43 @@ +import pytest + +from auto_config import pool_name +from middlewared.test.integration.utils import call +from middlewared.test.integration.assets.pool import dataset + + +def query_filters(ds_name): + return [['id', '=', ds_name]], {'get': True, 'extra': {'retrieve_children': False}} + + +@pytest.fixture(scope='module') +def temp_ds(): + with dataset('test1') as ds: + yield ds + + +def test_default_acltype_on_zpool(): + assert 'POSIXACL' in call('filesystem.statfs', f'/mnt/{pool_name}')['flags'] + + +def test_acltype_inheritance(temp_ds): + assert call('zfs.dataset.query', *query_filters(temp_ds))['properties']['acltype']['rawvalue'] == 'posix' + + +@pytest.mark.parametrize( + 'change,expected', [ + ( + {'acltype': 'NFSV4', 'aclmode': 'PASSTHROUGH'}, + (('acltype', 'value', 'nfsv4'), ('aclmode', 'value', 'passthrough'), ('aclinherit', 'value', 'passthrough')) + ), + ( + {'acltype': 'POSIX', 'aclmode': 'DISCARD'}, + (('acltype', 'value', 'posix'), ('aclmode', 'value', 'discard'), ('aclinherit', 'value', 'discard')) + ), + ], + ids=['NFSV4_PASSTHROUGH', 'POSIX_DISCARD'] +) +def test_change_acltype_and_aclmode_to_(temp_ds, change, expected): + call('pool.dataset.update', temp_ds, change) + props = call('zfs.dataset.query', *query_filters(temp_ds))['properties'] + for tkey, skey, value in expected: + assert props[tkey][skey] == value, props[tkey][skey]