From c912bf100d8ca7585160ab817a7482cb34cbce51 Mon Sep 17 00:00:00 2001 From: Idan Narotzki Date: Thu, 6 Jul 2017 13:43:45 +0000 Subject: [PATCH] Add tempest tests. Add test_DB_store tests that includes: create artifact, download/upload blob/folder. Change-Id: I8e77fe639e73a4107433c1bcbbd601c6d089786c --- glare_tempest_plugin/README.rst | 18 +++++ glare_tempest_plugin/tests/api/test_blobs.py | 79 +++++++++++++++++++ .../tests/api/test_list_artifact.py | 2 - 3 files changed, 97 insertions(+), 2 deletions(-) create mode 100644 glare_tempest_plugin/README.rst create mode 100644 glare_tempest_plugin/tests/api/test_blobs.py diff --git a/glare_tempest_plugin/README.rst b/glare_tempest_plugin/README.rst new file mode 100644 index 0000000..99d3995 --- /dev/null +++ b/glare_tempest_plugin/README.rst @@ -0,0 +1,18 @@ +============================ +Tempest Integration of Glare +============================ + +This directory contains Tempest tests to cover the Glare project. + +To list all glare tempest cases, go to tempest directory, then run: + + $ testr list-tests glare + +To run glare tempest plugin tests using tox, go to tempest directory, then run: + + $ tox -eall-plugin glare + +And, to run a specific test: + + TBD + diff --git a/glare_tempest_plugin/tests/api/test_blobs.py b/glare_tempest_plugin/tests/api/test_blobs.py new file mode 100644 index 0000000..c07dd14 --- /dev/null +++ b/glare_tempest_plugin/tests/api/test_blobs.py @@ -0,0 +1,79 @@ +# Copyright 2017 Nokia, Inc. +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +import hashlib +import testtools + + +from glare_tempest_plugin.tests.api import base +from pprint import pformat + + +class TestDownloadSanity(base.BaseArtifactTest): + + @testtools.testcase.attr('TestDownloadSanity') + def test_blob_dict(self): + """Uploading data to a folder and then download it back""" + + # Create a test artifact + art = self.artifacts_client.create_artifact('sample_artifact', + 'sample_art1') + data = "data" * 100 + art = self.artifacts_client.upload_blob( + 'sample_artifact', art['id'], '/dict_of_blobs/new_blob', data) + + art_blob = art['dict_of_blobs']['new_blob'] + self.assertEqual(400, art_blob['size']) + self.assertEqual('active', art_blob['status'], pformat(art_blob)) + + encoded_data = data.encode('UTF-8') + md5 = hashlib.md5(encoded_data).hexdigest() + sha1 = hashlib.sha1(encoded_data).hexdigest() + sha256 = hashlib.sha256(encoded_data).hexdigest() + self.assertEqual(md5, art_blob['md5']) + self.assertEqual(sha1, art_blob['sha1']) + self.assertEqual(sha256, art_blob['sha256']) + + # Download data from the folder (dict_of_blobs) + self.assertEqual(data, + self.artifacts_client.download_blob( + 'sample_artifact', art['id'], + '/dict_of_blobs/new_blob'), pformat(art)) + + @testtools.testcase.attr('TestDownloadSanity') + def test_blob_download(self): + data = 'some_arbitrary_testing_data' + art = self.artifacts_client.create_artifact('sample_artifact', + 'test_af') + + # upload data + art = self.artifacts_client.upload_blob('sample_artifact', + art['id'], 'blob', data) + + art_blob = art['blob'] + self.assertEqual('active', art_blob['status'], pformat(art)) + encoded_data = data.encode('UTF-8') + md5 = hashlib.md5(encoded_data).hexdigest() + sha1 = hashlib.sha1(encoded_data).hexdigest() + sha256 = hashlib.sha256(encoded_data).hexdigest() + self.assertEqual(md5, art_blob['md5']) + self.assertEqual(sha1, art_blob['sha1']) + self.assertEqual(sha256, art_blob['sha256']) + + # Download data + self.assertEqual(data, + self.artifacts_client.download_blob( + 'sample_artifact', art['id'], + '/blob'), pformat(art)) diff --git a/glare_tempest_plugin/tests/api/test_list_artifact.py b/glare_tempest_plugin/tests/api/test_list_artifact.py index 4b516df..068eaf0 100644 --- a/glare_tempest_plugin/tests/api/test_list_artifact.py +++ b/glare_tempest_plugin/tests/api/test_list_artifact.py @@ -13,14 +13,12 @@ # License for the specific language governing permissions and limitations # under the License. - import testtools from glare_tempest_plugin.tests.api import base from tempest import config - CONF = config.CONF