Load Balancing as a Service (LBaaS) for OpenStack
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
2.2 KiB

# Copyright 2016 Rackspace
# 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.
from octavia.common.jinja import user_data_jinja_cfg
import octavia.tests.unit.base as base
'debug = False\n'
'base_cert_dir = /var/lib/octavia/certs\n')
' debug = False\n'
' [haproxy_amphora]\n'
' base_cert_dir = /var/lib/octavia/certs\n\n')
BASE_CFG = ('#cloud-config\n'
'# vim: syntax=yaml\n'
'# This configuration with take user-data dict and '
'build a cloud-init\n'
'# script utilizing the write_files module. '
'The user-data dict should be a\n'
'# Key Value pair where the Key is the path to store the '
'file and the Value\n'
'# is the data to store at that location\n'
'# Example:\n'
'# {\'/root/path/to/file.cfg\': \'I\'m a file, '
'write things in me\'}\n'
RUN_CMD = ('runcmd:\n'
'- service amphora-agent restart')
class TestUserDataJinjaCfg(base.TestCase):
def setUp(self):
super(TestUserDataJinjaCfg, self).setUp()
def test_build_user_data_config(self):
udc = user_data_jinja_cfg.UserDataJinjaCfg()
expected_config = (BASE_CFG +
'- path: /test/config/path\n'
' content: |\n' + EXPECTED_TEST_CONFIG + RUN_CMD)
ud_cfg = udc.build_user_data_config({'/test/config/path': TEST_CONFIG})
self.assertEqual(expected_config, ud_cfg)