From 31d2e465e39a246f829870e1081863982111c4d7 Mon Sep 17 00:00:00 2001 From: Chris Friesen Date: Thu, 1 Jun 2017 19:29:52 -0600 Subject: [PATCH] add new test fixture flavor with extra_specs We support flavor extra_specs, so it would probably make sense to have some in one of the test fixture flavors. In order to make it compatible with the functional tests we'll make it as small as m1.tiny. Change-Id: Ic98d7dd2f44796279e18083a8c423aed0066d177 --- .../flavors/flavors-detail-resp.json | 22 +++++++++++++++++++ .../flavors/flavors-list-resp.json | 16 +++++++++++++- nova/tests/fixtures.py | 8 +++++++ .../flavors/flavors-detail-resp.json.tpl | 22 +++++++++++++++++++ .../flavors/flavors-list-resp.json.tpl | 14 ++++++++++++ nova/tests/unit/test_fixtures.py | 2 +- nova/tests/unit/test_flavors.py | 2 +- 7 files changed, 83 insertions(+), 3 deletions(-) diff --git a/doc/api_samples/flavors/flavors-detail-resp.json b/doc/api_samples/flavors/flavors-detail-resp.json index b83549f188cd..f59f287dedf3 100644 --- a/doc/api_samples/flavors/flavors-detail-resp.json +++ b/doc/api_samples/flavors/flavors-detail-resp.json @@ -109,6 +109,28 @@ "swap": "", "vcpus": 8, "rxtx_factor": 1.0 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 1, + "OS-FLV-EXT-DATA:ephemeral": 0, + "os-flavor-access:is_public": true, + "id": "6", + "links": [ + { + "href": "http://openstack.example.com/v2/6f70656e737461636b20342065766572/flavors/6", + "rel": "self" + }, + { + "href": "http://openstack.example.com/6f70656e737461636b20342065766572/flavors/6", + "rel": "bookmark" + } + ], + "name": "m1.tiny.specs", + "ram": 512, + "swap": "", + "vcpus": 1, + "rxtx_factor": 1.0 } ] } diff --git a/doc/api_samples/flavors/flavors-list-resp.json b/doc/api_samples/flavors/flavors-list-resp.json index c585f2bb524d..d20397296340 100644 --- a/doc/api_samples/flavors/flavors-list-resp.json +++ b/doc/api_samples/flavors/flavors-list-resp.json @@ -69,6 +69,20 @@ } ], "name": "m1.xlarge" + }, + { + "id": "6", + "links": [ + { + "href": "http://openstack.example.com/v2/6f70656e737461636b20342065766572/flavors/6", + "rel": "self" + }, + { + "href": "http://openstack.example.com/6f70656e737461636b20342065766572/flavors/6", + "rel": "bookmark" + } + ], + "name": "m1.tiny.specs" } ] -} \ No newline at end of file +} diff --git a/nova/tests/fixtures.py b/nova/tests/fixtures.py index c5721d1218d8..279368662d36 100644 --- a/nova/tests/fixtures.py +++ b/nova/tests/fixtures.py @@ -622,6 +622,11 @@ class DefaultFlavorsFixture(fixtures.Fixture): ctxt = context.get_admin_context() defaults = {'rxtx_factor': 1.0, 'disabled': False, 'is_public': True, 'ephemeral_gb': 0, 'swap': 0} + extra_specs = { + "hw:cpu_model": "SandyBridge", + "hw:mem_page_size": "2048", + "hw:cpu_policy": "dedicated" + } default_flavors = [ objects.Flavor(context=ctxt, memory_mb=512, vcpus=1, root_gb=1, flavorid='1', name='m1.tiny', @@ -638,6 +643,9 @@ class DefaultFlavorsFixture(fixtures.Fixture): objects.Flavor(context=ctxt, memory_mb=16384, vcpus=8, root_gb=160, flavorid='5', name='m1.xlarge', **defaults), + objects.Flavor(context=ctxt, memory_mb=512, vcpus=1, + root_gb=1, flavorid='6', name='m1.tiny.specs', + extra_specs=extra_specs, **defaults), ] for flavor in default_flavors: flavor.create() diff --git a/nova/tests/functional/api_sample_tests/api_samples/flavors/flavors-detail-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/flavors/flavors-detail-resp.json.tpl index 1d812a82e67b..636ae4323926 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/flavors/flavors-detail-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/flavors/flavors-detail-resp.json.tpl @@ -109,6 +109,28 @@ "swap": "", "vcpus": 8, "rxtx_factor": 1.0 + }, + { + "OS-FLV-DISABLED:disabled": false, + "disk": 1, + "OS-FLV-EXT-DATA:ephemeral": 0, + "id": "6", + "links": [ + { + "href": "%(versioned_compute_endpoint)s/flavors/6", + "rel": "self" + }, + { + "href": "%(compute_endpoint)s/flavors/6", + "rel": "bookmark" + } + ], + "name": "m1.tiny.specs", + "os-flavor-access:is_public": true, + "ram": 512, + "swap": "", + "vcpus": 1, + "rxtx_factor": 1.0 } ] } diff --git a/nova/tests/functional/api_sample_tests/api_samples/flavors/flavors-list-resp.json.tpl b/nova/tests/functional/api_sample_tests/api_samples/flavors/flavors-list-resp.json.tpl index a78ccd901365..54de90e4c7a9 100644 --- a/nova/tests/functional/api_sample_tests/api_samples/flavors/flavors-list-resp.json.tpl +++ b/nova/tests/functional/api_sample_tests/api_samples/flavors/flavors-list-resp.json.tpl @@ -69,6 +69,20 @@ } ], "name": "m1.xlarge" + }, + { + "id": "6", + "links": [ + { + "href": "%(versioned_compute_endpoint)s/flavors/6", + "rel": "self" + }, + { + "href": "%(compute_endpoint)s/flavors/6", + "rel": "bookmark" + } + ], + "name": "m1.tiny.specs" } ] } diff --git a/nova/tests/unit/test_fixtures.py b/nova/tests/unit/test_fixtures.py index 8a81fe479014..cb5a4ceb1d91 100644 --- a/nova/tests/unit/test_fixtures.py +++ b/nova/tests/unit/test_fixtures.py @@ -333,7 +333,7 @@ class TestDefaultFlavorsFixture(testtools.TestCase): result = conn.execute("select * from flavors") rows = result.fetchall() - self.assertEqual(5, len(rows), "Rows %s" % rows) + self.assertEqual(6, len(rows), "Rows %s" % rows) class TestIndirectionAPIFixture(testtools.TestCase): diff --git a/nova/tests/unit/test_flavors.py b/nova/tests/unit/test_flavors.py index b4080e93541f..8bdf04a36f58 100644 --- a/nova/tests/unit/test_flavors.py +++ b/nova/tests/unit/test_flavors.py @@ -154,7 +154,7 @@ class InstanceTypeFilteringTest(test.TestCase): def test_no_filters(self): filters = None expected = ['m1.tiny', 'm1.small', 'm1.medium', 'm1.large', - 'm1.xlarge'] + 'm1.xlarge', 'm1.tiny.specs'] self.assertFilterResults(filters, expected) def test_min_memory_mb_filter(self):