From 7dde6ee980a6f34a081d0bfc7380b766e6fb66bf Mon Sep 17 00:00:00 2001 From: "Joe H. Rahme" Date: Tue, 27 Sep 2016 17:14:09 +0200 Subject: [PATCH] Adds a simple example for the mysql client The test connects to the database and verifies that at least one service is registered. --- rhostest_tempest_plugin/tests/api/test_sample.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/rhostest_tempest_plugin/tests/api/test_sample.py b/rhostest_tempest_plugin/tests/api/test_sample.py index 4b92ab10..a50f5ae2 100644 --- a/rhostest_tempest_plugin/tests/api/test_sample.py +++ b/rhostest_tempest_plugin/tests/api/test_sample.py @@ -12,10 +12,12 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from rhostest_tempest_plugin.tests.api import base from tempest import config from tempest import test +from rhostest_tempest_plugin.lib.mysql import default_client as dbclient +from rhostest_tempest_plugin.tests.api import base + CONF = config.CONF @@ -48,3 +50,15 @@ class SampleRHOSTest(base.BaseRHOSTest): # This test shows how to use the tempest clients server = self.create_test_server(adminPass='testpassword') self.assertEqual('testpassword', server['adminPass']) + + def test_mysql_client(self): + # This test shows how to use the mysql dbclient + connection = dbclient.connect() + try: + with connection.cursor() as cursor: + result = cursor.execute("SELECT * FROM nova.services;") + + self.assertGreater(result, 0) + + finally: + connection.close()