]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
Revert "quincy: rgw/admin/notifications: support admin operations on topics with... revert-59322-wip-58364-quincy
authorShilpa Jagannath <smanjara@users.noreply.github.com>
Thu, 29 Aug 2024 23:05:19 +0000 (16:05 -0700)
committerGitHub <noreply@github.com>
Thu, 29 Aug 2024 23:05:19 +0000 (16:05 -0700)
src/rgw/rgw_admin.cc
src/test/rgw/bucket_notification/api.py
src/test/rgw/bucket_notification/test_bn.py

index a7c6e3af014cb7f478cc1d184b8ce2bd26c86630..823fc65dbdf15bab5af12f71a76f013d141cc588 100644 (file)
@@ -4311,10 +4311,7 @@ int main(int argc, const char **argv)
                           && opt_cmd != OPT::ROLE_POLICY_DELETE
                           && opt_cmd != OPT::RESHARD_ADD
                           && opt_cmd != OPT::RESHARD_CANCEL
-                          && opt_cmd != OPT::RESHARD_STATUS
-                          && opt_cmd != OPT::PUBSUB_TOPICS_LIST
-                          && opt_cmd != OPT::PUBSUB_TOPIC_GET
-                          && opt_cmd != OPT::PUBSUB_TOPIC_RM) {
+                          && opt_cmd != OPT::RESHARD_STATUS) {
         cerr << "ERROR: --tenant is set, but there's no user ID" << std::endl;
         return EINVAL;
       }
index fe38576fb3512e7ef1ead5ff4669debcf844a368..2e0fc9ca1df68dda1013d07db99e6004a2407757 100644 (file)
@@ -56,6 +56,23 @@ def make_request(conn, method, resource, parameters=None, sign_parameters=False,
     http_conn.close()
     return data.decode('utf-8'), status
 
+def delete_all_s3_topics(zone, region):
+    try:
+        conn = zone.secure_conn if zone.secure_conn is not None else zone.conn
+        protocol = 'https' if conn.is_secure else 'http'
+        client = boto3.client('sns',
+                endpoint_url=protocol+'://'+conn.host+':'+str(conn.port),
+                aws_access_key_id=conn.aws_access_key_id,
+                aws_secret_access_key=conn.aws_secret_access_key,
+                region_name=region,
+                verify='./cert.pem')
+
+        topics = client.list_topics()['Topics']
+        for topic in topics:
+            print('topic cleanup, deleting: ' + topic['TopicArn'])
+            assert client.delete_topic(TopicArn=topic['TopicArn'])['ResponseMetadata']['HTTPStatusCode'] == 200
+    except Exception as err:
+        print('failed to do topic cleanup: ' + str(err))
 
 def delete_all_objects(conn, bucket_name):
     client = boto3.client('s3',
@@ -132,9 +149,9 @@ class PSTopicS3:
         self.topic_arn = result['TopicArn']
         return self.topic_arn
 
-    def del_config(self, topic_arn=None):
+    def del_config(self):
         """delete topic"""
-        result = self.client.delete_topic(TopicArn=(topic_arn if topic_arn is not None else self.topic_arn))
+        result = self.client.delete_topic(TopicArn=self.topic_arn)
         return result['ResponseMetadata']['HTTPStatusCode']
 
     def get_list(self):
index 51e40daf2811c6077b7883aefe0c6453ac490009..812a07d1b081a6687324ae25675cec3366f417b6 100644 (file)
@@ -29,6 +29,7 @@ from . import(
 
 from .api import PSTopicS3, \
     PSNotificationS3, \
+    delete_all_s3_topics, \
     delete_all_objects, \
     put_object_tagging, \
     admin
@@ -484,7 +485,6 @@ def stop_kafka_receiver(receiver, task):
 def get_ip():
     return 'localhost'
 
-
 def get_ip_http():
     s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
     try:
@@ -495,7 +495,6 @@ def get_ip_http():
         s.close()
     return ip
 
-
 def connection():
     hostname = get_config_host()
     port_no = get_config_port()
@@ -509,16 +508,14 @@ def connection():
 
     return conn
 
-
 def connection2():
-    hostname = get_config_host()
-    port_no = 8001
-    vstart_access_key = get_access_key()
-    vstart_secret_key = get_secret_key()
+    vstart_access_key = '0555b35654ad1656d804'
+    vstart_secret_key = 'h7GhxuBLTrlhVUyxSPUKUV8r/2EI4ngqJxD7iBdBYLhwluN30JaT3Q=='
+    hostname = get_ip()
 
     conn = S3Connection(aws_access_key_id=vstart_access_key,
-                  aws_secret_access_key=vstart_secret_key,
-                      is_secure=False, port=port_no, host=hostname, 
+                      aws_secret_access_key=vstart_secret_key,
+                      is_secure=False, port=8001, host=hostname,
                       calling_format='boto.s3.connection.OrdinaryCallingFormat')
 
     return conn
@@ -529,55 +526,39 @@ def connection2():
 ##############
 
 
-@attr('basic_test')
+@attr('modification_required')
 def test_ps_s3_topic_on_master():
     """ test s3 topics set/get/delete on master """
-    
-    access_key = str(time.time())
-    secret_key = str(time.time())
-    uid = 'superman' + str(time.time())
-    tenant = 'kaboom'
-    _, result = admin(['user', 'create', '--uid', uid, '--tenant', tenant, '--access-key', access_key, '--secret-key', secret_key, '--display-name', '"Super Man"'])  
-    assert_equal(result, 0)
-    conn = S3Connection(aws_access_key_id=access_key,
-                  aws_secret_access_key=secret_key,
-                      is_secure=False, port=get_config_port(), host=get_config_host(), 
-                      calling_format='boto.s3.connection.OrdinaryCallingFormat')
+    return SkipTest('Get tenant function required.')
+
     zonegroup = 'default' 
     bucket_name = gen_bucket_name()
+    conn = connection()
     topic_name = bucket_name + TOPIC_SUFFIX
 
+    # clean all topics
+    delete_all_s3_topics(conn, zonegroup)
+
     # create s3 topics
     endpoint_address = 'amqp://127.0.0.1:7001/vhost_1'
     endpoint_args = 'push-endpoint='+endpoint_address+'&amqp-exchange=amqp.direct&amqp-ack-level=none'
     topic_conf1 = PSTopicS3(conn, topic_name+'_1', zonegroup, endpoint_args=endpoint_args)
-    # clean all topics
-    try:
-        result = topic_conf1.get_list()[0]['ListTopicsResponse']['ListTopicsResult']['Topics']
-        topics = []
-        if result is not None:
-            topics = result['member']
-        for topic in topics:
-            topic_conf1.del_config(topic_arn=topic['TopicArn'])
-    except Exception as err:
-        print('failed to do topic cleanup: ' + str(err))
-
     topic_arn = topic_conf1.set_config()
     assert_equal(topic_arn,
-                 'arn:aws:sns:' + zonegroup + ':' + tenant + ':' + topic_name + '_1')
+                 'arn:aws:sns:' + zonegroup + ':' + get_tenant() + ':' + topic_name + '_1')
 
     endpoint_address = 'http://127.0.0.1:9001'
     endpoint_args = 'push-endpoint='+endpoint_address
     topic_conf2 = PSTopicS3(conn, topic_name+'_2', zonegroup, endpoint_args=endpoint_args)
     topic_arn = topic_conf2.set_config()
     assert_equal(topic_arn,
-                 'arn:aws:sns:' + zonegroup + ':' + tenant + ':' + topic_name + '_2')
+                 'arn:aws:sns:' + zonegroup + ':' + get_tenant() + ':' + topic_name + '_2')
     endpoint_address = 'http://127.0.0.1:9002'
     endpoint_args = 'push-endpoint='+endpoint_address
     topic_conf3 = PSTopicS3(conn, topic_name+'_3', zonegroup, endpoint_args=endpoint_args)
     topic_arn = topic_conf3.set_config()
     assert_equal(topic_arn,
-                 'arn:aws:sns:' + zonegroup + ':' + tenant + ':' + topic_name + '_3')
+                 'arn:aws:sns:' + zonegroup + ':' + get_tenant() + ':' + topic_name + '_3')
 
     # get topic 3
     result, status = topic_conf3.get_config()
@@ -601,95 +582,17 @@ def test_ps_s3_topic_on_master():
 
     # delete topics
     result = topic_conf2.del_config()
-    assert_equal(status, 200)
+    # TODO: should be 200OK
+    # assert_equal(status, 200)
     result = topic_conf3.del_config()
-    assert_equal(status, 200)
+    # TODO: should be 200OK
+    # assert_equal(status, 200)
 
     # get topic list, make sure it is empty
     result, status = topic_conf1.get_list()
     assert_equal(result['ListTopicsResponse']['ListTopicsResult']['Topics'], None)
 
 
-@attr('basic_test')
-def test_ps_s3_topic_admin_on_master():
-    """ test s3 topics set/get/delete on master """
-    
-    access_key = str(time.time())
-    secret_key = str(time.time())
-    uid = 'superman' + str(time.time())
-    tenant = 'kaboom'
-    _, result = admin(['user', 'create', '--uid', uid, '--tenant', tenant, '--access-key', access_key, '--secret-key', secret_key, '--display-name', '"Super Man"'])  
-    assert_equal(result, 0)
-    conn = S3Connection(aws_access_key_id=access_key,
-                  aws_secret_access_key=secret_key,
-                      is_secure=False, port=get_config_port(), host=get_config_host(), 
-                      calling_format='boto.s3.connection.OrdinaryCallingFormat')
-    zonegroup = 'default' 
-    bucket_name = gen_bucket_name()
-    topic_name = bucket_name + TOPIC_SUFFIX
-
-    # create s3 topics
-    endpoint_address = 'amqp://127.0.0.1:7001/vhost_1'
-    endpoint_args = 'push-endpoint='+endpoint_address+'&amqp-exchange=amqp.direct&amqp-ack-level=none'
-    topic_conf1 = PSTopicS3(conn, topic_name+'_1', zonegroup, endpoint_args=endpoint_args)
-    # clean all topics
-    try:
-        result = topic_conf1.get_list()[0]['ListTopicsResponse']['ListTopicsResult']['Topics']
-        topics = []
-        if result is not None:
-            topics = result['member']
-        for topic in topics:
-            topic_conf1.del_config(topic_arn=topic['TopicArn'])
-    except Exception as err:
-        print('failed to do topic cleanup: ' + str(err))
-
-    topic_arn1 = topic_conf1.set_config()
-    assert_equal(topic_arn1,
-                 'arn:aws:sns:' + zonegroup + ':' + tenant + ':' + topic_name + '_1')
-
-    endpoint_address = 'http://127.0.0.1:9001'
-    endpoint_args = 'push-endpoint='+endpoint_address
-    topic_conf2 = PSTopicS3(conn, topic_name+'_2', zonegroup, endpoint_args=endpoint_args)
-    topic_arn2 = topic_conf2.set_config()
-    assert_equal(topic_arn2,
-                 'arn:aws:sns:' + zonegroup + ':' + tenant + ':' + topic_name + '_2')
-    endpoint_address = 'http://127.0.0.1:9002'
-    endpoint_args = 'push-endpoint='+endpoint_address
-    topic_conf3 = PSTopicS3(conn, topic_name+'_3', zonegroup, endpoint_args=endpoint_args)
-    topic_arn3 = topic_conf3.set_config()
-    assert_equal(topic_arn3,
-                 'arn:aws:sns:' + zonegroup + ':' + tenant + ':' + topic_name + '_3')
-
-    # get topic 3 via commandline
-    result = admin(['topic', 'get', '--topic', topic_name+'_3', '--tenant', tenant])  
-    parsed_result = json.loads(result[0])
-    assert_equal(parsed_result['topic']['arn'], topic_arn3)
-
-    # delete topic 3
-    _, result = admin(['topic', 'rm', '--topic', topic_name+'_3', '--tenant', tenant])  
-    assert_equal(result, 0)
-
-    # try to get a deleted topic
-    _, result = admin(['topic', 'get', '--topic', topic_name+'_3', '--tenant', tenant])  
-    assert_equal(result, 2)
-
-    # get the remaining 2 topics
-    result = admin(['topic', 'list', '--tenant', tenant])  
-    parsed_result = json.loads(result[0])
-    assert_equal(len(parsed_result['topics']), 2)
-
-    # delete topics
-    _, result = admin(['topic', 'rm', '--topic', topic_name+'_1', '--tenant', tenant])  
-    assert_equal(result, 0)
-    _, result = admin(['topic', 'rm', '--topic', topic_name+'_2', '--tenant', tenant])  
-    assert_equal(result, 0)
-
-    # get topic list, make sure it is empty
-    result = admin(['topic', 'list', '--tenant', tenant])  
-    parsed_result = json.loads(result[0])
-    assert_equal(len(parsed_result['topics']), 0)
-
-
 @attr('modification_required')
 def test_ps_s3_topic_with_secret_on_master():
     """ test s3 topics with secret set/get/delete on master """