def before_all(context): mongo_uri = 'mongodb://{0}:27017/deployer'.format(os.getenv("MONGO_HOST", 'localhost')) Context(context).set_mongo_uri(mongo_uri) __build_apps(context) os.environ['TARGET_ENV'] = TARGET_ENV os.environ['REST_API_ID'] = 'y404vvoq21' if __is_aws_mode(context): context.aws_uri = "911479539546.dkr.ecr.us-east-1.amazonaws.com/" context.minikube = None __push_apps_aws(Context(context).all_apps()) context.domain = "heed-dev.io" else: K8sDriver.add_node_label('type', 'node') context.minikube = subprocess.check_output('minikube ip', shell=True)[:-1] context.aws_uri = '' context.domain = "minikube"
def __create_namespace(context): namespace = __create_namespace_name().lower() print ("namespace:%s" % namespace) k8s = K8sDriver(namespace, context.minikube) k8s.create_namespace() Context(context).set_default_namespace(namespace) k8s.upload_config_folder('global-configs') k8s.upload_config('log4j.xml', 'log4j', 'log4j2.xml') k8s.create_secret('features/config/secret.yml', namespace) k8s.deploy('features/support/deployer-shell.yml')
def service_updated(context, name, version): K8sDriver(Context(context).default_namespace()).verify_get( '%s/version' % url_for(Context(context).get_app_for(name, version)), lambda response: json.loads(response)['version'] == version)
def should_have_ingress(context): service_name = context.config.userdata['lastDeployed']._service_name K8sDriver(Context(context).default_namespace()).has_ingress(service_name)
def should_exist_autoscaler(context): service_name = context.config.userdata['lastDeployed']._service_name K8sDriver( Context(context).default_namespace()).has_autoscaler(service_name)
def service_is_serving(context, service_name): K8sDriver(Context(context).default_namespace()).wait_to_serve( context.config.userdata['apps'][service_name])
def after_scenario(context, scenario): for ns in Context(context).pop_namespaces_to_delete(): K8sDriver(ns).delete_namespace()
def jobs_were_invoked_on_service(context, service, version): K8sDriver(Context(context).default_namespace()).verify_get( '%s/state' % url_for(Context(context).get_app_for(service, version)), lambda output: json.loads(output)['state'] )
def validate_config_uploaded(context, config_name, namespace=None): ns = Context(context).default_namespace() if namespace is None else namespace K8sDriver(ns, context.minikube).verify_config_is(LocalConfig(config_name).content())
def validate_config_uploaded(context, config_folder, namespace=None): ns = Context(context).default_namespace() if namespace is None else namespace K8sDriver(ns, context.minikube).verify_all_configs_in_folder(LocalConfig(config_folder).get_path())
def clear_namespace(context, namespace): K8sDriver(namespace, context.minikube).delete_namespace() Context(context).add_namespace_to_delete(namespace)
def verify_port_available(context): K8sDriver(Context(context).default_namespace()).verify_get( '%s/greet' % url_for(Context(context).last_deployed_app(), 5000), lambda output: output == "Hello Ported")
def pod_running(context): K8sDriver(Context(context).default_namespace(), context.minikube).verify_app_is_running( Context(context).last_deployed_app())
def verify_config_was_overriden(context): K8sDriver(Context(context).default_namespace()).verify_get( '%s/greeting' % url_for(Context(context).last_deployed_app()), lambda output: output == 'Hello overridden world')
def upload_config(context, config_name): K8sDriver(Context(context).default_namespace(), context.minikube).upload_config_folder(config_name)