Skip to content

Commit

Permalink
[metricsadvisor] live fix (#14780)
Browse files Browse the repository at this point in the history
* rerecord incident root cause test with ID that returns root cause that is not transient

* try better different randomizer

* shorten name
  • Loading branch information
kristapratico authored Oct 26, 2020
1 parent 4760227 commit 14713f3
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
from azure_devtools.scenario_tests.utilities import trim_kwargs_from_test_function
from devtools_testutils import AzureTestCase
from azure_devtools.scenario_tests import (
ReplayableTest
ReplayableTest,
create_random_name
)

from azure.ai.metricsadvisor import (
MetricsAdvisorKeyCredential,
)
Expand Down Expand Up @@ -179,7 +179,7 @@ def __init__(self, method_name):
MetricsAdvisorKeyCredential(subscription_key, api_key))

async def _create_data_feed(self, name):
name = self.create_random_name(name)
name = create_random_name(name)
return await self.admin_client.create_data_feed(
DataFeed(
name=name,
Expand Down Expand Up @@ -209,7 +209,7 @@ async def _create_data_feed(self, name):

async def _create_data_feed_and_anomaly_detection_config(self, name):
data_feed = await self._create_data_feed(name)
detection_config_name = self.create_random_name(name)
detection_config_name = create_random_name(name)
detection_config = await self.admin_client.create_metric_anomaly_detection_configuration(
AnomalyDetectionConfiguration(
name=detection_config_name,
Expand All @@ -230,7 +230,7 @@ async def _create_data_feed_and_anomaly_detection_config(self, name):
return detection_config, data_feed

async def _create_data_feed_for_update(self, name):
data_feed_name = self.create_random_name(name)
data_feed_name = create_random_name(name)
return await self.admin_client.create_data_feed(
DataFeed(
name=data_feed_name,
Expand Down Expand Up @@ -279,7 +279,7 @@ async def _create_data_feed_for_update(self, name):

async def _create_anomaly_alert_config_for_update(self, name):
detection_config, data_feed = await self._create_data_feed_and_anomaly_detection_config(name)
alert_config_name = self.create_random_name(name)
alert_config_name = create_random_name(name)
alert_config = await self.admin_client.create_anomaly_alert_configuration(
AnomalyAlertConfiguration(
name=alert_config_name,
Expand Down Expand Up @@ -337,7 +337,7 @@ async def _create_anomaly_alert_config_for_update(self, name):

async def _create_detection_config_for_update(self, name):
data_feed = await self._create_data_feed(name)
detection_config_name = self.create_random_name("testupdated")
detection_config_name = create_random_name("testupdated")
detection_config = await self.admin_client.create_metric_anomaly_detection_configuration(
AnomalyDetectionConfiguration(
name=detection_config_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ interactions:
uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/enrichment/anomalyDetection/configurations/anomaly_detection_configuration_id/incidents/incident_id/rootCause
response:
body:
string: '{"value":[{"rootCause":{"dimension":{"category":"Shoes Handbags & Sunglasses","dimension_name":"Mumbai"}},"path":["dimension_name","category"],"score":0.1494267098214867,"description":"Decrease
on category = Shoes Handbags & Sunglasses | dimension_name = Mumbai contributes
string: '{"value":[{"rootCause":{"dimension":{"category":"Electronics (Consumer)","dimension_name":"Karachi"}},"path":["dimension_name"],"score":0.34265262137636504,"description":"Increase
on category = Electronics (Consumer) | dimension_name = Karachi contributes
the most to current incident."}]}'
headers:
apim-request-id: 10991b64-5d97-4897-b69c-7a83a1cd219b
content-length: '277'
apim-request-id: fa45d3b0-f5bb-459d-8d1e-5cc4dc55292a
content-length: '259'
content-type: application/json; charset=utf-8
date: Fri, 23 Oct 2020 16:06:06 GMT
date: Mon, 26 Oct 2020 19:42:46 GMT
strict-transport-security: max-age=31536000; includeSubDomains; preload
x-content-type-options: nosniff
x-envoy-upstream-service-time: '5422'
x-request-id: 10991b64-5d97-4897-b69c-7a83a1cd219b
x-envoy-upstream-service-time: '415'
x-request-id: fa45d3b0-f5bb-459d-8d1e-5cc4dc55292a
status:
code: 200
message: OK
url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/enrichment/anomalyDetection/configurations/fb5a6ed6-2b9e-4b72-8b0c-0046ead1c15c/incidents/5a0692283edccf37ce825b3a8d475f4e-174e1756000/rootCause
url: https://js-metrics-advisor.cognitiveservices.azure.com//metricsadvisor/v1.0/enrichment/anomalyDetection/configurations/fb5a6ed6-2b9e-4b72-8b0c-0046ead1c15c/incidents/2583ff47fef9174e6d6bfe73415ad914-174d2024c00/rootCause
version: 1
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ async def test_create_ad_config_with_series_and_group_conds(self):

@AzureTestCase.await_prepared_test
async def test_create_ad_config_multiple_series_and_group_conds(self):
data_feed = await self._create_data_feed("datafeedforconfigasync")
data_feed = await self._create_data_feed("datafeedconfigasync")
async with self.admin_client:
try:
detection_config_name = self.create_random_name("multipledetectionconfigsasync")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import datetime
from devtools_testutils import AzureTestCase
from azure_devtools.scenario_tests import (
ReplayableTest
ReplayableTest,
create_random_name
)

from azure.ai.metricsadvisor import (
Expand Down Expand Up @@ -174,7 +175,7 @@ def __init__(self, method_name):
MetricsAdvisorKeyCredential(subscription_key, api_key))

def _create_data_feed(self, name):
name = self.create_random_name(name)
name = create_random_name(name)
return self.admin_client.create_data_feed(
DataFeed(
name=name,
Expand Down Expand Up @@ -204,7 +205,7 @@ def _create_data_feed(self, name):

def _create_data_feed_and_anomaly_detection_config(self, name):
data_feed = self._create_data_feed(name)
detection_config_name = self.create_random_name(name)
detection_config_name = create_random_name(name)
detection_config = self.admin_client.create_metric_anomaly_detection_configuration(
AnomalyDetectionConfiguration(
name=detection_config_name,
Expand All @@ -225,7 +226,7 @@ def _create_data_feed_and_anomaly_detection_config(self, name):
return detection_config, data_feed

def _create_data_feed_for_update(self, name):
data_feed_name = self.create_random_name(name)
data_feed_name = create_random_name(name)
return self.admin_client.create_data_feed(
DataFeed(
name=data_feed_name,
Expand Down Expand Up @@ -273,7 +274,7 @@ def _create_data_feed_for_update(self, name):

def _create_anomaly_alert_config_for_update(self, name):
detection_config, data_feed = self._create_data_feed_and_anomaly_detection_config(name)
alert_config_name = self.create_random_name(name)
alert_config_name = create_random_name(name)
alert_config = self.admin_client.create_anomaly_alert_configuration(
AnomalyAlertConfiguration(
name=alert_config_name,
Expand Down Expand Up @@ -331,7 +332,7 @@ def _create_anomaly_alert_config_for_update(self, name):

def _create_detection_config_for_update(self, name):
data_feed = self._create_data_feed(name)
detection_config_name = self.create_random_name("testupdated")
detection_config_name = create_random_name("testupdated")
detection_config = self.admin_client.create_metric_anomaly_detection_configuration(
AnomalyDetectionConfiguration(
name=detection_config_name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,26 @@ interactions:
uri: https://js-metrics-advisor.cognitiveservices.azure.com/metricsadvisor/v1.0/enrichment/anomalyDetection/configurations/anomaly_detection_configuration_id/incidents/incident_id/rootCause
response:
body:
string: '{"value":[{"rootCause":{"dimension":{"category":"Shoes Handbags & Sunglasses","dimension_name":"Mumbai"}},"path":["dimension_name","category"],"score":0.1494267098214867,"description":"Decrease
on category = Shoes Handbags & Sunglasses | dimension_name = Mumbai contributes
string: '{"value":[{"rootCause":{"dimension":{"category":"Electronics (Consumer)","dimension_name":"Karachi"}},"path":["dimension_name"],"score":0.34265262137636504,"description":"Increase
on category = Electronics (Consumer) | dimension_name = Karachi contributes
the most to current incident."}]}'
headers:
apim-request-id:
- 828a8895-7d09-4a7f-9deb-3971845e666e
- 90fb6c36-5f75-4e4e-84ec-d5e503ab2b06
content-length:
- '277'
- '259'
content-type:
- application/json; charset=utf-8
date:
- Fri, 23 Oct 2020 16:05:03 GMT
- Mon, 26 Oct 2020 19:39:10 GMT
strict-transport-security:
- max-age=31536000; includeSubDomains; preload
x-content-type-options:
- nosniff
x-envoy-upstream-service-time:
- '352'
- '5448'
x-request-id:
- 828a8895-7d09-4a7f-9deb-3971845e666e
- 90fb6c36-5f75-4e4e-84ec-d5e503ab2b06
status:
code: 200
message: OK
Expand Down

0 comments on commit 14713f3

Please sign in to comment.