Add test_fuel_ccp_dry_run test
- add test_fuel_ccp_dry_run; Change-Id: I634c1a0e14141c0f923cb58bec8f1b40ee3077f6
This commit is contained in:
parent
e83ad13158
commit
2c07ce4bb9
|
@ -11,6 +11,7 @@
|
|||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
import os
|
||||
|
||||
from fuel_ccp_tests.helpers import exceptions
|
||||
from fuel_ccp_tests import settings
|
||||
|
@ -46,7 +47,15 @@ class CCPManager(object):
|
|||
|
||||
@classmethod
|
||||
def build_command(cls, *args, **kwargs):
|
||||
command_list = ['ccp']
|
||||
"""Generate the list of parameters
|
||||
|
||||
:param args: list of command parameters
|
||||
:param kwargs: dict of command parameters
|
||||
:param base_command: by default will be ccp, or taken from kwargs
|
||||
:return: list of parameters
|
||||
"""
|
||||
base_command = kwargs.pop('base_command', 'ccp')
|
||||
command_list = [base_command]
|
||||
for arg in args:
|
||||
command_list.append('--{}'.format(arg.replace('_', '-')))
|
||||
for key in kwargs:
|
||||
|
@ -95,3 +104,39 @@ class CCPManager(object):
|
|||
remote.upload(
|
||||
settings.SERVICE_PATH,
|
||||
"./microservices-repos/")
|
||||
|
||||
def do_dry_run(self, *args, **kwargs):
|
||||
"""Create yaml templates, make registry
|
||||
|
||||
:param args: passed into build_command()
|
||||
:param kwargs: passed into build_command()
|
||||
:param export_dir: taken from kwargs, contains dir for yaml templates
|
||||
:param: base_command: should be empty for getting 'dry_run'
|
||||
params without 'ccp'
|
||||
:return: None
|
||||
"""
|
||||
try:
|
||||
export_dir = kwargs.pop("export_dir")
|
||||
except KeyError:
|
||||
raise ValueError("Variable 'export_dir' is not set")
|
||||
command_list = [
|
||||
self.build_command(*args, **kwargs),
|
||||
"deploy",
|
||||
"--dry-run",
|
||||
self.build_command(export_dir=export_dir, base_command='')
|
||||
]
|
||||
command_list = ' '.join(command_list)
|
||||
command = [
|
||||
command_list,
|
||||
'kubectl create -f {0}/configmaps/ -f {0}'.format(
|
||||
os.path.join('~/', export_dir))
|
||||
]
|
||||
with self.__underlay.remote(
|
||||
host=self.__config.k8s.kube_host) as remote:
|
||||
for cmd in command:
|
||||
LOG.info("Running command '{cmd}' on node {node}".format(
|
||||
cmd=cmd,
|
||||
node=remote.hostname)
|
||||
)
|
||||
result = remote.execute(cmd)
|
||||
assert result['exit_code'] == 0
|
||||
|
|
|
@ -13,3 +13,5 @@ ccp-microservices-options:
|
|||
- images-tag: {images_tag}
|
||||
- deploy-config: {deploy_config}
|
||||
- images-namespace: {images_namespace}
|
||||
dry_run_options:
|
||||
export_dir: {export_dir}
|
||||
|
|
|
@ -27,7 +27,7 @@ LOG.addHandler(logger.console)
|
|||
|
||||
class TestServiceGlance(object):
|
||||
|
||||
@pytest.mark.revert_snapshot(ext.SNAPSHOT.initial)
|
||||
@pytest.mark.revert_snapshot(ext.SNAPSHOT.ccp_deployed)
|
||||
@pytest.mark.glance_test
|
||||
@pytest.mark.fail_snapshot
|
||||
def test_glance_api(self, config, underlay,
|
||||
|
|
|
@ -97,7 +97,9 @@ class TestDeployOpenstack(base_test.SystemBaseTest):
|
|||
data_params = yaml.load(data)['ccp-microservices-options']
|
||||
if settings.BUILD_IMAGES:
|
||||
k8scluster.create_registry(remote)
|
||||
params_list, params_dict = self.get_params(data_params, [])
|
||||
exclude_list = ['dry-run', 'export-dir']
|
||||
params_list, params_dict = self.get_params(
|
||||
data_params, exclude_list)
|
||||
with remote.get_sudo(remote):
|
||||
ccpcluster.do_build(remote, *params_list, **params_dict)
|
||||
post_install_k8s_checks.check_calico_network(remote, k8sclient)
|
||||
|
@ -106,7 +108,8 @@ class TestDeployOpenstack(base_test.SystemBaseTest):
|
|||
raise ValueError("The REGISTRY variable should be set with "
|
||||
"external registry address, "
|
||||
"current value {0}".format(settings.REGISTRY))
|
||||
exclude_list = ['builder-push', 'builder-workers']
|
||||
exclude_list = ['builder-push', 'builder-workers', 'dry-run',
|
||||
'export-dir']
|
||||
params_list, params_dict = self.get_params(data_params, exclude_list)
|
||||
with remote.get_sudo(remote):
|
||||
ccpcluster.do_deploy(*params_list, **params_dict)
|
||||
|
@ -114,3 +117,45 @@ class TestDeployOpenstack(base_test.SystemBaseTest):
|
|||
namespace='ccp')
|
||||
post_os_deploy_checks.check_pods_status(k8sclient, timeout=2500,
|
||||
namespace='ccp')
|
||||
|
||||
@pytest.mark.snapshot_needed
|
||||
@pytest.mark.revert_snapshot(ext.SNAPSHOT.k8s_deployed)
|
||||
@pytest.mark.fail_snapshot
|
||||
def test_fuel_ccp_dry_run(self, config, underlay, ccpcluster, k8scluster):
|
||||
"""Deploy base environment
|
||||
|
||||
Scenario:
|
||||
1. Revert snapshot
|
||||
2. Install microservices
|
||||
3. Create yaml templates
|
||||
4. Deploy environment
|
||||
4. Check deployment
|
||||
|
||||
Duration 35 min
|
||||
"""
|
||||
k8sclient = k8scluster.get_k8sclient()
|
||||
remote = underlay.remote(host=config.k8s.kube_host)
|
||||
self.pre_build_deploy_step(remote)
|
||||
yaml_path = os.path.join(
|
||||
os.getcwd(),
|
||||
'fuel_ccp_tests/templates/k8s_templates/build-deploy_cluster.yaml')
|
||||
with open(yaml_path, 'r') as yaml_path:
|
||||
data = yaml_path.read()
|
||||
data = data.format(registry_address='127.0.0.1:31500'
|
||||
if settings.BUILD_IMAGES else settings.REGISTRY,
|
||||
images_namespace=settings.IMAGES_NAMESPACE,
|
||||
images_tag=settings.IMAGES_TAG,
|
||||
deploy_config='~/k8s_topology.yaml',
|
||||
export_dir='tmp')
|
||||
data_params = yaml.load(data)['ccp-microservices-options']
|
||||
dry_run_params = yaml.load(data)['dry_run_options']
|
||||
exclude_list = ['builder-push', 'builder-workers']
|
||||
params_list, params_dict = self.get_params(data_params, exclude_list)
|
||||
params_dict.update(dry_run_params)
|
||||
with remote.get_sudo(remote):
|
||||
ccpcluster.do_dry_run(
|
||||
*params_list, **params_dict)
|
||||
post_os_deploy_checks.check_jobs_status(k8sclient, timeout=1500,
|
||||
namespace='default')
|
||||
post_os_deploy_checks.check_pods_status(k8sclient, timeout=2500,
|
||||
namespace='default')
|
||||
|
|
Loading…
Reference in New Issue