"Fossies" - the Fresh Open Source Software Archive

Member "octavia-8.0.0/octavia/tests/unit/compute/drivers/noop_driver/test_driver.py" (14 Apr 2021, 5957 Bytes) of package /linux/misc/openstack/octavia-8.0.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Python source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 # Copyright 2015 Hewlett-Packard Development Company, L.P.
    2 #
    3 # Licensed under the Apache License, Version 2.0 (the "License"); you may
    4 # not use this file except in compliance with the License. You may obtain
    5 # a copy of the License at
    6 #
    7 # http://www.apache.org/licenses/LICENSE-2.0
    8 #
    9 # Unless required by applicable law or agreed to in writing, software
   10 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
   11 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
   12 #    License for the specific language governing permissions and limitations
   13 #    under the License.
   14 
   15 from oslo_utils import uuidutils
   16 
   17 from octavia.compute.drivers.noop_driver import driver
   18 import octavia.tests.unit.base as base
   19 
   20 
   21 class TestNoopComputeDriver(base.TestCase):
   22     FAKE_UUID_1 = uuidutils.generate_uuid()
   23     FAKE_UUID_2 = uuidutils.generate_uuid()
   24     FAKE_UUID_3 = uuidutils.generate_uuid()
   25     FAKE_UUID_4 = uuidutils.generate_uuid()
   26     FAKE_UUID_5 = uuidutils.generate_uuid()
   27     FAKE_UUID_6 = uuidutils.generate_uuid()
   28 
   29     def setUp(self):
   30         super().setUp()
   31         self.driver = driver.NoopComputeDriver()
   32 
   33         self.name = "amphora_name"
   34         self.amphora_flavor = "m1.tiny"
   35         self.image_tag = "faketag"
   36         self.image_owner = self.FAKE_UUID_2
   37         self.key_name = "key_name"
   38         self.sec_groups = ["default"]
   39         self.network_ids = [self.FAKE_UUID_3]
   40         self.confdrivefiles = ["config_driver_file1"]
   41         self.user_data = "user_data"
   42         self.amphora_id = self.FAKE_UUID_4
   43         self.loadbalancer_id = self.FAKE_UUID_5
   44         self.server_group_policy = 'anti-affinity'
   45         self.server_group_name = 'my_server_group'
   46         self.server_group_id = self.FAKE_UUID_6
   47         self.port_ids = ['port-id-1']
   48         self.port_id = 88
   49         self.network_id = uuidutils.generate_uuid()
   50         self.ip_address = "192.0.2.2"
   51         self.flavor_id = uuidutils.generate_uuid()
   52         self.availability_zone = 'my_test_az'
   53 
   54     def test_build(self):
   55         self.driver.build(self.name, self.amphora_flavor,
   56                           self.image_tag, self.image_owner,
   57                           self.key_name, self.sec_groups, self.network_ids,
   58                           self.confdrivefiles, self.user_data, self.port_ids,
   59                           self.server_group_id)
   60 
   61         self.assertEqual((self.name, self.amphora_flavor,
   62                           self.image_tag, self.image_owner,
   63                           self.key_name, self.sec_groups, self.network_ids,
   64                           self.confdrivefiles, self.user_data, self.port_ids,
   65                           self.server_group_id, 'build'),
   66                          self.driver.driver.computeconfig[(
   67                              self.name,
   68                              self.amphora_flavor,
   69                              self.image_tag,
   70                              self.image_owner,
   71                              self.key_name,
   72                              self.user_data,
   73                              self.server_group_id
   74                          )])
   75 
   76     def test_delete(self):
   77         self.driver.delete(self.amphora_id)
   78         self.assertEqual((self.amphora_id, 'delete'),
   79                          self.driver.driver.computeconfig[
   80                              self.amphora_id])
   81 
   82     def test_status(self):
   83         self.driver.status(self.amphora_id)
   84         self.assertEqual((self.amphora_id, 'status'),
   85                          self.driver.driver.computeconfig[
   86                              self.amphora_id])
   87 
   88     def test_get_amphora(self):
   89         management_network_id = uuidutils.generate_uuid()
   90         self.driver.get_amphora(self.amphora_id, management_network_id)
   91         self.assertEqual(
   92             (self.amphora_id, management_network_id, 'get_amphora'),
   93             self.driver.driver.computeconfig[
   94                 self.amphora_id, management_network_id])
   95 
   96     def test_create_server_group(self):
   97         self.driver.create_server_group(self.server_group_name,
   98                                         self.server_group_policy)
   99         self.assertEqual((self.server_group_name, self.server_group_policy,
  100                           'create'),
  101                          self.driver.driver.computeconfig[
  102                              self.server_group_name, self.server_group_policy])
  103 
  104     def test_delete_server_group(self):
  105         self.driver.delete_server_group(self.server_group_id)
  106         self.assertEqual((self.server_group_id, 'delete'),
  107                          self.driver.driver.computeconfig[
  108                              self.server_group_id])
  109 
  110     def test_attach_network_or_port(self):
  111         self.driver.attach_network_or_port(self.amphora_id, self.network_id,
  112                                            self.ip_address, self.port_id)
  113         self.assertEqual((self.amphora_id, self.network_id, self.ip_address,
  114                           self.port_id, 'attach_network_or_port'),
  115                          self.driver.driver.computeconfig[(
  116                              self.amphora_id, self.network_id,
  117                              self.ip_address, self.port_id)])
  118 
  119     def test_detach_port(self):
  120         self.driver.detach_port(self.amphora_id, self.port_id)
  121         self.assertEqual((self.amphora_id, self.port_id,
  122                           'detach_port'),
  123                          self.driver.driver.computeconfig[(
  124                              self.amphora_id, self.port_id)])
  125 
  126     def test_validate_flavor(self):
  127         self.driver.validate_flavor(self.flavor_id)
  128         self.assertEqual((self.flavor_id, 'validate_flavor'),
  129                          self.driver.driver.computeconfig[self.flavor_id])
  130 
  131     def test_validate_availability_zone(self):
  132         self.driver.validate_availability_zone(self.availability_zone)
  133         self.assertEqual(
  134             (self.availability_zone, 'validate_availability_zone'),
  135             self.driver.driver.computeconfig[self.availability_zone])