ServerActionsSampleJsonTest refactor

Change the instance action sample to a real world action.

In Setup, we create an instance and then stop it. That would
be 2 actions(create and stop), and the stop action should have
a "compute_stop_instance" event. And then we do 2.1/2.21/2.51
test case based on these actions, like we have done in 2.58.

Change-Id: Iac23a574a05e62a99aab20ffce4265f4fb5a44d9
This commit is contained in:
Yikun Jiang 2018-04-17 15:29:43 +08:00
parent 7500462bc3
commit 577cb4b2f4
27 changed files with 236 additions and 368 deletions

View File

@ -1,27 +1,20 @@
{
"instanceAction": {
"action": "reboot",
"action": "stop",
"events": [
{
"event": "schedule",
"finish_time": "2012-12-05T01:02:00.000000",
"event": "compute_stop_instance",
"finish_time": "2018-04-25T01:26:29.585618",
"result": "Success",
"start_time": "2012-12-05T01:00:02.000000",
"traceback": ""
},
{
"event": "compute_create",
"finish_time": "2012-12-05T01:04:00.000000",
"result": "Success",
"start_time": "2012-12-05T01:03:00.000000",
"traceback": ""
"start_time": "2018-04-25T01:26:29.299627",
"traceback": null
}
],
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "147",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2012-12-05T00:00:00.000000",
"user_id": "789"
"instance_uuid": "e0a7ed34-899c-4b4d-8637-11ca627346ef",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-14122cb1-4256-4a16-a4f9-6faf494afaa7",
"start_time": "2018-04-25T01:26:29.074293",
"user_id": "admin"
}
}

View File

@ -1,22 +1,22 @@
{
"instanceActions": [
{
"action": "resize",
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "842",
"request_id": "req-25517360-b757-47d3-be45-0e8d2a01b36a",
"start_time": "2012-12-05T01:00:00.000000",
"user_id": "789"
"action": "stop",
"instance_uuid": "fcd19ef2-b593-40b1-90a5-fc31063fa95c",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-f8a59f03-76dc-412f-92c2-21f8612be728",
"start_time": "2018-04-25T01:26:29.092892",
"user_id": "admin"
},
{
"action": "reboot",
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "147",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2012-12-05T00:00:00.000000",
"user_id": "789"
"action": "create",
"instance_uuid": "fcd19ef2-b593-40b1-90a5-fc31063fa95c",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-50189019-626d-47fb-b944-b8342af09679",
"start_time": "2018-04-25T01:26:25.877278",
"user_id": "admin"
}
]
}

View File

@ -1,27 +1,20 @@
{
"instanceAction": {
"action": "reboot",
"action": "stop",
"events": [
{
"event": "schedule",
"finish_time": "2012-12-05T01:02:00.000000",
"event": "compute_stop_instance",
"finish_time": "2018-04-25T01:26:29.262877",
"result": "Success",
"start_time": "2012-12-05T01:00:02.000000",
"traceback": ""
},
{
"event": "compute_create",
"finish_time": "2012-12-05T01:04:00.000000",
"result": "Success",
"start_time": "2012-12-05T01:03:00.000000",
"traceback": ""
"start_time": "2018-04-25T01:26:29.012774",
"traceback": null
}
],
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "147",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2012-12-05T00:00:00.000000",
"user_id": "789"
"instance_uuid": "a53525ef-9ed5-4169-9f2e-dd141d575d87",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-343506f4-4dc3-4153-8de5-de6a60cb26ab",
"start_time": "2018-04-25T01:26:28.757301",
"user_id": "admin"
}
}

View File

@ -1,22 +1,22 @@
{
"instanceActions": [
{
"action": "resize",
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "842",
"request_id": "req-25517360-b757-47d3-be45-0e8d2a01b36a",
"start_time": "2012-12-05T01:00:00.000000",
"user_id": "789"
"action": "stop",
"instance_uuid": "07cacdbb-2e7f-4048-b69c-95cbdc47af6f",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-c022e6dc-d962-426e-b623-1cdbac0da64b",
"start_time": "2018-04-25T01:26:28.752049",
"user_id": "admin"
},
{
"action": "reboot",
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "147",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2012-12-05T00:00:00.000000",
"user_id": "789"
"action": "create",
"instance_uuid": "07cacdbb-2e7f-4048-b69c-95cbdc47af6f",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-862ef1ff-da4f-4b3b-9a29-6d621442c76c",
"start_time": "2018-04-25T01:26:25.595858",
"user_id": "admin"
}
]
}

View File

@ -1,25 +1,19 @@
{
"instanceAction": {
"action": "reboot",
"action": "stop",
"events": [
{
"event": "schedule",
"finish_time": "2012-12-05T01:02:00.000000",
"event": "compute_stop_instance",
"finish_time": "2018-04-25T01:26:29.565338",
"result": "Success",
"start_time": "2012-12-05T01:00:02.000000"
},
{
"event": "compute_create",
"finish_time": "2012-12-05T01:04:00.000000",
"result": "Success",
"start_time": "2012-12-05T01:03:00.000000"
"start_time": "2018-04-25T01:26:29.294207"
}
],
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "147",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2012-12-05T00:00:00.000000",
"user_id": "789"
"instance_uuid": "11a932ff-48b8-46ed-a409-7d9e50ec75d0",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-fad89d20-0311-44bd-a8c2-ee3f2411bcf0",
"start_time": "2018-04-25T01:26:29.073738",
"user_id": "fake"
}
}

View File

@ -1,27 +1,20 @@
{
"instanceAction": {
"action": "reboot",
"action": "stop",
"events": [
{
"event": "schedule",
"finish_time": "2012-12-05T01:02:00.000000",
"event": "compute_stop_instance",
"finish_time": "2018-04-25T01:26:30.798227",
"result": "Success",
"start_time": "2012-12-05T01:00:02.000000",
"traceback": ""
},
{
"event": "compute_create",
"finish_time": "2012-12-05T01:04:00.000000",
"result": "Success",
"start_time": "2012-12-05T01:03:00.000000",
"traceback": ""
"start_time": "2018-04-25T01:26:30.526590",
"traceback": null
}
],
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "147",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2012-12-05T00:00:00.000000",
"user_id": "789"
"instance_uuid": "07afdfe5-3791-48e3-9bda-1a0804796bab",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-f574c934-6f67-4945-b357-5a52a28a46a6",
"start_time": "2018-04-25T01:26:30.301030",
"user_id": "admin"
}
}

View File

@ -1,22 +1,22 @@
{
"instanceActions": [
{
"action": "resize",
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "842",
"request_id": "req-25517360-b757-47d3-be45-0e8d2a01b36a",
"start_time": "2012-12-05T01:00:00.000000",
"user_id": "789"
"action": "stop",
"instance_uuid": "a0dbc3b0-6f14-4fb7-8500-172e82584d05",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-ca4313e0-b514-46ea-a9b9-e49f8a1ad344",
"start_time": "2018-04-25T01:26:29.206664",
"user_id": "admin"
},
{
"action": "reboot",
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"project_id": "147",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2012-12-05T00:00:00.000000",
"user_id": "789"
"action": "create",
"instance_uuid": "a0dbc3b0-6f14-4fb7-8500-172e82584d05",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-a897e43f-8733-499d-a9cc-78993de2b8e8",
"start_time": "2018-04-25T01:26:25.910998",
"user_id": "admin"
}
]
}

View File

@ -4,17 +4,17 @@
"events": [
{
"event": "compute_stop_instance",
"finish_time": "2017-12-07T11:07:06.431902",
"finish_time": "2018-04-25T01:26:30.518082",
"result": "Success",
"start_time": "2017-12-07T11:07:06.251280"
"start_time": "2018-04-25T01:26:30.261571"
}
],
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"instance_uuid": "ee4c91a6-f214-486d-8e2a-efa29ad91ecd",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2017-12-07T11:07:06.088644",
"updated_at": "2017-12-07T11:07:06.431902",
"request_id": "req-ada57283-2dd7-4703-9781-d287aaa4eb95",
"start_time": "2018-04-25T01:26:30.041225",
"updated_at": "2018-04-25T01:26:30.518082",
"user_id": "fake"
}
}

View File

@ -4,18 +4,18 @@
"events": [
{
"event": "compute_stop_instance",
"finish_time": "2017-12-07T11:07:06.431902",
"finish_time": "2018-04-25T01:26:29.409773",
"result": "Success",
"start_time": "2017-12-07T11:07:06.251280",
"start_time": "2018-04-25T01:26:29.203170",
"traceback": null
}
],
"instance_uuid": "b48316c5-71e8-45e4-9884-6c78055b9b13",
"message": "",
"instance_uuid": "cab10fb8-6702-40ba-a91c-18009cec0a09",
"message": null,
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-3293a3f1-b44c-4609-b8d2-d81b105636b8",
"start_time": "2017-12-07T11:07:06.088644",
"updated_at": "2017-12-07T11:07:06.431902",
"user_id": "fake"
"request_id": "req-0514d54b-0f2c-4611-963d-fc24afb57f1f",
"start_time": "2018-04-25T01:26:28.996024",
"updated_at": "2018-04-25T01:26:29.409773",
"user_id": "admin"
}
}

View File

@ -1,24 +1,24 @@
{
"instanceActions": [
{
"instance_uuid": "e357e6d8-952e-4d1d-b74f-c8519e937706",
"user_id": "fake",
"start_time": "2017-12-07T11:07:06.088644",
"updated_at": "2017-12-07T11:07:06.431902",
"request_id": "req-e80018f1-c5bd-45ee-aaa9-290f2f5ef7bc",
"action": "stop",
"instance_uuid": "247cc793-7cf4-424a-a529-11bd62f960b6",
"message": null,
"project_id": "6f70656e737461636b20342065766572"
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-1448f44f-490d-42ff-8781-c3181d103a7c",
"start_time": "2018-04-25T01:26:28.793416",
"updated_at": "2018-04-25T01:26:29.292649",
"user_id": "fake"
},
{
"instance_uuid": "e357e6d8-952e-4d1d-b74f-c8519e937706",
"user_id": "fake",
"start_time": "2017-12-07T11:07:04.313653",
"updated_at": "2017-12-07T11:07:06.058351",
"request_id": "req-c8fd339d-d2bf-43c2-a98a-84328281f83e",
"action": "create",
"instance_uuid": "247cc793-7cf4-424a-a529-11bd62f960b6",
"message": null,
"project_id": "6f70656e737461636b20342065766572"
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-de0561a0-09d9-4902-b1fc-23ee95b14c67",
"start_time": "2018-04-25T01:26:25.527791",
"updated_at": "2018-04-25T01:26:28.749039",
"user_id": "fake"
}
]
}

View File

@ -1,19 +1,19 @@
{
"instanceActions": [
{
"instance_uuid": "e357e6d8-952e-4d1d-b74f-c8519e937706",
"user_id": "fake",
"start_time": "2017-12-07T11:07:06.088644",
"updated_at": "2017-12-07T11:07:06.431902",
"request_id": "req-e80018f1-c5bd-45ee-aaa9-290f2f5ef7bc",
"action": "stop",
"instance_uuid": "ca3d3be5-1a40-427f-9515-f5e181f479d0",
"message": null,
"project_id": "6f70656e737461636b20342065766572"
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-4dbefbb7-d743-4d42-b0a1-a79cbe256138",
"start_time": "2018-04-25T01:26:28.909887",
"updated_at": "2018-04-25T01:26:29.400606",
"user_id": "admin"
}
],
"links": [
{
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/servers/e357e6d8-952e-4d1d-b74f-c8519e937706/os-instance-actions?limit=1&marker=req-e80018f1-c5bd-45ee-aaa9-290f2f5ef7bc",
"href": "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/servers/ca3d3be5-1a40-427f-9515-f5e181f479d0/os-instance-actions?limit=1&marker=req-4dbefbb7-d743-4d42-b0a1-a79cbe256138",
"rel": "next"
}
]

View File

@ -1,14 +1,14 @@
{
"instanceActions": [
{
"instance_uuid": "e357e6d8-952e-4d1d-b74f-c8519e937706",
"user_id": "fake",
"start_time": "2017-12-07T11:07:04.313653",
"updated_at": "2017-12-07T11:07:06.058351",
"request_id": "req-c8fd339d-d2bf-43c2-a98a-84328281f83e",
"action": "create",
"instance_uuid": "31f35617-317d-4688-8046-bb600286e6b6",
"message": null,
"project_id": "6f70656e737461636b20342065766572"
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-922232c3-faf8-4628-9c40-0e8f0cdab020",
"start_time": "2018-04-25T01:26:33.694447",
"updated_at": "2018-04-25T01:26:35.944525",
"user_id": "fake"
}
]
}

View File

@ -1,14 +1,14 @@
{
"instanceActions": [
{
"instance_uuid": "e357e6d8-952e-4d1d-b74f-c8519e937706",
"user_id": "fake",
"start_time": "2017-12-07T11:07:06.088644",
"updated_at": "2017-12-07T11:07:06.431902",
"request_id": "req-e80018f1-c5bd-45ee-aaa9-290f2f5ef7bc",
"action": "stop",
"instance_uuid": "84fb2511-ed79-418c-ac0d-11337e1a1d76",
"message": null,
"project_id": "6f70656e737461636b20342065766572"
"project_id": "6f70656e737461636b20342065766572",
"request_id": "req-0176a4e5-15ae-4038-98a9-5444aa277c31",
"start_time": "2018-04-25T01:26:29.051607",
"updated_at": "2018-04-25T01:26:29.538648",
"user_id": "admin"
}
]
}

View File

@ -1,27 +1,20 @@
{
"instanceAction": {
"action": "%(action)s",
"instance_uuid": "%(instance_uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"start_time": "%(strtime)s",
"message": "",
"events": [
{
"event": "%(event)s",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "%(result)s",
"traceback": ""
},
{
"event": "%(event)s",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "%(result)s",
"traceback": ""
}
]
"action": "stop",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": null,
"events": [
{
"event": "compute_stop_instance",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "Success",
"traceback": null
}
]
}
}

View File

@ -1,22 +1,22 @@
{
"instanceActions": [
{
"action": "%(action)s",
"action": "stop",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": ""
"message": null
},
{
"action": "%(action)s",
"action": "create",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": ""
"message": null
}
]
}

View File

@ -1,26 +1,19 @@
{
"instanceAction": {
"action": "%(action)s",
"instance_uuid": "%(instance_uuid)s",
"action": "stop",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": "",
"message": null,
"events": [
{
"event": "%(event)s",
"event": "compute_stop_instance",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "%(result)s",
"traceback": ""
},
{
"event": "%(event)s",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "%(result)s",
"traceback": ""
"result": "Success",
"traceback": null
}
]
}

View File

@ -1,22 +1,22 @@
{
"instanceActions": [
{
"action": "%(action)s",
"action": "stop",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": ""
"message": null
},
{
"action": "%(action)s",
"action": "create",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": ""
"message": null
}
]
}

View File

@ -1,24 +1,18 @@
{
"instanceAction": {
"action": "%(action)s",
"instance_uuid": "%(instance_uuid)s",
"action": "stop",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": "",
"message": null,
"events": [
{
"event": "%(event)s",
"event": "compute_stop_instance",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "%(result)s"
},
{
"event": "%(event)s",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "%(result)s"
"result": "Success"
}
]
}

View File

@ -1,26 +1,19 @@
{
"instanceAction": {
"action": "%(action)s",
"instance_uuid": "%(instance_uuid)s",
"action": "stop",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": "",
"message": null,
"events": [
{
"event": "%(event)s",
"event": "compute_stop_instance",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "%(result)s",
"traceback": ""
},
{
"event": "%(event)s",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "%(result)s",
"traceback": ""
"result": "Success",
"traceback": null
}
]
}

View File

@ -1,22 +1,22 @@
{
"instanceActions": [
{
"action": "%(action)s",
"action": "stop",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": ""
"message": null
},
{
"action": "%(action)s",
"action": "create",
"instance_uuid": "%(uuid)s",
"request_id": "%(request_id)s",
"user_id": "%(integer_id)s",
"project_id": "%(integer_id)s",
"user_id": "%(user_id)s",
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"message": ""
"message": null
}
]
}

View File

@ -7,7 +7,7 @@
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"updated_at": "%(strtime)s",
"message": "",
"message": null,
"events": [
{
"event": "compute_stop_instance",

View File

@ -7,14 +7,14 @@
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"updated_at": "%(strtime)s",
"message": "",
"message": null,
"events": [
{
"event": "compute_stop_instance",
"start_time": "%(strtime)s",
"finish_time": "%(strtime)s",
"result": "Success",
"traceback": ""
"traceback": null
}
]
}

View File

@ -8,7 +8,7 @@
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"updated_at": "%(strtime)s",
"message": ""
"message": null
},
{
"action": "create",
@ -18,7 +18,7 @@
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"updated_at": "%(strtime)s",
"message": ""
"message": null
}
]
}

View File

@ -8,7 +8,7 @@
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"updated_at": "%(strtime)s",
"message": ""
"message": null
}
],
"links": [

View File

@ -8,7 +8,7 @@
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"updated_at": "%(strtime)s",
"message": ""
"message": null
}
]
}

View File

@ -8,7 +8,7 @@
"project_id": "%(project_id)s",
"start_time": "%(strtime)s",
"updated_at": "%(strtime)s",
"message": ""
"message": null
}
]
}

View File

@ -13,90 +13,50 @@
# License for the specific language governing permissions and limitations
# under the License.
import copy
import six
from nova.tests.functional.api_sample_tests import api_sample_base
from nova.tests.functional.api_sample_tests import test_servers
from nova.tests.functional import api_samples_test_base
from nova.tests.functional import integrated_helpers
from nova.tests.unit import fake_instance
from nova.tests.unit import fake_server_actions
from nova.tests.unit import utils as test_utils
class ServerActionsSampleJsonTest(api_sample_base.ApiSampleTestBaseV21):
class ServerActionsSampleJsonTest(test_servers.ServersSampleBase,
integrated_helpers.InstanceHelperMixin):
microversion = None
ADMIN_API = True
sample_dir = 'os-instance-actions'
def setUp(self):
super(ServerActionsSampleJsonTest, self).setUp()
self.api.microversion = self.microversion
self.actions = fake_server_actions.FAKE_ACTIONS
self.events = fake_server_actions.FAKE_EVENTS
self.instance = test_utils.get_test_instance(obj=True)
# Create and stop a server
self.uuid = self._post_server()
self._get_response('servers/%s/action' % self.uuid, 'POST',
'{"os-stop": null}')
response = self._do_get('servers/%s/os-instance-actions' % self.uuid)
response_data = api_samples_test_base.pretty_data(response.content)
actions = api_samples_test_base.objectify(response_data)
self.action_stop = actions['instanceActions'][0]
self._wait_for_state_change(self.api, {'id': self.uuid}, 'SHUTOFF')
def _fake_get(stub_self, context, instance_uuid, expected_attrs=None):
return fake_instance.fake_instance_obj(
None, **{'uuid': instance_uuid})
def fake_instance_action_get_by_request_id(context, uuid, request_id):
return copy.deepcopy(self.actions[uuid][request_id])
def fake_server_actions_get(context, uuid, limit=None, marker=None,
filters=None):
return [copy.deepcopy(value) for value in
six.itervalues(self.actions[uuid])]
def fake_instance_action_events_get(context, action_id):
return copy.deepcopy(self.events[action_id])
def fake_instance_get_by_uuid(context, instance_id):
return self.instance
self.stub_out('nova.db.action_get_by_request_id',
fake_instance_action_get_by_request_id)
self.stub_out('nova.db.actions_get', fake_server_actions_get)
self.stub_out('nova.db.action_events_get',
fake_instance_action_events_get)
self.stub_out('nova.db.instance_get_by_uuid',
fake_instance_get_by_uuid)
self.stub_out('nova.compute.api.API.get', _fake_get)
def _get_subs(self):
return {
'uuid': self.uuid,
'project_id': self.action_stop['project_id']
}
def test_instance_action_get(self):
fake_uuid = fake_server_actions.FAKE_UUID
fake_request_id = fake_server_actions.FAKE_REQUEST_ID1
fake_action = self.actions[fake_uuid][fake_request_id]
req_id = self.action_stop['request_id']
response = self._do_get('servers/%s/os-instance-actions/%s' %
(fake_uuid, fake_request_id))
subs = {}
subs['action'] = '(reboot)|(resize)'
subs['instance_uuid'] = str(fake_uuid)
subs['integer_id'] = '[0-9]+'
subs['request_id'] = str(fake_action['request_id'])
subs['start_time'] = str(fake_action['start_time'])
subs['result'] = '(Success)|(Error)'
subs['event'] = '(schedule)|(compute_create)'
(self.uuid, req_id))
# Non-admins can see event details except for the "traceback" field
# starting in the 2.51 microversion.
if self.ADMIN_API:
name = 'instance-action-get-resp'
else:
name = 'instance-action-get-non-admin-resp'
self._verify_response(name, subs, response, 200)
self._verify_response(name, self._get_subs(), response, 200)
def test_instance_actions_list(self):
fake_uuid = fake_server_actions.FAKE_UUID
response = self._do_get('servers/%s/os-instance-actions' % (fake_uuid))
subs = {}
subs['action'] = '(reboot)|(resize)'
subs['integer_id'] = '[0-9]+'
subs['request_id'] = ('req-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}'
'-[0-9a-f]{4}-[0-9a-f]{12}')
self._verify_response('instance-actions-list-resp', subs,
response = self._do_get('servers/%s/os-instance-actions' % self.uuid)
self._verify_response('instance-actions-list-resp', self._get_subs(),
response, 200)
@ -132,47 +92,9 @@ class ServerActionsV251NonAdminSampleJsonTest(ServerActionsSampleJsonTest):
scenarios = [('v2_51', {'api_major_version': 'v2.1'})]
class ServerActionsV258SampleJsonTest(test_servers.ServersSampleBase,
integrated_helpers.InstanceHelperMixin):
class ServerActionsV258SampleJsonTest(ServerActionsV251AdminSampleJsonTest):
microversion = '2.58'
scenarios = [('v2_58', {'api_major_version': 'v2.1'})]
sample_dir = 'os-instance-actions'
ADMIN_API = True
def setUp(self):
super(ServerActionsV258SampleJsonTest, self).setUp()
# Create and stop a server
self.uuid = self._post_server()
self._get_response('servers/%s/action' % self.uuid, 'POST',
'{"os-stop": null}')
response = self._do_get('servers/%s/os-instance-actions' % self.uuid)
response_data = api_samples_test_base.pretty_data(response.content)
actions = api_samples_test_base.objectify(response_data)
self.action_stop = actions['instanceActions'][0]
self._wait_for_state_change(self.api, {'id': self.uuid}, 'SHUTOFF')
def _get_subs(self):
return {
'uuid': self.uuid,
'project_id': self.action_stop['project_id']
}
def test_instance_action_get(self):
req_id = self.action_stop['request_id']
response = self._do_get('servers/%s/os-instance-actions/%s' %
(self.uuid, req_id))
# Non-admins can see event details except for the "traceback" field
# starting in the 2.51 microversion.
if self.ADMIN_API:
name = 'instance-action-get-resp'
else:
name = 'instance-action-get-non-admin-resp'
self._verify_response(name, self._get_subs(), response, 200)
def test_instance_actions_list(self):
response = self._do_get('servers/%s/os-instance-actions' % self.uuid)
self._verify_response('instance-actions-list-resp', self._get_subs(),
response, 200)
def test_instance_actions_list_with_limit(self):
response = self._do_get('servers/%s/os-instance-actions'