summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLingxian Kong <anlin.kong@gmail.com>2020-12-02 14:36:39 +1300
committerLingxian Kong <anlin.kong@gmail.com>2020-12-09 14:17:16 +1300
commitca04c94ef66ed16169e949e680fb3b31025cb61a (patch)
tree43d04462568204c242e8989ba1bbdd054d55e886
parent9ea87ccf4334e893565c2fa1ee8e587f56e592a1 (diff)
downloadtrove-ca04c94ef66ed16169e949e680fb3b31025cb61a.tar.gz
Support instance operating_status
Added a new field ``operating_status`` for the instance to show the actual operational status of user's database. Change-Id: I7c52cff0ec48289fe1a260e99e02a506d4f8ddec
-rw-r--r--api-ref/source/instances.inc2
-rwxr-xr-xapi-ref/source/parameters.yaml6
-rw-r--r--api-ref/source/samples/instance-create-response.json33
-rw-r--r--api-ref/source/samples/instance-list-detail-response.json4
-rw-r--r--api-ref/source/samples/instance-list-response.json1
-rw-r--r--api-ref/source/samples/instance-mgmt-list-response.json4
-rw-r--r--api-ref/source/samples/instance-mgmt-show-response.json3
-rw-r--r--api-ref/source/samples/instance-show-response.json3
-rw-r--r--doc/source/user/create-db.rst164
-rw-r--r--doc/source/user/instance-status.rst50
-rw-r--r--doc/source/user/set-up-replication.rst40
-rw-r--r--doc/source/user/upgrade-datastore.rst42
-rw-r--r--releasenotes/notes/wallaby-operating-status.yaml9
-rw-r--r--trove/instance/models.py69
-rw-r--r--trove/instance/views.py1
-rw-r--r--trove/tests/api/instances.py15
-rw-r--r--trove/tests/api/instances_actions.py13
-rw-r--r--trove/tests/scenario/runners/test_runners.py29
-rw-r--r--trove/tests/unittests/instance/test_instance_status.py106
19 files changed, 319 insertions, 275 deletions
diff --git a/api-ref/source/instances.inc b/api-ref/source/instances.inc
index 0cc834ec..db8b872e 100644
--- a/api-ref/source/instances.inc
+++ b/api-ref/source/instances.inc
@@ -160,6 +160,7 @@ Response Parameters
- id: instanceId1
- name: instanceName1
- status: instance_status
+ - operating_status: operating_status
- links: instance_links
- links.href: instance_link_href
- links.rel: instance_link_rel
@@ -226,6 +227,7 @@ Response Parameters
- id: instanceId1
- name: instanceName1
- status: instance_status
+ - operating_status: operating_status
- links: instance_links
- links.href: instance_link_href
- links.rel: instance_link_rel
diff --git a/api-ref/source/parameters.yaml b/api-ref/source/parameters.yaml
index 20a0123b..6918f2e4 100755
--- a/api-ref/source/parameters.yaml
+++ b/api-ref/source/parameters.yaml
@@ -717,6 +717,12 @@ nics:
in: body
required: false
type: array
+operating_status:
+ description: |
+ The operating status of the database service inside the Trove instance.
+ in: body
+ required: true
+ type: string
project_uuid:
description: |
The project ID of the resource.
diff --git a/api-ref/source/samples/instance-create-response.json b/api-ref/source/samples/instance-create-response.json
index 14edc0aa..1fd74ac1 100644
--- a/api-ref/source/samples/instance-create-response.json
+++ b/api-ref/source/samples/instance-create-response.json
@@ -1,14 +1,27 @@
{
"instance": {
- "created": "2019-12-23T20:53:38",
+ "id": "b76a6a76-748b-4064-adec-4c9e6c9abd68",
+ "name": "test",
+ "status": "BUILD",
+ "operating_status": "",
"datastore": {
"type": "mysql",
- "version": "5.7"
+ "version": "5.7.29",
+ "version_number": "5.7.29"
},
"flavor": {
- "id": "6"
+ "id": "3ca76fe7-8dc1-4059-b728-de725835abcb",
+ "links": [
+ {
+ "href": "https://192.168.206.8:87 79/v1.0/c37341d7d1934ebc949c9d6b5c9f818c/flavors/3ca76fe7-8dc1-4059-b728-de725835abcb",
+ "rel": "self"
+ },
+ {
+ "href": "https://192.168.206.8:8779/flavors/3ca76fe7-8dc1-4059-b728-de725835abcb",
+ "rel": "bookmark"
+ }
+ ]
},
- "id": "b76a6a76-748b-4064-adec-4c9e6c9abd68",
"links": [
{
"href": "https://127.0.0.1:8779/v1.0/9f8dd5eacb074c9f87d2d822c9092aa5/instances/b76a6a76-748b-4064-adec-4c9e6c9abd68",
@@ -19,13 +32,15 @@
"rel": "bookmark"
}
],
- "name": "test",
"region": "RegionOne",
- "service_status_updated": "2019-12-23T20:53:38",
- "status": "BUILD",
- "updated": "2019-12-23T20:53:38",
+ "access": {
+ "is_public": false
+ },
"volume": {
"size": 1
- }
+ },
+ "created": "2019-12-23T20:53:38",
+ "updated": "2019-12-23T20:53:38",
+ "service_status_updated": "2019-12-23T20:53:38"
}
} \ No newline at end of file
diff --git a/api-ref/source/samples/instance-list-detail-response.json b/api-ref/source/samples/instance-list-detail-response.json
index f253c099..b938de88 100644
--- a/api-ref/source/samples/instance-list-detail-response.json
+++ b/api-ref/source/samples/instance-list-detail-response.json
@@ -35,9 +35,10 @@
}
],
"name": "test",
+ "operating_status": "HEALTHY",
"region": "RegionOne",
"service_status_updated": "2019-12-23T21:01:11",
- "status": "HEALTHY",
+ "status": "ACTIVE",
"updated": "2019-12-23T20:58:45",
"volume": {
"size": 1
@@ -69,6 +70,7 @@
}
],
"name": "test",
+ "operating_status": "",
"region": "RegionOne",
"service_status_updated": "2019-12-23T20:53:38",
"status": "ERROR",
diff --git a/api-ref/source/samples/instance-list-response.json b/api-ref/source/samples/instance-list-response.json
index df995aa1..32d3200f 100644
--- a/api-ref/source/samples/instance-list-response.json
+++ b/api-ref/source/samples/instance-list-response.json
@@ -24,6 +24,7 @@
}
],
"name": "test",
+ "operating_status": "HEALTHY",
"region": "RegionOne",
"status": "ACTIVE",
"volume": {
diff --git a/api-ref/source/samples/instance-mgmt-list-response.json b/api-ref/source/samples/instance-mgmt-list-response.json
index 17ec62c2..071e610c 100644
--- a/api-ref/source/samples/instance-mgmt-list-response.json
+++ b/api-ref/source/samples/instance-mgmt-list-response.json
@@ -37,6 +37,7 @@
}
],
"name": "test",
+ "operating_status": "HEALTHY",
"region": "RegionOne",
"server": {
"host": "bdfe3275004d2a98d38d494fd7adfcd0c6d5d5198e86fa0d6ec5d588",
@@ -48,7 +49,7 @@
"server_id": "710a84e5-6adf-4a4c-9167-8bade67a5a1c",
"service_status": "HEALTHY",
"service_status_updated": "2019-12-24T00:02:55",
- "status": "HEALTHY",
+ "status": "ACTIVE",
"task_description": "No tasks for the instance.",
"tenant_id": "9f8dd5eacb074c9f87d2d822c9092aa5",
"updated": "2019-12-23T23:53:46",
@@ -86,6 +87,7 @@
}
],
"name": "test",
+ "operating_status": "",
"region": "RegionOne",
"server": null,
"server_id": null,
diff --git a/api-ref/source/samples/instance-mgmt-show-response.json b/api-ref/source/samples/instance-mgmt-show-response.json
index 9ca5bd9c..23ce592c 100644
--- a/api-ref/source/samples/instance-mgmt-show-response.json
+++ b/api-ref/source/samples/instance-mgmt-show-response.json
@@ -40,6 +40,7 @@
}
],
"name": "test",
+ "operating_status": "HEALTHY",
"region": "RegionOne",
"server": {
"addresses": {
@@ -75,7 +76,7 @@
"server_id": "710a84e5-6adf-4a4c-9167-8bade67a5a1c",
"service_status": "HEALTHY",
"service_status_updated": "2019-12-24T00:08:55",
- "status": "HEALTHY",
+ "status": "ACTIVE",
"task_description": "No tasks for the instance.",
"tenant_id": "9f8dd5eacb074c9f87d2d822c9092aa5",
"updated": "2019-12-23T23:53:46",
diff --git a/api-ref/source/samples/instance-show-response.json b/api-ref/source/samples/instance-show-response.json
index 7b609682..49579242 100644
--- a/api-ref/source/samples/instance-show-response.json
+++ b/api-ref/source/samples/instance-show-response.json
@@ -34,9 +34,10 @@
}
],
"name": "test",
+ "operating_status": "HEALTHY",
"region": "RegionOne",
"service_status_updated": "2019-12-23T22:15:11",
- "status": "HEALTHY",
+ "status": "ACTIVE",
"updated": "2019-12-23T20:58:45",
"volume": {
"size": 1,
diff --git a/doc/source/user/create-db.rst b/doc/source/user/create-db.rst
index 8be08079..a8a111e1 100644
--- a/doc/source/user/create-db.rst
+++ b/doc/source/user/create-db.rst
@@ -7,82 +7,32 @@ Assume that you have installed the Database service and populated your
data store with images for the type and versions of databases that you
want, and that you can create and access a database instance.
-This example shows you how to create and access a MySQL 5.7 database.
+This example shows you how to create and access a MySQL 5.7.29 database.
Create and access a database instance
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-#. **Determine which flavor to use for your database**
+#. **Before creating the instance**
- When you create a database instance, you must specify a nova flavor.
- The flavor indicates various characteristics of the instance, such as
- RAM and root volume size. You will need to create or
- obtain new nova flavors that work for databases.
+ * Choose the flavor. A flavor defines RAM and root volume size for the instance. Trove OpenStack CLI provides a command to get a flavor list that are supported to create trove instance.
- The first step is to list flavors by using the
- :command:`openstack flavor list` command.
+ .. code-block:: console
- .. code-block:: console
-
- $ openstack flavor list
-
- Now take a look at the minimum requirements for various database
- instances:
-
- +--------------------+--------------------+--------------------+--------------------+
- | Database | RAM (MB) | Disk (GB) | VCPUs |
- +====================+====================+====================+====================+
- | MySQL | 512 | 5 | 1 |
- +--------------------+--------------------+--------------------+--------------------+
- | Cassandra | 2048 | 5 | 1 |
- +--------------------+--------------------+--------------------+--------------------+
- | MongoDB | 1024 | 5 | 1 |
- +--------------------+--------------------+--------------------+--------------------+
- | Redis | 512 | 5 | 1 |
- +--------------------+--------------------+--------------------+--------------------+
-
- - If you have a custom flavor that meets the needs of the database
- that you want to create, proceed to
- :ref:`Step 2 <create-database-instance>` and use that flavor.
+ $ openstack database flavor list
- - If your environment does not have a suitable flavor, an
- administrative user must create a custom flavor by using the
- :command:`openstack flavor create` command.
+ .. note::
- **MySQL example.** This example creates a flavor that you can use
- with a MySQL database. This example has the following attributes:
+ If creating instance as a replica for the replication cluster, flavor is not needed as it's the same with the replication primary.
- - Flavor name: ``mysql_minimum``
+ * Choose a neutron network that the instance is allocated IP address from. You can either specify the network ID or the subnet ID, you can even specify the IP address (must be available).
+ * Choose the volume size. The cinder volume is used as data storage for the database.
+ * Choose datastore version.
- - Flavor ID: You must use an ID that is not already in use. In this
- example, IDs 1 through 5 are in use, so use ID ``6``.
+ .. note::
- - RAM: ``512``
-
- - Root volume size in GB: ``5``
-
- - Virtual CPUs: ``1``
-
- .. code-block:: console
+ If creating instance as a replica for the replication cluster, datastore is not needed as it's the same with the replication primary.
- $ openstack flavor create mysql-minimum --id 6 --ram 512 --disk 5 --vcpus 1
- +----------------------------+---------------+
- | Field | Value |
- +----------------------------+---------------+
- | OS-FLV-DISABLED:disabled | False |
- | OS-FLV-EXT-DATA:ephemeral | 0 |
- | disk | 5 |
- | id | 6 |
- | name | mysql-minimum |
- | os-flavor-access:is_public | True |
- | properties | |
- | ram | 512 |
- | rxtx_factor | 1.0 |
- | swap | |
- | vcpus | 1 |
- +----------------------------+---------------+
-
- .. _create-database-instance:
+ * (Optional) Choose the data source. You can create a new instance by restoring a backup using ``--backup <BACKUP_ID>``, or create a replica instance for a replication cluster using ``--replica-of <PRIMARY_INSTANCE_ID>``
#. **Create a database instance**
@@ -90,19 +40,18 @@ Create and access a database instance
parameters:
- Name of the instance: ``mysql_instance_1``
- - Database flavor: ``6``
+ - Database flavor: ``1fb05bb0-4605-48b6-81e6-3d4622e4a330``
- A volume size of ``5`` (5 GB)
- A database named ``test``
- The database is based on the ``mysql`` data store and the
- ``5.7`` datastore version
+ ``5.7.29`` datastore version
- The ``userA`` user with the ``password`` password.
- A Neutron network ``8799cf10-01ef-40e2-b04e-06da7cfa5668`` to allocate
the database IP address (for internal access).
- Expose the instance to the public via ``--is-public`` (for external
- access). Ignore this parameter if you don't want to expose database
- service to the public internet.
+ access).
- Only the IP addresses coming from ``202.37.199.1/24`` or ``10.1.0.1/24``
- are allowed to access the database service.
+ are allowed to access the database.
.. code-block:: console
@@ -111,54 +60,65 @@ Create and access a database instance
--size 5 \
--nic net-id=8799cf10-01ef-40e2-b04e-06da7cfa5668 \
--databases test --users userA:password \
- --datastore mysql --datastore-version 5.7 \
+ --datastore mysql --datastore-version 5.7.29 \
--is-public \
--allowed-cidr 10.1.0.1/24 \
--allowed-cidr 202.37.199.1/24
- +-------------------+--------------------------------------+
- | Field | Value |
- +-------------------+--------------------------------------+
- | created | 2019-09-11T09:19:18 |
- | datastore | mysql |
- | datastore_version | 5.7 |
- | flavor | 6 |
- | id | 4bca2f27-f986-419e-ab4a-df1db399d590 |
- | name | mysql_instance_1 |
- | region | RegionOne |
- | status | BUILD |
- | updated | 2019-09-11T09:19:18 |
- | volume | 5 |
- +-------------------+--------------------------------------+
+ +--------------------------+--------------------------------------+
+ | Field | Value |
+ +--------------------------+--------------------------------------+
+ | allowed_cidrs | [10.1.0.1/24, 202.37.199.1/24] |
+ | created | 2020-12-08T21:00:19 |
+ | datastore | mysql |
+ | datastore_version | 5.7.29 |
+ | datastore_version_number | 5.7.29 |
+ | flavor | 1fb05bb0-4605-48b6-81e6-3d4622e4a330 |
+ | id | ad40cf6c-6532-4a22-a3f3-7364f0f04a0f |
+ | name | mysql_instance_1 |
+ | operating_status | |
+ | public | True |
+ | region | RegionOne |
+ | service_status_updated | 2020-12-08T21:00:19 |
+ | status | BUILD |
+ | updated | 2020-12-08T21:00:19 |
+ | volume | 5 |
+ +--------------------------+--------------------------------------+
#. **Get the IP address of the database instance**
- Both internal and external IP addresses can be shown by running:
+ Wait until the instance ``operating_status`` changes to HEALTHY before getting IP address to access the database:
.. code-block:: console
- $ openstack database instance show 4bca2f27-f986-419e-ab4a-df1db399d590
- +-------------------+--------------------------------------+
- | Field | Value |
- +-------------------+--------------------------------------+
- | created | 2019-09-11T07:14:37 |
- | datastore | mysql |
- | datastore_version | 5.7 |
- | flavor | 6 |
- | id | 4bca2f27-f986-419e-ab4a-df1db399d590 |
- | ip | 10.1.0.14, 172.24.5.15 |
- | name | mysql_instance_1 |
- | region | RegionOne |
- | status | ACTIVE |
- | updated | 2019-09-11T07:14:47 |
- | volume | 5 |
- | volume_used | 0.12 |
- +-------------------+--------------------------------------+
+ $ openstack database instance show ad40cf6c-6532-4a22-a3f3-7364f0f04a0f
+ +--------------------------+----------------------------------------------------------------------------------------------+
+ | Field | Value |
+ +--------------------------+----------------------------------------------------------------------------------------------+
+ | addresses | [{'address': '10.0.0.59', 'type': 'private'}, {'address': '172.24.4.242', 'type': 'public'}] |
+ | allowed_cidrs | [] |
+ | created | 2020-12-08T21:00:20 |
+ | datastore | mysql |
+ | datastore_version | 5.7.29 |
+ | datastore_version_number | 5.7.29 |
+ | flavor | 1fb05bb0-4605-48b6-81e6-3d4622e4a330 |
+ | id | ad40cf6c-6532-4a22-a3f3-7364f0f04a0f |
+ | ip | 10.0.0.59, 172.24.4.242 |
+ | name | mysql_instance_1 |
+ | operating_status | HEALTHY |
+ | public | True |
+ | region | RegionOne |
+ | service_status_updated | 2020-12-08T21:05:51 |
+ | status | ACTIVE |
+ | updated | 2020-12-08T21:04:39 |
+ | volume | 5 |
+ | volume_used | 0.2 |
+ +--------------------------+----------------------------------------------------------------------------------------------+
#. **Access the new database**
You can now access the new database you just created by using
typical database access commands. In this MySQL example, replace
- ``IP_ADDRESS`` with either 10.1.0.14 or 172.24.5.15 according to where the
+ ``IP_ADDRESS`` with either 10.0.0.59 or 172.24.4.242 according to where the
command is running. Make sure your IP address is in the allowed CIDRs
specified in the above command.
diff --git a/doc/source/user/instance-status.rst b/doc/source/user/instance-status.rst
index a3a0568c..5e2dfbad 100644
--- a/doc/source/user/instance-status.rst
+++ b/doc/source/user/instance-status.rst
@@ -2,40 +2,46 @@
Database instance status
========================
-HEALTHY
- The database service is functional, e.g. table is accessible.
+Trove is maintaining two types of status, named ``status`` and ``operating_status``.
-RUNNING
- The database service is alive, but maybe not functional yet.
+``status`` is reflecting the trove instance VM status and instance task status, e.g. after successfully creating a trove instance, the ``status`` is ``ACTIVE``, when doing backup, the ``status`` is ``BACKUP``, etc.
-SHUTDOWN
- The database service is stopped.
+``operating_status`` is the actual database status inside the trove instance, trove guest agent is actively monitoring the database status and reporting back to trove, e.g. when MySQL service is up and running, the ``operating_status`` should be ``HEALTHY``, if MySQL service is not running for some reason, the ``operating_status`` is ``SHUTDOWN``.
+
+The possible values for ``status`` are:
NEW
- The database service creation request is just received by Trove.
+ The database instance creation request is just received by Trove.
BUILD
- The database service is being installed.
+ The database instance is being installed.
-BLOCKED
- The database service process exists but service is not accessible for some
- reason.
+ACTIVE
+ The database instance is up and running.
-PROMOTE
- Trove is replicating data between a replication group in order to promote a
- new master instance.
+REBOOT
+ The database instance is rebooting.
-EJECT
- The master election is happening within a replication group.
+RESIZE
+ The database instance is being resized.
+
+UPGRADE
+ The database instance is upgrading its datastore, e.g. from mysql 5.7.29 to mysql 5.7.30
RESTART_REQUIRED
The database service needs to restart, e.g. due to the configuration change.
-FAILED
- The database service is failed to spawn.
+PROMOTE
+ A replica instance in the replication cluster is being promoted to the primary.
+
+EJECT
+ The current primary instance in a replication cluster is being ejected, one of the replicas is going to be elected as the new primary.
-ERROR
- There are some errors in a running database service.
+DETACH
+ One of the replicas in a replication cluster is being detached and will become a standalone instance.
+
+SHUTDOWN
+ The database instance is being shutdown during deletion.
-DELETED
- The database service is deleted.
+BACKUP
+ The database instance is being backed up.
diff --git a/doc/source/user/set-up-replication.rst b/doc/source/user/set-up-replication.rst
index c215858d..ae0b3675 100644
--- a/doc/source/user/set-up-replication.rst
+++ b/doc/source/user/set-up-replication.rst
@@ -48,12 +48,12 @@ Set up replication
.. code-block:: console
$ openstack database instance list
- +--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+
- | ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role |
- +--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+
- | 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
- | cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
- +--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+
+ +--------------------------------------+----------------------+-----------+-------------------+---------+------------------+------------------------------------------------+-----------+------+-----------+---------+
+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+ +--------------------------------------+----------------------+-----------+-------------------+---------+------------------+------------------------------------------------+-----------+------+-----------+---------+
+ | 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
+ | cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
+ +--------------------------------------+----------------------+-----------+-------------------+---------+------------------+-----------------------------+-----------+------+-----------+---------+
#. Verify replication status.
@@ -120,13 +120,13 @@ couple minutes.
.. code-block:: console
$ openstack database instance list
- +--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+
- | ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role |
- +--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+
- | 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
- | a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
- | cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
- +--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+
+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
+ | 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
+ | a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
+ | cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+-----------------------------+-----------+------+-----------+---------+
#. Failover(promote) "test-mysql-replica-1" to primary.
@@ -139,13 +139,13 @@ couple minutes.
.. code-block:: console
$ openstack database instance list
- +--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+
- | ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role |
- +--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+
- | 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
- | a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
- | cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
- +--------------------------------------+----------------------+-----------+-------------------+---------+------------------------------------------------+-----------+------+-----------+---------+
+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
+ | 71f30a72-4e47-4505-9e7f-ffd8933a331c | test-mysql-replica-1 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.155', 'type': 'private'}] | d2 | 2 | RegionOne | primary |
+ | a85ece86-9f62-4aa8-bb15-eba604cd2a01 | test-mysql-replica-2 | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.243', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
+ | cebbf187-e223-46dd-8802-6dc04e895d0a | test-mysql | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.1.0.43', 'type': 'private'}] | d2 | 2 | RegionOne | replica |
+ +--------------------------------------+----------------------+-----------+-------------------+--------+------------------+------------------------------------------------+-----------+------+-----------+---------+
#. Point your application to the (former) replica.
diff --git a/doc/source/user/upgrade-datastore.rst b/doc/source/user/upgrade-datastore.rst
index dd89e4e8..cceff6d2 100644
--- a/doc/source/user/upgrade-datastore.rst
+++ b/doc/source/user/upgrade-datastore.rst
@@ -35,12 +35,12 @@ Upgrading datastore
| 50bed39d-6788-4a0d-8d74-321012bb6b55 | mysql |
+--------------------------------------+-------+
$ openstack datastore version list mysql
- +--------------------------------------+--------+
- | ID | Name |
- +--------------------------------------+--------+
- | 70c68d0a-27e1-4fbd-bd3b-f29d42ce1a7d | 5.7.29 |
- | cf91aa9a-2192-4ec4-b7ce-5cac3b1e7dbe | 5.7.30 |
- +--------------------------------------+--------+
+ +--------------------------------------+--------+---------+
+ | ID | Name | Version |
+ +--------------------------------------+--------+---------+
+ | 70c68d0a-27e1-4fbd-bd3b-f29d42ce1a7d | 5.7.29 | 5.7.29 |
+ | cf91aa9a-2192-4ec4-b7ce-5cac3b1e7dbe | 5.7.30 | 5.7.30 |
+ +--------------------------------------+--------+---------+
#. **Create a new instance with datastore version 5.7.29**
@@ -55,11 +55,11 @@ Upgrading datastore
--datastore mysql --datastore-version 5.7.29 \
--databases testdb --users user:password
$ openstack database instance list
- +--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+
- | ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role |
- +--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+
- | 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.29 | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
- +--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+
+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
+ | 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.29 | ACTIVE | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
Check the MySQL version by connecting with the database:
@@ -91,17 +91,17 @@ Upgrading datastore
.. code-block:: console
$ openstack database instance list
- +--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+
- | ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role |
- +--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+
- | 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | UPGRADE | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
- +--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+
+ +--------------------------------------+--------------------+-----------+-------------------+---------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+ +--------------------------------------+--------------------+-----------+-------------------+---------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
+ | 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | UPGRADE | | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
+ +--------------------------------------+--------------------+-----------+-------------------+---------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
$ openstack database instance list
- +--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+
- | ID | Name | Datastore | Datastore Version | Status | Addresses | Flavor ID | Size | Region | Role |
- +--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+
- | 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
- +--------------------------------------+--------------------+-----------+-------------------+---------+-----------------------------------------------+-----------+------+-----------+---------+
+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
+ | ID | Name | Datastore | Datastore Version | Status | Operating Status | Addresses | Flavor ID | Size | Region | Role |
+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
+ | 32eb56b0-d10d-43e9-b59e-1e4b0979e5dd | test-mysql-upgrade | mysql | 5.7.30 | ACTIVE | HEALTHY | [{'address': '10.0.0.54', 'type': 'private'}] | d2 | 1 | RegionOne | |
+ +--------------------------------------+--------------------+-----------+-------------------+--------+------------------+-----------------------------------------------+-----------+------+-----------+---------+
Check the MySQL version again:
diff --git a/releasenotes/notes/wallaby-operating-status.yaml b/releasenotes/notes/wallaby-operating-status.yaml
new file mode 100644
index 00000000..0117047e
--- /dev/null
+++ b/releasenotes/notes/wallaby-operating-status.yaml
@@ -0,0 +1,9 @@
+---
+features:
+ - Added a new field ``operating_status`` for the instance to show the actual
+ operational status of user's database. See
+ https://docs.openstack.org/trove/latest/user/instance-status.html for more
+ information.
+upgrade:
+ - Any 3rd party clients that are talking with Trove API to wait for
+ ``status`` should be notified to use ``operating_status`` instead.
diff --git a/trove/instance/models.py b/trove/instance/models.py
index 1c3079ea..cbd6933a 100644
--- a/trove/instance/models.py
+++ b/trove/instance/models.py
@@ -331,7 +331,26 @@ class SimpleInstance(object):
self.__datastore_status = datastore_status
@property
+ def operating_status(self):
+ """operating_status is the database service status."""
+ task_status = self.db_info.task_status
+ server_status = self.db_info.server_status
+ ds_status = self.datastore_status.status
+
+ if (task_status != InstanceTasks.NONE or server_status != 'ACTIVE'):
+ return ""
+
+ return repr(ds_status)
+
+ @property
def status(self):
+ """The server status of the database instance.
+
+ - The task action is considered first.
+ - If it's performing backup or not.
+ - Then server status
+ - Otherwise, unknown
+ """
LOG.info(f"Getting instance status for {self.id}, "
f"task status: {self.db_info.task_status}, "
f"datastore status: {self.datastore_status.status}, "
@@ -339,19 +358,12 @@ class SimpleInstance(object):
task_status = self.db_info.task_status
server_status = self.db_info.server_status
- ds_status = self.datastore_status.status
# Check for taskmanager errors.
if task_status.is_error:
return InstanceStatus.ERROR
action = task_status.action
-
- # Check if we are resetting status or force deleting
- if (srvstatus.ServiceStatuses.UNKNOWN == ds_status
- and action == InstanceTasks.DELETING.action):
- return InstanceStatus.SHUTDOWN
-
# Check for taskmanager status.
if InstanceTasks.BUILDING.action == action:
if 'ERROR' == server_status:
@@ -373,23 +385,9 @@ class SimpleInstance(object):
return InstanceStatus.LOGGING
if InstanceTasks.DETACHING.action == action:
return InstanceStatus.DETACH
-
- # Check for server status.
- if server_status in ["BUILD", "ERROR", "REBOOT", "RESIZE"]:
- return server_status
-
- # As far as Trove is concerned, Nova instances in VERIFY_RESIZE should
- # still appear as though they are in RESIZE.
- if server_status in ["VERIFY_RESIZE"]:
- return InstanceStatus.RESIZE
-
- # Check if there is a backup running for this instance
- if Backup.running(self.id):
- return InstanceStatus.BACKUP
-
# Report as Shutdown while deleting, unless there's an error.
- if 'DELETING' == action:
- if server_status in ["ACTIVE", "SHUTDOWN", "DELETED", "HEALTHY"]:
+ if InstanceTasks.DELETING.action == action:
+ if server_status in ["ACTIVE", "SHUTDOWN", "DELETED"]:
return InstanceStatus.SHUTDOWN
else:
LOG.error("While shutting down instance (%(instance)s): "
@@ -397,17 +395,21 @@ class SimpleInstance(object):
{'instance': self.id, 'status': server_status})
return InstanceStatus.ERROR
- # Check against the service status.
- # The service is only paused during a reboot.
- if ds_status == srvstatus.ServiceStatuses.PAUSED:
- return InstanceStatus.REBOOT
- elif ds_status == srvstatus.ServiceStatuses.NEW:
- return InstanceStatus.BUILD
- elif ds_status == srvstatus.ServiceStatuses.UNKNOWN:
- return InstanceStatus.ERROR
+ # Check if there is a backup running for this instance
+ if Backup.running(self.id):
+ return InstanceStatus.BACKUP
+
+ # Check for server status.
+ if server_status in ["BUILD", "ERROR", "REBOOT", "RESIZE", "ACTIVE",
+ "SHUTDOWN"]:
+ return server_status
+
+ # As far as Trove is concerned, Nova instances in VERIFY_RESIZE should
+ # still appear as though they are in RESIZE.
+ if server_status in ["VERIFY_RESIZE"]:
+ return InstanceStatus.RESIZE
- # For everything else we can look at the service status mapping.
- return self.datastore_status.status.api_status
+ return "UNKNOWN"
@property
def updated(self):
@@ -607,7 +609,6 @@ def load_instance(cls, context, id, needs_server=False,
def load_instance_with_info(cls, context, id, cluster_id=None):
db_info = get_db_info(context, id, cluster_id)
- LOG.debug('Task status for instance %s: %s', id, db_info.task_status)
service_status = InstanceServiceStatus.find_by(instance_id=id)
if (db_info.task_status == InstanceTasks.NONE and
diff --git a/trove/instance/views.py b/trove/instance/views.py
index 96d8c796..85181f16 100644
--- a/trove/instance/views.py
+++ b/trove/instance/views.py
@@ -35,6 +35,7 @@ class InstanceView(object):
"id": self.instance.id,
"name": self.instance.name,
"status": self.instance.status,
+ "operating_status": self.instance.operating_status,
"links": self._build_links(),
"flavor": self._build_flavor_info(),
"datastore": {"type": None, "version": None},
diff --git a/trove/tests/api/instances.py b/trove/tests/api/instances.py
index 643e120e..7f0f7887 100644
--- a/trove/tests/api/instances.py
+++ b/trove/tests/api/instances.py
@@ -622,7 +622,7 @@ class CreateInstanceFail(object):
'server_state_description', 'status', 'updated',
'users', 'volume', 'root_enabled_at',
'root_enabled_by', 'fault',
- 'service_status_updated']
+ 'service_status_updated', 'operating_status']
with CheckInstance(result._info) as check:
check.contains_allowed_attrs(
result._info, allowed_attrs,
@@ -785,7 +785,8 @@ class CreateInstance(object):
# Check these attrs only are returned in create response
allowed_attrs = ['created', 'flavor', 'addresses', 'id', 'links',
'name', 'status', 'updated', 'datastore', 'fault',
- 'region', 'service_status_updated', 'access']
+ 'region', 'service_status_updated', 'access',
+ 'operating_status']
if ROOT_ON_CREATE:
allowed_attrs.append('password')
if VOLUME_SUPPORT:
@@ -928,7 +929,7 @@ class TestGetInstances(object):
def test_index_list(self):
allowed_attrs = ['id', 'links', 'name', 'status', 'flavor',
'datastore', 'ip', 'hostname', 'replica_of',
- 'region', 'addresses', 'access']
+ 'region', 'addresses', 'access', 'operating_status']
if VOLUME_SUPPORT:
allowed_attrs.append('volume')
instances = dbaas.instances.list()
@@ -950,7 +951,8 @@ class TestGetInstances(object):
allowed_attrs = ['created', 'databases', 'flavor', 'hostname', 'id',
'links', 'name', 'status', 'updated', 'ip',
'datastore', 'fault', 'region',
- 'service_status_updated', 'addresses', 'access']
+ 'service_status_updated', 'addresses', 'access',
+ 'operating_status']
if VOLUME_SUPPORT:
allowed_attrs.append('volume')
instances = dbaas.instances.list(detailed=True)
@@ -970,7 +972,8 @@ class TestGetInstances(object):
allowed_attrs = ['created', 'databases', 'flavor', 'hostname', 'id',
'links', 'name', 'status', 'updated', 'ip',
'datastore', 'fault', 'region',
- 'service_status_updated', 'addresses', 'access']
+ 'service_status_updated', 'addresses', 'access',
+ 'operating_status']
if VOLUME_SUPPORT:
allowed_attrs.append('volume')
else:
@@ -1050,7 +1053,7 @@ class TestGetInstances(object):
'name', 'root_enabled_at', 'root_enabled_by',
'server_state_description', 'status', 'datastore',
'updated', 'users', 'volume', 'fault', 'region',
- 'access']
+ 'access', 'operating_status']
with CheckInstance(result._info) as check:
check.contains_allowed_attrs(
result._info, allowed_attrs,
diff --git a/trove/tests/api/instances_actions.py b/trove/tests/api/instances_actions.py
index 4d8d2b25..d35d0f7c 100644
--- a/trove/tests/api/instances_actions.py
+++ b/trove/tests/api/instances_actions.py
@@ -276,6 +276,15 @@ class RebootTestBase(ActionTestBase):
poll_until(is_status, time_out=timeout, sleep_time=sleep_time)
+ def wait_for_operating_status(self, status, timeout=60, sleep_time=5):
+ def is_status():
+ instance = self.instance
+ if instance.operating_status in status:
+ return True
+ return False
+
+ poll_until(is_status, time_out=timeout, sleep_time=sleep_time)
+
@test(groups=[tests.DBAAS_API_INSTANCE_ACTIONS],
depends_on_groups=[tests.DBAAS_API_DATABASES],
@@ -323,9 +332,7 @@ class StopTests(RebootTestBase):
def test_stop_mysql(self):
"""Stops MySQL by admin."""
instance_info.dbaas_admin.management.stop(self.instance_id)
-
- # The instance status will only be updated by guest agent.
- self.wait_for_status(['SHUTDOWN'], timeout=90, sleep_time=10)
+ self.wait_for_operating_status(['SHUTDOWN'], timeout=90, sleep_time=10)
@test(depends_on=[test_stop_mysql])
def test_volume_info_while_mysql_is_down(self):
diff --git a/trove/tests/scenario/runners/test_runners.py b/trove/tests/scenario/runners/test_runners.py
index 60326773..d1dacd0c 100644
--- a/trove/tests/scenario/runners/test_runners.py
+++ b/trove/tests/scenario/runners/test_runners.py
@@ -325,7 +325,7 @@ class TestRunner(object, metaclass=LogOnFail):
instance_info = InstanceTestInfo()
report = CONFIG.get_report()
- def __init__(self, sleep_time=10, timeout=1800):
+ def __init__(self, sleep_time=10, timeout=900):
self.def_sleep_time = sleep_time
self.def_timeout = timeout
@@ -604,6 +604,19 @@ class TestRunner(object, metaclass=LogOnFail):
self.assert_equal(expected_http_code, client.last_http_code,
"Unexpected client status code")
+ def assert_instance_operating_status(self, instance_id, expected_status):
+ self.report.log(f"Waiting for expected_status ({expected_status}) "
+ f"for instances: {instance_id}")
+
+ def wait_for_operating_status():
+ instance = self.get_instance(instance_id, self.admin_client)
+ if instance.operating_status == expected_status:
+ return True
+ return False
+
+ poll_until(wait_for_operating_status, sleep_time=self.def_sleep_time,
+ time_out=self.def_timeout)
+
def assert_all_instance_states(self, instance_ids, expected_states,
fast_fail_status=None,
require_all_states=False):
@@ -647,6 +660,15 @@ class TestRunner(object, metaclass=LogOnFail):
self.report.log("Waiting for states (%s) for instance: %s" %
(expected_states, instance_id))
+ # Replace HEALTHY with ACTIVE. This is needed after operating_status
+ # is introduced in Trove.
+ wait_operating_status = False
+ if 'HEALTHY' in expected_states:
+ wait_operating_status = True
+ expected_states.remove('HEALTHY')
+ if 'ACTIVE' not in expected_states:
+ expected_states.append('ACTIVE')
+
if fast_fail_status is None:
fast_fail_status = ['ERROR', 'FAILED']
found = False
@@ -677,6 +699,9 @@ class TestRunner(object, metaclass=LogOnFail):
"Instance state was not '%s', moving to the next expected "
"state." % status)
+ if found and wait_operating_status:
+ self.assert_instance_operating_status(instance_id, 'HEALTHY')
+
return found
def _time_since(self, start_time):
@@ -992,7 +1017,7 @@ class CheckInstance(AttrCheck):
if 'datastore' not in self.instance:
self.fail("'datastore' not found in instance.")
else:
- allowed_attrs = ['type', 'version']
+ allowed_attrs = ['type', 'version', 'version_number']
self.contains_allowed_attrs(
self.instance['datastore'], allowed_attrs,
msg="datastore")
diff --git a/trove/tests/unittests/instance/test_instance_status.py b/trove/tests/unittests/instance/test_instance_status.py
index a81849ce..aaa8bcd4 100644
--- a/trove/tests/unittests/instance/test_instance_status.py
+++ b/trove/tests/unittests/instance/test_instance_status.py
@@ -13,6 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
#
+from unittest import mock
import uuid
from trove.datastore import models
@@ -38,113 +39,114 @@ class FakeDBInstance(object):
self.id = str(uuid.uuid4())
self.deleted = False
self.datastore_version_id = str(uuid.uuid4())
- self.server_status = "HEALTHY"
+ self.server_status = "ACTIVE"
self.task_status = FakeInstanceTask()
class BaseInstanceStatusTestCase(trove_testtools.TestCase):
-
- def setUp(self):
+ @classmethod
+ def setUpClass(cls):
util.init_db()
- self.db_info = FakeDBInstance()
- self.status = InstanceServiceStatus(
- ServiceStatuses.RUNNING)
- self.datastore = models.DBDatastore.create(
+ cls.db_info = FakeDBInstance()
+ cls.datastore = models.DBDatastore.create(
id=str(uuid.uuid4()),
name='mysql' + str(uuid.uuid4()),
- default_version_id=self.db_info.datastore_version_id
+ default_version_id=cls.db_info.datastore_version_id
)
- self.version = models.DBDatastoreVersion.create(
- id=self.db_info.datastore_version_id,
- datastore_id=self.datastore.id,
+ cls.version = models.DBDatastoreVersion.create(
+ id=cls.db_info.datastore_version_id,
+ datastore_id=cls.datastore.id,
name='5.7' + str(uuid.uuid4()),
manager='mysql',
image_id=str(uuid.uuid4()),
active=1,
packages="mysql-server-5.7"
)
- super(BaseInstanceStatusTestCase, self).setUp()
+ super(BaseInstanceStatusTestCase, cls).setUpClass()
- def tearDown(self):
- self.datastore.delete()
- self.version.delete()
- super(BaseInstanceStatusTestCase, self).tearDown()
+ @classmethod
+ def tearDownClass(cls):
+ util.cleanup_db()
+ super(BaseInstanceStatusTestCase, cls).tearDownClass()
class InstanceStatusTest(BaseInstanceStatusTestCase):
+ def setUp(self):
+ self.db_info.task_status = FakeInstanceTask()
+ self.db_info.server_status = "ACTIVE"
+ self.ds_status = InstanceServiceStatus(ServiceStatuses.HEALTHY)
+ super(InstanceStatusTest, self).setUp()
def test_task_status_error_reports_error(self):
self.db_info.task_status.is_error = True
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.ERROR, instance.status)
def test_task_status_action_building_reports_build(self):
self.db_info.task_status.action = "BUILDING"
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.BUILD, instance.status)
def test_task_status_action_rebooting_reports_reboot(self):
self.db_info.task_status.action = "REBOOTING"
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.REBOOT, instance.status)
def test_task_status_action_resizing_reports_resize(self):
self.db_info.task_status.action = "RESIZING"
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.RESIZE, instance.status)
- def test_task_status_action_deleting_reports_shutdown(self):
+ def test_task_deleting_server_active(self):
self.db_info.task_status.action = "DELETING"
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.SHUTDOWN, instance.status)
def test_nova_server_build_reports_build(self):
self.db_info.server_status = "BUILD"
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.BUILD, instance.status)
def test_nova_server_error_reports_error(self):
self.db_info.server_status = "ERROR"
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.ERROR, instance.status)
def test_nova_server_reboot_reports_reboot(self):
self.db_info.server_status = "REBOOT"
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.REBOOT, instance.status)
def test_nova_server_resize_reports_resize(self):
self.db_info.server_status = "RESIZE"
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.RESIZE, instance.status)
def test_nova_server_verify_resize_reports_resize(self):
self.db_info.server_status = "VERIFY_RESIZE"
- instance = SimpleInstance('dummy context', self.db_info, self.status)
+ instance = SimpleInstance('dummy context', self.db_info,
+ self.ds_status)
self.assertEqual(InstanceStatus.RESIZE, instance.status)
- def test_service_status_paused_reports_reboot(self):
- self.status.set_status(ServiceStatuses.PAUSED)
- instance = SimpleInstance('dummy context', self.db_info, self.status)
- self.assertEqual(InstanceStatus.REBOOT, instance.status)
-
- def test_service_status_new_reports_build(self):
- self.status.set_status(ServiceStatuses.NEW)
- instance = SimpleInstance('dummy context', self.db_info, self.status)
- self.assertEqual(InstanceStatus.BUILD, instance.status)
-
- def test_service_status_running_reports_active(self):
- self.status.set_status(ServiceStatuses.RUNNING)
- instance = SimpleInstance('dummy context', self.db_info, self.status)
- self.assertEqual(InstanceStatus.ACTIVE, instance.status)
-
- def test_service_status_reset_status(self):
- self.status.set_status(ServiceStatuses.UNKNOWN)
- instance = SimpleInstance('dummy context', self.db_info, self.status)
- self.assertEqual(InstanceStatus.ERROR, instance.status)
-
- def test_service_status_force_deleteing(self):
- self.status.set_status(ServiceStatuses.UNKNOWN)
- self.db_info.task_status = InstanceTasks.DELETING
- instance = SimpleInstance('dummy context', self.db_info, self.status)
- self.assertEqual(InstanceStatus.SHUTDOWN, instance.status)
+ def test_operating_status_healthy(self):
+ self.db_info.task_status = InstanceTasks.NONE
+ instance = SimpleInstance(mock.MagicMock(), self.db_info,
+ self.ds_status)
+ self.assertEqual(repr(ServiceStatuses.HEALTHY),
+ instance.operating_status)
+
+ def test_operating_status_task_not_none(self):
+ self.db_info.task_status = InstanceTasks.RESIZING
+ instance = SimpleInstance(mock.MagicMock(), self.db_info,
+ self.ds_status)
+ self.assertEqual("",
+ instance.operating_status)