Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated model service detectors url #41

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 15 additions & 15 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ def test_cli_build_detectors_already_exists(caplog):
responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags",
json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE,
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
json=MOCK_DETECTORS[0],
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
json=MOCK_DETECTORS[1],
status=200)
metric_configs, exit_code = read_config_file("./tests/data/metric-config.json")
Expand All @@ -50,10 +50,10 @@ def test_cli_build_new_detectors(caplog):
responses.add(responses.POST, "http://modelservice/api/detectorMappings",
json=[],
status=200)
responses.add(responses.POST, "http://modelservice/api/v2/detectors",
responses.add(responses.POST, "http://modelservice/api/v3/detectors",
body="4fdc3395-e969-449a-a306-201db183c6d7",
status=201)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
json=MOCK_DETECTORS[0],
status=200)
responses.add(
Expand All @@ -63,10 +63,10 @@ def test_cli_build_new_detectors(caplog):
status=200,
)
# error_count
responses.add(responses.POST, "http://modelservice/api/v2/detectors",
responses.add(responses.POST, "http://modelservice/api/v3/detectors",
body="47a0661d-aceb-4ef2-bf06-0828f28631b4",
status=201)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
json=MOCK_DETECTORS[1],
status=200)
responses.add(
Expand All @@ -76,10 +76,10 @@ def test_cli_build_new_detectors(caplog):
status=200,
)
# success_rate
responses.add(responses.POST, "http://modelservice/api/v2/detectors",
responses.add(responses.POST, "http://modelservice/api/v3/detectors",
body="16769303-a950-4d0f-a5a6-8d00eef886ec",
status=201)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=16769303-a950-4d0f-a5a6-8d00eef886ec",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=16769303-a950-4d0f-a5a6-8d00eef886ec",
json=MOCK_DETECTORS[2],
status=200)
responses.add(
Expand All @@ -89,10 +89,10 @@ def test_cli_build_new_detectors(caplog):
status=200,
)
# latency
responses.add(responses.POST, "http://modelservice/api/v2/detectors",
responses.add(responses.POST, "http://modelservice/api/v3/detectors",
body="5afc2bb3-4a5b-4a4b-8e30-890d67904588",
status=201)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=5afc2bb3-4a5b-4a4b-8e30-890d67904588",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=5afc2bb3-4a5b-4a4b-8e30-890d67904588",
json=MOCK_DETECTORS[3],
status=200)
responses.add(
Expand All @@ -117,10 +117,10 @@ def test_cli_disable_metric_detectors(caplog):
responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags",
json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE,
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
json=MOCK_DETECTORS[0],
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
json=MOCK_DETECTORS[1],
status=200)
responses.add(responses.POST, "http://modelservice/api/detectorMappings/search",
Expand All @@ -133,9 +133,9 @@ def test_cli_disable_metric_detectors(caplog):
status=200)
responses.add(responses.PUT, "http://modelservice/api/detectorMappings/disable?id=6XeANXABlK1-eG-Fo78V",
status=200)
responses.add(responses.POST, "http://modelservice/api/v2/detectors/toggleDetector?enabled=false&uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.POST, "http://modelservice/api/v3/detectors/toggleDetector?enabled=false&uuid=4fdc3395-e969-449a-a306-201db183c6d7",
status=200)
responses.add(responses.POST, "http://modelservice/api/v2/detectors/toggleDetector?enabled=false&uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
responses.add(responses.POST, "http://modelservice/api/v3/detectors/toggleDetector?enabled=false&uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
status=200)
metric_configs, exit_code = read_config_file("./tests/data/metric-config-request-count.json")
disable_exit_code = disable_detectors_for_metric_configs(metric_configs)
Expand All @@ -155,7 +155,7 @@ def test_cli_train_metric_detectors_sparse_data(caplog):
"lookupTimeInMillis": 2
},
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=5afc2bb3-4a5b-4a4b-8e30-890d67904588",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=5afc2bb3-4a5b-4a4b-8e30-890d67904588",
json=MOCK_DETECTORS[3],
status=200)
responses.add(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_constant_threshold_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ def test_train_detector_with_invalid_sample_size_raises_build_error(mock_metric)
responses.add(responses.POST, "http://modelservice/api/detectorMappings",
json=[],
status=200)
responses.add(responses.POST, "http://modelservice/api/v2/detectors",
responses.add(responses.POST, "http://modelservice/api/v3/detectors",
body="4fdc3395-e969-449a-a306-201db183c6d7",
status=201)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
json=MOCK_DETECTORS[0],
status=200)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_detector_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

@responses.activate
def test_detector_client_get_detector(mock_metric):
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
json=MOCK_DETECTORS[0],
status=200)
detector_client = DetectorClient()
Expand Down
22 changes: 11 additions & 11 deletions tests/test_metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ def test_detector_client_list_detectors_for_metric(mock_metric):
responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags",
json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE,
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
json=MOCK_DETECTORS[0],
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
json=MOCK_DETECTORS[1],
status=200)
detector_client = DetectorClient()
Expand All @@ -40,10 +40,10 @@ def test_build_metric_detectors(mock_metric):
responses.add(responses.POST, "http://modelservice/api/detectorMappings",
json=[],
status=200)
responses.add(responses.POST, "http://modelservice/api/v2/detectors",
responses.add(responses.POST, "http://modelservice/api/v3/detectors",
body="4fdc3395-e969-449a-a306-201db183c6d7",
status=201)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
json=MOCK_DETECTORS[0],
status=200)

Expand All @@ -66,10 +66,10 @@ def test_delete_metric_detectors(mock_metric):
responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags",
json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE,
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
json=MOCK_DETECTORS[0],
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
json=MOCK_DETECTORS[1],
status=200)
responses.add(responses.POST, "http://modelservice/api/detectorMappings/search",
Expand All @@ -82,9 +82,9 @@ def test_delete_metric_detectors(mock_metric):
status=200)
responses.add(responses.DELETE, "http://modelservice/api/detectorMappings?id=6XeANXABlK1-eG-Fo78V",
status=200)
responses.add(responses.DELETE, "http://modelservice/api/v2/detectors?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.DELETE, "http://modelservice/api/v3/detectors?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
status=200)
responses.add(responses.DELETE, "http://modelservice/api/v2/detectors?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
responses.add(responses.DELETE, "http://modelservice/api/v3/detectors?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
status=200)
test_metric = mock_metric(data=[5, 4, 7, 9, 15, 1, 0])
assert len(test_metric.detectors) == 2
Expand All @@ -102,10 +102,10 @@ def test_train_metric_detectors(mock_metric):
responses.add(responses.POST, "http://modelservice/api/detectorMappings/findMatchingByTags",
json=FIND_BY_MATCHING_TAGS_MOCK_RESPONSE,
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
json=MOCK_DETECTORS[0],
status=200)
responses.add(responses.GET, "http://modelservice/api/v2/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
responses.add(responses.GET, "http://modelservice/api/v3/detectors/findByUuid?uuid=47a0661d-aceb-4ef2-bf06-0828f28631b4",
json=MOCK_DETECTORS[1],
status=200)
def validate_update_request(request):
Expand All @@ -116,7 +116,7 @@ def validate_update_request(request):
assert isclose(thresholds["lowerWeak"], -9.48, rel_tol=0.01)
assert isclose(thresholds["lowerStrong"], -14.59, rel_tol=0.01)
return (200, {}, None)
responses.add_callback(responses.PUT, "http://modelservice/api/v2/detectors?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
responses.add_callback(responses.PUT, "http://modelservice/api/v3/detectors?uuid=4fdc3395-e969-449a-a306-201db183c6d7",
callback=validate_update_request)
test_metric = mock_metric(data=[5, 4, 7, 9, 15, 1, 0])
assert len(test_metric.detectors) == 2
Expand Down