def test_ps_topic(): """ test set/get/delete of topic """ _, ps_zones = init_env() bucket_name = gen_bucket_name() topic_name = bucket_name + TOPIC_SUFFIX # create topic topic_conf = PSTopic(ps_zones[0].conn, topic_name) _, status = topic_conf.set_config() assert_equal(status / 100, 2) # get topic result, _ = topic_conf.get_config() # verify topic content parsed_result = json.loads(result) assert_equal(parsed_result['topic']['name'], topic_name) assert_equal(len(parsed_result['subs']), 0) # delete topic _, status = topic_conf.del_config() assert_equal(status / 100, 2) # verift topic is deleted result, _ = topic_conf.get_config() parsed_result = json.loads(result) assert_equal(parsed_result['Code'], 'NoSuchKey')
def test_ps_topic(): """ test set/get/delete of topic """ _, ps_zones = init_env() bucket_name = gen_bucket_name() topic_name = bucket_name+TOPIC_SUFFIX # create topic topic_conf = PSTopic(ps_zones[0].conn, topic_name) _, status = topic_conf.set_config() assert_equal(status/100, 2) # get topic result, _ = topic_conf.get_config() # verify topic content parsed_result = json.loads(result) assert_equal(parsed_result['topic']['name'], topic_name) assert_equal(len(parsed_result['subs']), 0) # delete topic _, status = topic_conf.del_config() assert_equal(status/100, 2) # verift topic is deleted result, _ = topic_conf.get_config() parsed_result = json.loads(result) assert_equal(parsed_result['Code'], 'NoSuchKey')
def test_ps_s3_notification_low_level(): """ test low level implementation of s3 notifications """ zones, ps_zones = init_env() bucket_name = gen_bucket_name() # create bucket on the first of the rados zones bucket = zones[0].create_bucket(bucket_name) # wait for sync zone_meta_checkpoint(ps_zones[0].zone) # create topic topic_name = bucket_name + TOPIC_SUFFIX topic_conf = PSTopic(ps_zones[0].conn, topic_name) _, status = topic_conf.set_config() assert_equal(status / 100, 2) # create s3 notification notification_name = bucket_name + NOTIFICATION_SUFFIX generated_topic_name = notification_name + '_' + topic_name topic_arn = 'arn:aws:sns:::' + topic_name s3_notification_conf = PSNotificationS3(ps_zones[0].conn, bucket_name, notification_name, topic_arn, ['s3:ObjectCreated:*']) response, status = s3_notification_conf.set_config() assert_equal(status / 100, 2) zone_meta_checkpoint(ps_zones[0].zone) # get auto-generated topic generated_topic_conf = PSTopic(ps_zones[0].conn, generated_topic_name) result, status = generated_topic_conf.get_config() parsed_result = json.loads(result) assert_equal(status / 100, 2) assert_equal(parsed_result['topic']['name'], generated_topic_name) # get auto-generated notification notification_conf = PSNotification(ps_zones[0].conn, bucket_name, generated_topic_name) result, status = notification_conf.get_config() parsed_result = json.loads(result) assert_equal(status / 100, 2) assert_equal(len(parsed_result['topics']), 1) # get auto-generated subscription sub_conf = PSSubscription(ps_zones[0].conn, notification_name, generated_topic_name) result, status = sub_conf.get_config() parsed_result = json.loads(result) assert_equal(status / 100, 2) assert_equal(parsed_result['topic'], generated_topic_name) # delete s3 notification _, status = s3_notification_conf.del_config(all_notifications=False) assert_equal(status / 100, 2) # delete topic _, status = topic_conf.del_config() assert_equal(status / 100, 2) # verify low-level cleanup _, status = generated_topic_conf.get_config() assert_equal(status, 404) result, status = notification_conf.get_config() parsed_result = json.loads(result) assert_equal(len(parsed_result['topics']), 0) # TODO should return 404 # assert_equal(status, 404) result, status = sub_conf.get_config() parsed_result = json.loads(result) assert_equal(parsed_result['topic'], '') # TODO should return 404 # assert_equal(status, 404) # cleanup topic_conf.del_config() # delete the bucket zones[0].delete_bucket(bucket_name)
def test_ps_s3_notification_low_level(): """ test low level implementation of s3 notifications """ zones, ps_zones = init_env() bucket_name = gen_bucket_name() # create bucket on the first of the rados zones bucket = zones[0].create_bucket(bucket_name) # wait for sync zone_meta_checkpoint(ps_zones[0].zone) # create topic topic_name = bucket_name + TOPIC_SUFFIX topic_conf = PSTopic(ps_zones[0].conn, topic_name) _, status = topic_conf.set_config() assert_equal(status/100, 2) # create s3 notification notification_name = bucket_name + NOTIFICATION_SUFFIX generated_topic_name = notification_name+'_'+topic_name topic_arn = 'arn:aws:sns:::' + topic_name s3_notification_conf = PSNotificationS3(ps_zones[0].conn, bucket_name, notification_name, topic_arn, ['s3:ObjectCreated:*']) response, status = s3_notification_conf.set_config() assert_equal(status/100, 2) zone_meta_checkpoint(ps_zones[0].zone) # get auto-generated topic generated_topic_conf = PSTopic(ps_zones[0].conn, generated_topic_name) result, status = generated_topic_conf.get_config() parsed_result = json.loads(result) assert_equal(status/100, 2) assert_equal(parsed_result['topic']['name'], generated_topic_name) # get auto-generated notification notification_conf = PSNotification(ps_zones[0].conn, bucket_name, generated_topic_name) result, status = notification_conf.get_config() parsed_result = json.loads(result) assert_equal(status/100, 2) assert_equal(len(parsed_result['topics']), 1) # get auto-generated subscription sub_conf = PSSubscription(ps_zones[0].conn, notification_name, generated_topic_name) result, status = sub_conf.get_config() parsed_result = json.loads(result) assert_equal(status/100, 2) assert_equal(parsed_result['topic'], generated_topic_name) # delete s3 notification _, status = s3_notification_conf.del_config(all_notifications=False) assert_equal(status/100, 2) # delete topic _, status = topic_conf.del_config() assert_equal(status/100, 2) # verify low-level cleanup _, status = generated_topic_conf.get_config() assert_equal(status, 404) result, status = notification_conf.get_config() parsed_result = json.loads(result) assert_equal(len(parsed_result['topics']), 0) # TODO should return 404 # assert_equal(status, 404) result, status = sub_conf.get_config() parsed_result = json.loads(result) assert_equal(parsed_result['topic'], '') # TODO should return 404 # assert_equal(status, 404) # cleanup topic_conf.del_config() # delete the bucket zones[0].delete_bucket(bucket_name)