]> git.apps.os.sepia.ceph.com Git - s3-tests.git/commitdiff
website: routing_setup() as pytest fixture ceph-reef
authorCasey Bodley <cbodley@redhat.com>
Wed, 4 Jun 2025 22:31:39 +0000 (18:31 -0400)
committerCasey Bodley <cbodley@redhat.com>
Fri, 6 Jun 2025 13:30:54 +0000 (09:30 -0400)
c80e9d2118ca5bcdec5285898a532f8e18faa6b6 had removed the use of
routing_setup() without adding a fixture to replace it. this had broken
routing_check(), but we hadn't noticed it because pytest hadn't
supported the 'yield' pattern in test_routing_generator() to call it

test_routing_generator() now uses this routing_setup fixture to provide
the kwargs that had previously been injected into routing_check() via
@common.with_setup_kwargs(setup=routing_setup, teardown=routing_teardown)

Signed-off-by: Casey Bodley <cbodley@redhat.com>
(cherry picked from commit 9839a407c2353125bb867dec67a8f9960b1a2065)

s3tests/functional/test_s3_website.py

index 7831796eee438da08a8f939fb5e9045353e44463..4df5f901a8756872db79c8cc129d927b361200eb 100644 (file)
@@ -1002,8 +1002,8 @@ for redirect_code in VALID_AMZ_REDIRECT:
 # give an error of 'The provided HTTP redirect code (314) is not valid. Valid codes are 3XX except 300.' during setting the website config
 # we should check that we can return that too on ceph
 
+@pytest.fixture
 def routing_setup():
-  check_can_test_website()
   kwargs = {'obj':[]}
   bucket = get_new_bucket()
   kwargs['bucket'] = bucket
@@ -1033,9 +1033,8 @@ def routing_setup():
   while bucket.get_key(f['ErrorDocument_Key']) is None:
       time.sleep(SLEEP_INTERVAL)
 
-  return kwargs
+  yield kwargs
 
-def routing_teardown(**kwargs):
   for o in reversed(kwargs['obj']):
     print('Deleting', str(o))
     o.delete()
@@ -1078,7 +1077,7 @@ def routing_check(*args, **kwargs):
 @pytest.mark.s3website
 @pytest.mark.fails_on_dbstore
 @pytest.mark.parametrize('t', ROUTING_RULES_TESTS)
-def test_routing_generator(t):
+def test_routing_generator(t, routing_setup):
     if 'xml' in t and 'RoutingRules' in t['xml'] and len(t['xml']['RoutingRules']) > 0:
         t['xml']['RoutingRules'] = common.trim_xml(t['xml']['RoutingRules'])
-    routing_check(t)
+    routing_check(t, **routing_setup)