Skip to content

Commit

Permalink
Add LBaaSv2 volume-based Amphora test
Browse files Browse the repository at this point in the history
Enable Amphora to run instances booted from a volume by flipping the
config option `enable-volume-based-amphora` to True and checking volumes
attached to the amphora instances.

Depends-On: https://review.opendev.org/c/openstack/charm-octavia/+/810567
Related-Bug: https://launchpad.net/bugs/1901732
  • Loading branch information
Nicholas Njihia authored and dosaboy committed Sep 20, 2024
1 parent 32bcda1 commit 856d7d9
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
1 change: 1 addition & 0 deletions zaza/openstack/charm_tests/octavia/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ def ensure_lts_images():
glance_setup.add_lts_image(image_name='bionic', release='bionic')
glance_setup.add_lts_image(image_name='focal', release='focal')
glance_setup.add_lts_image(image_name='jammy', release='jammy')
glance_setup.add_lts_image(image_name='noble', release='noble')


def add_amphora_image(image_url=None):
Expand Down
51 changes: 50 additions & 1 deletion zaza/openstack/charm_tests/octavia/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

"""Encapsulate octavia testing."""

import json
import logging
import subprocess
import tenacity
Expand All @@ -34,6 +35,7 @@
LoadBalancerUnexpectedState,
LoadBalancerUnrecoverableError,
)
from zaza.openstack.utilities.os_versions import CompareOpenStack

LBAAS_ADMIN_ROLE = 'load-balancer_admin'

Expand Down Expand Up @@ -202,6 +204,8 @@ def setUpClass(cls):
openstack_utils.get_neutron_session_client(cls.keystone_session))
cls.octavia_client = ObjectRetrierWraps(
openstack_utils.get_octavia_session_client(cls.keystone_session))
cls.cinder_client = ObjectRetrierWraps(
openstack_utils.get_cinder_session_client(cls.keystone_session))
cls.RESOURCE_PREFIX = 'zaza-octavia'

# NOTE(fnordahl): in the event of a test failure we do not want to run
Expand Down Expand Up @@ -456,7 +460,7 @@ def _get_payload(ip):
'http://{}/'.format(ip)],
universal_newlines=True)

def test_create_loadbalancer(self):
def create_loadbalancer(self, ensure_volume_backed=False):
"""Create load balancer."""
# Prepare payload instances
# First we allow communication to port 80 by adding a security group
Expand Down Expand Up @@ -526,11 +530,56 @@ def test_create_loadbalancer(self):
.format(snippet, provider,
lb_fp['floating_ip_address']))

if ensure_volume_backed:
amphora_list = self.octavia_client.amphora_list()
self.assertTrue(len(amphora_list) > 0)
attached_volumes = []
for amphora in amphora_list.get('amphorae', []):
server_id = amphora['compute_id']
logging.info("Checking amphora {} server {} for attached "
"volumes".format(amphora['id'], server_id))
volumes = self.nova_client.volumes.get_server_volumes(
server_id)
logging.info('amphora {} server {} has volumes={}'.
format(amphora['id'],
server_id, volumes))
attached_volumes.append(json.dumps(vars(volumes)))

self.assertTrue(len(attached_volumes) > 0)
logging.info("Amphora volumes creation successful: {}".format(
attached_volumes))

# If we get here, it means the tests passed
self.run_resource_cleanup = True

def test_create_loadbalancer(self):
"""Test creating a load balancer."""
self.create_loadbalancer()


class OctaviaTempestTestK8S(tempest_tests.TempestTestScaleK8SBase):
"""Test octavia k8s scale out and scale back."""

application_name = "octavia"


class VolumeBasedAmphoraTest(LBAASv2Test):
"""LBaaSv2 Volume-based Amphora tests."""

@classmethod
def setUpClass(cls):
"""Run class setup for LBaaSv2 Volume-based amphora tests."""
super(VolumeBasedAmphoraTest, cls).setUpClass()
os_versions = openstack_utils.get_current_os_versions(['octavia'])
if CompareOpenStack(os_versions['octavia']) < 'ussuri':
cls.skipTest('Run only for Openstack Ussuri and newer releases.')
return

def test_volume_based_amphora(self):
"""Test creating a load balancer that uses volume-based amphora."""
default_charm_config = {'enable-volume-based-amphora': False}
alternate_charm_config = {'enable-volume-based-amphora': True}
with self.config_change(default_charm_config,
alternate_charm_config, reset_to_charm_default=True):
logging.info("Testing create volume-backed amphora loadbalancer")
self.create_loadbalancer(ensure_volume_backed=True)

0 comments on commit 856d7d9

Please sign in to comment.