diff --git a/plugin/src/test/resources/rest-api-spec/test/ml/delete_model_snapshot.yaml b/plugin/src/test/resources/rest-api-spec/test/ml/delete_model_snapshot.yaml index f946e783f70..78f1a71d78c 100644 --- a/plugin/src/test/resources/rest-api-spec/test/ml/delete_model_snapshot.yaml +++ b/plugin/src/test/resources/rest-api-spec/test/ml/delete_model_snapshot.yaml @@ -29,12 +29,12 @@ setup: index: index: .ml-anomalies-foo type: model_snapshot - id: "foo1" + id: "foo-inactive-snapshot" body: > { "job_id": "foo", "timestamp": "2016-06-02T00:00:00Z", - "snapshot_id": "foo1", + "snapshot_id": "inactive-snapshot", "description": "first", "latest_record_time_stamp": "2016-06-02T00:00:00Z", "latest_result_time_stamp": "2016-06-02T00:00:00Z", @@ -45,32 +45,32 @@ setup: index: index: .ml-state type: model_state - id: "foo1_0" + id: "foo-inactive-snapshot_1" body: > { - "state": "foo" + "state": "a" } - do: index: index: .ml-state type: model_state - id: "foo1_1" + id: "foo-inactive-snapshot_2" body: > { - "state": "foo" + "state": "b" } - do: index: index: .ml-anomalies-foo type: model_snapshot - id: "foo2" + id: "foo-active-snapshot" body: > { "job_id": "foo", "timestamp": "2016-06-01T00:00:00Z", - "snapshot_id": "foo2", + "snapshot_id": "active-snapshot", "description": "second", "latest_record_time_stamp": "2016-06-01T00:00:00Z", "latest_result_time_stamp": "2016-06-01T00:00:00Z" @@ -84,6 +84,14 @@ setup: indices.refresh: index: .ml-anomalies-foo + - do: + xpack.ml.update_job: + job_id: foo + body: > + { + "model_snapshot_id": "active-snapshot" + } + --- "Test delete snapshot missing snapshotId": - do: @@ -96,7 +104,7 @@ setup: - do: catch: param xpack.ml.delete_model_snapshot: - snapshot_id: "foo" + snapshot_id: "inactive-snapshot" --- "Test valid delete snapshot": @@ -115,7 +123,7 @@ setup: - do: xpack.ml.delete_model_snapshot: job_id: "foo" - snapshot_id: "foo1" + snapshot_id: "inactive-snapshot" - match: { acknowledged: true } - do: @@ -130,7 +138,7 @@ setup: xpack.ml.get_model_snapshots: job_id: "foo" - match: { count: 1 } - - match: { model_snapshots.0.snapshot_id: "foo2"} + - match: { model_snapshots.0.snapshot_id: "active-snapshot"} - do: count: @@ -141,13 +149,9 @@ setup: --- "Test delete with in-use model": - - do: - xpack.ml.revert_model_snapshot: - job_id: "foo" - snapshot_id: "foo2" - do: catch: request xpack.ml.delete_model_snapshot: job_id: "foo" - snapshot_id: "foo2" + snapshot_id: "active-snapshot" diff --git a/plugin/src/test/resources/rest-api-spec/test/ml/get_model_snapshots.yaml b/plugin/src/test/resources/rest-api-spec/test/ml/get_model_snapshots.yaml index 83714f0d2d8..b84d13c2a91 100644 --- a/plugin/src/test/resources/rest-api-spec/test/ml/get_model_snapshots.yaml +++ b/plugin/src/test/resources/rest-api-spec/test/ml/get_model_snapshots.yaml @@ -34,7 +34,8 @@ setup: job_id: "foo" - match: { count: 2 } - - match: { model_snapshots.0.timestamp: 1464739200000 } + - match: { model_snapshots.0.timestamp: 1464825600000 } + - match: { model_snapshots.1.timestamp: 1464739200000 } --- "Test get model snapshots API with _all": @@ -44,7 +45,8 @@ setup: snapshot_id: "_all" - match: { count: 2 } - - match: { model_snapshots.0.timestamp: 1464739200000 } + - match: { model_snapshots.0.timestamp: 1464825600000 } + - match: { model_snapshots.1.timestamp: 1464739200000 } --- "Test get specific model snapshot": @@ -65,7 +67,8 @@ setup: end: "2016-07-01T00:00:00Z" - match: { count: 2 } - - match: { model_snapshots.0.timestamp: 1464739200000 } + - match: { model_snapshots.0.timestamp: 1464825600000 } + - match: { model_snapshots.1.timestamp: 1464739200000 } --- "Test get model snapshots API with ascending": @@ -75,7 +78,8 @@ setup: desc: false - match: { count: 2 } - - match: { model_snapshots.0.timestamp: 1464825600000 } + - match: { model_snapshots.0.timestamp: 1464739200000 } + - match: { model_snapshots.1.timestamp: 1464825600000 } --- "Test get model snapshots API with size": @@ -85,7 +89,7 @@ setup: size: 1 - match: { count: 2 } - - match: { model_snapshots.0.timestamp: 1464739200000 } + - match: { model_snapshots.0.timestamp: 1464825600000 } - length: { model_snapshots: 1 } --- @@ -96,5 +100,5 @@ setup: from: 1 - match: { count: 2 } - - match: { model_snapshots.0.timestamp: 1464825600000 } + - match: { model_snapshots.0.timestamp: 1464739200000 } - length: { model_snapshots: 1 } diff --git a/plugin/src/test/resources/rest-api-spec/test/ml/revert_model_snapshot.yaml b/plugin/src/test/resources/rest-api-spec/test/ml/revert_model_snapshot.yaml index 4e98fd67620..52d652d723e 100644 --- a/plugin/src/test/resources/rest-api-spec/test/ml/revert_model_snapshot.yaml +++ b/plugin/src/test/resources/rest-api-spec/test/ml/revert_model_snapshot.yaml @@ -29,13 +29,13 @@ setup: index: index: .ml-anomalies-foo type: model_snapshot - id: "1" + id: "foo-first" body: > { "job_id": "foo", "timestamp": "2016-06-02T00:00:00Z", - "snapshot_id": "foo1", - "description": "first", + "snapshot_id": "first", + "description": "first snapshot", "latest_record_time_stamp": "2016-06-02T00:00:00Z", "latest_result_time_stamp": "2016-06-02T00:00:00Z" } @@ -44,13 +44,13 @@ setup: index: index: .ml-anomalies-foo type: model_snapshot - id: "2" + id: "foo-second" body: > { "job_id": "foo", "timestamp": "2016-06-01T00:00:00Z", - "snapshot_id": "foo2", - "description": "second", + "snapshot_id": "second", + "description": "second snapshot", "latest_record_time_stamp": "2016-06-01T00:00:00Z", "latest_result_time_stamp": "2016-06-01T00:00:00Z" } @@ -144,23 +144,23 @@ setup: - do: xpack.ml.revert_model_snapshot: job_id: "foo" - snapshot_id: "foo1" + snapshot_id: "first" - match: { acknowledged: true } - match: { model.job_id: "foo" } - match: { model.timestamp: 1464825600000 } - - match: { model.snapshot_id: "foo1" } + - match: { model.snapshot_id: "first" } - match: { model.snapshot_doc_count: 0 } - do: xpack.ml.revert_model_snapshot: job_id: "foo" - snapshot_id: "foo2" + snapshot_id: "second" - match: { acknowledged: true } - match: { model.job_id: "foo" } - match: { model.timestamp: 1464739200000 } - - match: { model.snapshot_id: "foo2" } + - match: { model.snapshot_id: "second" } - match: { model.snapshot_doc_count: 0 } --- @@ -176,7 +176,7 @@ setup: - do: xpack.ml.revert_model_snapshot: job_id: "foo" - snapshot_id: "foo2" + snapshot_id: "second" delete_intervening_results: true - do: