]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: pubsub add ACK test. add multi site readme
authorYuval Lifshitz <yuvalif@yahoo.com>
Thu, 7 Feb 2019 13:12:31 +0000 (15:12 +0200)
committerYuval Lifshitz <yuvalif@yahoo.com>
Thu, 7 Feb 2019 13:12:31 +0000 (15:12 +0200)
Signed-off-by: Yuval Lifshitz <yuvalif@yahoo.com>
src/test/rgw/rgw_multi/tests_ps.py
src/test/rgw/rgw_multi/zone_ps.py
src/test/rgw/test_multi.md [new file with mode: 0644]
src/test/rgw/test_multi.py

index 7a6727f3ddaa83508375774d65d68231cc1f6eb1..b568008b9dcaa0acf83a21a66c07edce92fab9f8 100644 (file)
@@ -405,3 +405,69 @@ def test_ps_event_fetching():
     for key in bucket.list():
         key.delete()
     zones[0].delete_bucket(bucket_name)
+
+
+def test_ps_event_acking():
+    """ test acking of some events in a subscription """
+    zones, 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)
+    topic_conf.set_config()
+    # 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 notifications
+    notification_conf = PSNotification(ps_zones[0].conn, bucket_name,
+                                       topic_name)
+    _, status = notification_conf.set_config()
+    assert_equal(status/100, 2)
+    # create subscription
+    sub_conf = PSSubscription(ps_zones[0].conn, bucket_name+SUB_SUFFIX,
+                              topic_name)
+    _, status = sub_conf.set_config()
+    assert_equal(status/100, 2)
+    # get the subscription
+    result, _ = sub_conf.get_config()
+    parsed_result = json.loads(result)
+    assert_equal(parsed_result['topic'], topic_name)
+    # create objects in the bucket
+    number_of_objects = 10
+    for i in range(number_of_objects):
+        key = bucket.new_key(str(i))
+        key.set_contents_from_string('bar')
+    # wait for sync
+    zone_meta_checkpoint(ps_zones[0].zone)
+
+    # get the create events from the subscription
+    result, _ = sub_conf.get_events()
+    parsed_result = json.loads(result)
+    for event in parsed_result['events']:
+        log.debug('Event (before ack)  id: "' + str(event['id']) + '"')
+    assert_equal(len(parsed_result['events']), number_of_objects)
+    # ack half of the  events
+    events_to_ack = number_of_objects/2
+    for event in parsed_result['events']:
+        if events_to_ack == 0:
+            break
+        _, status = sub_conf.ack_events(event['id'])
+        assert_equal(status/100, 2)
+        events_to_ack -= 1
+
+    # verify that acked events are gone
+    result, _ = sub_conf.get_events()
+    parsed_result = json.loads(result)
+    for event in parsed_result['events']:
+        log.debug('Event (after ack) id: "' + str(event['id']) + '"')
+    assert_equal(len(parsed_result['events']), number_of_objects - number_of_objects/2)
+
+    # cleanup
+    sub_conf.del_config()
+    notification_conf.del_config()
+    topic_conf.del_config()
+    for key in bucket.list():
+        key.delete()
+    zones[0].delete_bucket(bucket_name)
index e720d10ee3eae2952e044daac3000dfa41bdd001..31a7d4726b1eb8cfa463708a59754ad058e7d795 100644 (file)
@@ -50,8 +50,8 @@ def make_request(conn, method, resource, parameters=None):
                'Date': string_date,
                'Host': conn.host+':'+str(conn.port)}
     http_conn = httplib.HTTPConnection(conn.host, conn.port)
-    # TODO set http log level from regular log level
-    # http_conn.set_debuglevel(log.getEffectiveLevel())
+    if log.getEffectiveLevel() <= 10:
+        http_conn.set_debuglevel(5)
     http_conn.request(method, resource+url_params, NO_HTTP_BODY, headers)
     response = http_conn.getresponse()
     data = response.read()
diff --git a/src/test/rgw/test_multi.md b/src/test/rgw/test_multi.md
new file mode 100644 (file)
index 0000000..9be658b
--- /dev/null
@@ -0,0 +1,47 @@
+# Multi Site Test Framework
+This framework allows you to write and run tests against a **local** multi-cluster environment. The framework is using the `mstart.sh` script in order to setup the environment according to a configuration file, and then uses the [nose](https://nose.readthedocs.io/en/latest/) test framework to actually run the tests.
+Tests are written in python2.7, but can invoke shell scripts, binaries etc.
+## Running Tests
+Entry point for all tests is `/path/to/ceph/src/test/rgw/test_multi.py`. And the actual tests are located inside the `/path/to/ceph/src/test/rgw/rgw_multi` subdirectory.
+So, to run all tests use:
+```
+$ cd /path/to/ceph/src/test/rgw/
+$ nosetests test_multi.py
+```
+This will assume a configuration file called `/path/to/ceph/src/test/rgw/test_multi.conf` exists.
+To use a different configuration file, set the `RGW_MULTI_TEST_CONF` environment variable to point to that file.
+Since we use the same entry point file for all tests, running specific tests is possible using the following format:
+```
+$ nosetests test_multi.py:<specific_test_name>
+```
+Note that the test to run, does not have to be inside the `test_multi.py` file.
+Note that different options for running specific and multiple tests exists in the [nose documentation](https://nose.readthedocs.io/en/latest/usage.html#options), as well as other options to control the execution of the tests.
+## Configuration
+The configuration file for the run has 3 sections:
+### Default
+This section holds the following parameters:
+ - `num_zonegroups`: number of zone groups (integer, default 1)
+ - `num_zones`: number of regular zones in each group (integer, default 3)
+ - `num_ps_zones`: number of pubsub zones in each group (integer, default 0)         
+ - `gateways_per_zone`: number of RADOS gateways per zone (integer, default 2)
+ - `no_bootstrap`: whether to assume that the cluster is already up and does not need to be setup again. If set to "false", it will try to re-run the cluster, so, `mstop.sh` must be called beforehand. Should be set to false, anytime the configuration is changed. Otherwise, and assuming the cluster is already up, it should be set to "true" to save on execution time (boolean, default false)
+ - `log_level`: console log level of the logs in the tests, note that any program invoked from the test my emit logs regardless of that setting (integer, default 20)
+    - 20 and up -> DEBUG
+    - 10 and up -> INFO
+    - 5 and up -> WARNING
+    - 1 and up -> ERROR
+    - CRITICAL is always logged
+- `log_file`: log file name. If not set, only console logs exists (string, default None)
+- `file_log_level`: file log level of the logs in the tests. Similar to `log_level`
+- `tenant`: name of tenant (string, default None)
+- `checkpoint_retries`: *TODO* (integer, default 60)
+- `checkpoint_delay`: *TODO* (integer, default 5)
+- `reconfigure_delay`: *TODO* (integer, default 5)          
+### Elasticsearch
+*TODO*
+### Cloud
+*TODO*
+## Writing Tests
+New tests should be added into the `/path/to/ceph/src/test/rgw/rgw_multi` subdirectory.
+- Base classes are in: `/path/to/ceph/src/test/rgw/rgw_multi/multisite.py`
+- `/path/to/ceph/src/test/rgw/rgw_multi/tests.py` holds the majority of the tests, but also many utility and infrastructure functions that could be used in other tests files 
index f4a64d924a3defb19b424d9161c69e60ad4523fe..6b12a6c0e0e3be120b1961f956f0cc019256bf38 100644 (file)
@@ -155,6 +155,7 @@ def setup_logging(log_level_console, log_file, log_level_file):
     ch.setFormatter(formatter)
     ch.setLevel(get_log_level(log_level_console))
     log.addHandler(ch)
+    log.setLevel(get_log_level(log_level_console))
 
 def init(parse_args):
     cfg = configparser.RawConfigParser({