Merge "Drop python 2.7 support and testing"
diff --git a/.zuul.yaml b/.zuul.yaml
index 2c9e423..a760a82 100644
--- a/.zuul.yaml
+++ b/.zuul.yaml
@@ -80,6 +80,7 @@
         tempest: true
         tls-proxy: false
       devstack_localrc:
+        USE_PYTHON3: True
         TEMPEST_PLUGINS: '"/opt/stack/telemetry-tempest-plugin /opt/stack/heat-tempest-plugin"'
         GNOCCHI_ARCHIVE_POLICY_TEMPEST: "ceilometer-high-rate"
         CEILOMETER_BACKEND: "gnocchi"
@@ -90,7 +91,17 @@
 - job:
     name: telemetry-dsvm-integration
     parent: telemetry-tempest-base
-    branches: ^(?!stable/(ocata|pike|queens|rocky)).*$
+    branches: ^(?!stable/(ocata|pike|queens|rocky|stein|train)).*$
+
+- job:
+    name: telemetry-dsvm-integration
+    parent: telemetry-tempest-base
+    branches:
+      - stable/stein
+      - stable/train
+    vars:
+      devstack_localrc:
+        USE_PYTHON3: False
 
 - job:
     name: telemetry-dsvm-integration
@@ -101,6 +112,7 @@
       - stable/rocky
     vars:
       devstack_localrc:
+        USE_PYTHON3: False
         GNOCCHI_ARCHIVE_POLICY_TEMPEST: "ceilometer-high"
         GNOCCHI_ARCHIVE_POLICY: "high"
         CEILOMETER_ALARM_AGGREGATION_METHOD: "mean"
@@ -109,7 +121,7 @@
 - job:
     name: telemetry-dsvm-integration-ipv6-only
     parent: devstack-tempest-ipv6
-    branches: ^(?!stable/(ocata|pike|queens|rocky)).*$
+    branches: ^(?!stable/(ocata|pike|queens|rocky|stein)).*$
     description: |
       Telemetry devstack tempest tests job for IPv6-only deployment
     required-projects: *base_required_projects
diff --git a/CONTRIBUTING.rst b/CONTRIBUTING.rst
index 94e0794..7777a1b 100644
--- a/CONTRIBUTING.rst
+++ b/CONTRIBUTING.rst
@@ -1,14 +1,14 @@
 If you would like to contribute to the development of OpenStack, you must
 follow the steps in this page:
 
-   http://docs.openstack.org/infra/manual/developers.html
+   https://docs.openstack.org/infra/manual/developers.html
 
 If you already have a good understanding of how the system works and your
 OpenStack accounts are set up, you can skip to the development workflow
 section of this documentation to learn how changes to OpenStack should be
 submitted for review via the Gerrit tool:
 
-   http://docs.openstack.org/infra/manual/developers.html#development-workflow
+   https://docs.openstack.org/infra/manual/developers.html#development-workflow
 
 Pull requests submitted through GitHub will be ignored.
 
diff --git a/setup.cfg b/setup.cfg
index 9a237a8..d4167e3 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -5,7 +5,7 @@
     README.rst
 author = OpenStack
 author-email = openstack-discuss@lists.openstack.org
-home-page = http://www.openstack.org/
+home-page = https://www.openstack.org/
 classifier =
     Environment :: OpenStack
     Intended Audience :: Information Technology
diff --git a/telemetry_tempest_plugin/aodh/api/base.py b/telemetry_tempest_plugin/aodh/api/base.py
index 1035df7..29b1d61 100644
--- a/telemetry_tempest_plugin/aodh/api/base.py
+++ b/telemetry_tempest_plugin/aodh/api/base.py
@@ -43,10 +43,10 @@
         cls.alarm_ids = []
 
     @classmethod
-    def create_alarm(cls, **kwargs):
+    def create_alarm(cls, type='event', **kwargs):
         body = cls.alarming_client.create_alarm(
             name=data_utils.rand_name('telemetry_alarm'),
-            type='gnocchi_aggregation_by_metrics_threshold', **kwargs)
+            type=type, **kwargs)
         cls.alarm_ids.append(body['alarm_id'])
         return body
 
diff --git a/telemetry_tempest_plugin/aodh/api/test_alarming_api.py b/telemetry_tempest_plugin/aodh/api/test_alarming_api.py
index 1c42e63..9032a1a 100644
--- a/telemetry_tempest_plugin/aodh/api/test_alarming_api.py
+++ b/telemetry_tempest_plugin/aodh/api/test_alarming_api.py
@@ -26,14 +26,16 @@
         super(TelemetryAlarmingAPITest, cls).resource_setup()
 
         if CONF.alarming_plugin.create_alarms:
-            cls.rule = {'metrics': ['c0d457b6-957e-41de-a384-d5eb0957de3b'],
-                        'comparison_operator': 'gt',
-                        'aggregation_method': 'mean',
-                        'threshold': 80.0,
-                        'granularity': 70}
+            cls.rule = {
+                "event_type": "compute.instance.*",
+                "query": [
+                    {"field": "traits.name",
+                     "type": "string",
+                     "op": "eq",
+                     "value": "test"}]
+            }
             for i in range(2):
-                cls.create_alarm(
-                    gnocchi_aggregation_by_metrics_threshold_rule=cls.rule)
+                cls.create_alarm(event_rule=cls.rule)
 
     @decorators.idempotent_id('1c918e06-210b-41eb-bd45-14676dd77cd7')
     def test_alarm_list(self):
@@ -53,38 +55,42 @@
         # Create an alarm
         alarm_name = data_utils.rand_name('telemetry_alarm')
         body = self.alarming_client.create_alarm(
-            name=alarm_name, type='gnocchi_aggregation_by_metrics_threshold',
-            gnocchi_aggregation_by_metrics_threshold_rule=self.rule)
+            name=alarm_name, type='event',
+            event_rule=self.rule)
         self.assertEqual(alarm_name, body['name'])
         alarm_id = body['alarm_id']
-        self.assertDictContainsSubset(self.rule, body[
-            'gnocchi_aggregation_by_metrics_threshold_rule'])
+        self.assertDictContainsSubset(self.rule, body['event_rule'])
+
         # Update alarm with new rule and new name
-        new_rule = {'metrics': ['c0d457b6-957e-41de-a384-d5eb0957de3b'],
-                    'comparison_operator': 'eq',
-                    'aggregation_method': 'mean',
-                    'threshold': 70.0,
-                    'granularity': 60}
+        new_rule = {
+            "event_type": "compute.instance.create",
+            "query": [
+                {"field": "traits.name",
+                 "type": "string",
+                 "op": "eq",
+                 "value": "test"}]
+        }
         alarm_name_updated = data_utils.rand_name('telemetry-alarm-update')
         body = self.alarming_client.update_alarm(
             alarm_id,
-            gnocchi_aggregation_by_metrics_threshold_rule=new_rule,
+            event_rule=new_rule,
             name=alarm_name_updated,
-            type='gnocchi_aggregation_by_metrics_threshold')
+            type='event')
         self.assertEqual(alarm_name_updated, body['name'])
-        self.assertDictContainsSubset(
-            new_rule, body['gnocchi_aggregation_by_metrics_threshold_rule'])
+        self.assertDictContainsSubset(new_rule, body['event_rule'])
+
         # Get and verify details of an alarm after update
         body = self.alarming_client.show_alarm(alarm_id)
         self.assertEqual(alarm_name_updated, body['name'])
-        self.assertDictContainsSubset(
-            new_rule, body['gnocchi_aggregation_by_metrics_threshold_rule'])
+        self.assertDictContainsSubset(new_rule, body['event_rule'])
+
         # Get history for the alarm and verify the same
         body = self.alarming_client.show_alarm_history(alarm_id)
         self.assertEqual("rule change", body[0]['type'])
         self.assertIn(alarm_name_updated, body[0]['detail'])
         self.assertEqual("creation", body[1]['type'])
         self.assertIn(alarm_name, body[1]['detail'])
+
         # Delete alarm and verify if deleted
         self.alarming_client.delete_alarm(alarm_id)
         self.assertRaises(lib_exc.NotFound,
@@ -93,13 +99,14 @@
     @decorators.idempotent_id('aca49486-70bb-4016-87e0-f6131374f742')
     def test_set_get_alarm_state(self):
         alarm_states = ['ok', 'alarm', 'insufficient data']
-        alarm = self.create_alarm(
-            gnocchi_aggregation_by_metrics_threshold_rule=self.rule)
+        alarm = self.create_alarm(event_rule=self.rule)
+
         # Set alarm state and verify
         new_state =\
             [elem for elem in alarm_states if elem != alarm['state']][0]
         state = self.alarming_client.alarm_set_state(alarm['alarm_id'],
                                                      new_state)
+
         self.assertEqual(new_state, state.data)
         # Get alarm state and verify
         state = self.alarming_client.show_alarm_state(alarm['alarm_id'])
diff --git a/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/aodh-gnocchi-threshold-alarm.yaml b/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/aodh-gnocchi-threshold-alarm.yaml
index 9349295..1c55f0b 100644
--- a/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/aodh-gnocchi-threshold-alarm.yaml
+++ b/telemetry_tempest_plugin/scenario/telemetry_integration_gabbits/aodh-gnocchi-threshold-alarm.yaml
@@ -20,7 +20,8 @@
     - name: SETUP. create archive policy gabbiliveceph
       desc: create archve policy 'gabbiliveceph' for tests
       POST: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/archive_policy
-      status: 201
+      # 409 when policy with such name already exists
+      status: 201 || 409
       request_headers:
           content-type: application/json
       data:
@@ -37,8 +38,13 @@
               - mean
               - min
               - max
+
+    - name: check properties of created or existing archive policy
+      GET: $ENVIRON['GNOCCHI_SERVICE_URL']/v1/archive_policy/gabbiliveceph
+      status: 200
+      request_headers:
+          content-type: application/json
       response_json_paths:
-          $.name: gabbiliveceph
           $.back_window: 0
           $.aggregation_methods.`len`: 3
 
diff --git a/tox.ini b/tox.ini
index 72d3525..e8b6fba 100644
--- a/tox.ini
+++ b/tox.ini
@@ -7,7 +7,7 @@
 [testenv]
 basepython = python3
 usedevelop = True
-install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://opendev.org/openstack/requirements/raw/branch/master/upper-constraints.txt} {opts} {packages}
+install_command = pip install -c{env:UPPER_CONSTRAINTS_FILE:https://releases.openstack.org/constraints/upper/master} {opts} {packages}
 setenv =
    VIRTUAL_ENV={envdir}
    PYTHONWARNINGS=default::DeprecationWarning