Adds a simple example for the mysql client
The test connects to the database and verifies that at least one service is registered.
This commit is contained in:
@@ -12,10 +12,12 @@
|
|||||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||||
# License for the specific language governing permissions and limitations
|
# License for the specific language governing permissions and limitations
|
||||||
# under the License.
|
# under the License.
|
||||||
from rhostest_tempest_plugin.tests.api import base
|
|
||||||
from tempest import config
|
from tempest import config
|
||||||
from tempest import test
|
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
|
CONF = config.CONF
|
||||||
|
|
||||||
@@ -48,3 +50,15 @@ class SampleRHOSTest(base.BaseRHOSTest):
|
|||||||
# This test shows how to use the tempest clients
|
# This test shows how to use the tempest clients
|
||||||
server = self.create_test_server(adminPass='testpassword')
|
server = self.create_test_server(adminPass='testpassword')
|
||||||
self.assertEqual('testpassword', server['adminPass'])
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user