|
| 1 | +# Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 2 | +# not use this file except in compliance with the License. You may obtain |
| 3 | +# a copy of the License at |
| 4 | +# |
| 5 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 6 | +# |
| 7 | +# Unless required by applicable law or agreed to in writing, software |
| 8 | +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 9 | +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 10 | +# License for the specific language governing permissions and limitations |
| 11 | +# under the License. |
| 12 | + |
| 13 | +import hashlib |
| 14 | + |
| 15 | +from functional.common import test |
| 16 | + |
| 17 | + |
| 18 | +class ComputeAgentTests(test.TestCase): |
| 19 | + """Functional tests for compute agent. """ |
| 20 | + |
| 21 | + ID = None |
| 22 | + MD5HASH = hashlib.md5().hexdigest() |
| 23 | + URL = "http://localhost" |
| 24 | + VER = "v1" |
| 25 | + OS = "TEST_OS" |
| 26 | + ARCH = "x86_64" |
| 27 | + HYPER = "kvm" |
| 28 | + |
| 29 | + HEADERS = ['agent_id', 'md5hash'] |
| 30 | + FIELDS = ['agent_id', 'md5hash'] |
| 31 | + |
| 32 | + @classmethod |
| 33 | + def setUpClass(cls): |
| 34 | + opts = cls.get_show_opts(cls.HEADERS) |
| 35 | + raw_output = cls.openstack('compute agent create ' |
| 36 | + + cls.OS + ' ' + cls.ARCH + ' ' |
| 37 | + + cls.VER + ' ' + cls.URL + ' ' |
| 38 | + + cls.MD5HASH + ' ' + cls.HYPER + ' ' |
| 39 | + + opts) |
| 40 | + |
| 41 | + # Get agent id because agent can only be deleted by ID |
| 42 | + output_list = raw_output.split('\n', 1) |
| 43 | + cls.ID = output_list[0] |
| 44 | + |
| 45 | + cls.assertOutput(cls.MD5HASH + '\n', output_list[1]) |
| 46 | + |
| 47 | + @classmethod |
| 48 | + def tearDownClass(cls): |
| 49 | + raw_output = cls.openstack('compute agent delete ' + cls.ID) |
| 50 | + cls.assertOutput('', raw_output) |
| 51 | + |
| 52 | + def test_agent_list(self): |
| 53 | + raw_output = self.openstack('compute agent list') |
| 54 | + self.assertIn(self.ID, raw_output) |
| 55 | + self.assertIn(self.OS, raw_output) |
| 56 | + self.assertIn(self.ARCH, raw_output) |
| 57 | + self.assertIn(self.VER, raw_output) |
| 58 | + self.assertIn(self.URL, raw_output) |
| 59 | + self.assertIn(self.MD5HASH, raw_output) |
| 60 | + self.assertIn(self.HYPER, raw_output) |
| 61 | + |
| 62 | + def test_agent_set(self): |
| 63 | + ver = 'v2' |
| 64 | + url = "http://openstack" |
| 65 | + md5hash = hashlib.md5().hexdigest() |
| 66 | + |
| 67 | + raw_output = self.openstack('compute agent set ' |
| 68 | + + self.ID + ' ' + ver + ' ' |
| 69 | + + url + ' ' + md5hash) |
| 70 | + self.assertEqual('', raw_output) |
| 71 | + |
| 72 | + raw_output = self.openstack('compute agent list') |
| 73 | + self.assertIn(self.ID, raw_output) |
| 74 | + self.assertIn(ver, raw_output) |
| 75 | + self.assertIn(url, raw_output) |
| 76 | + self.assertIn(md5hash, raw_output) |
0 commit comments