def test_pod_with_container_bridge_network(): """Tests creation of a pod with a "container/bridge" network, and its HTTP endpoint accessibility.""" pod_def = pods.container_bridge_pod() pod_id = pod_def['id'] # In strict mode all tasks are started as user `nobody` by default and `nobody` # doesn't have permissions to write to /var/log within the container. if shakedown.ee_version() == 'strict': pod_def['user'] = '******' common.add_dcos_marathon_user_acls() client = marathon.create_client() client.add_pod(pod_def) common.deployment_wait(service_id=pod_id) task = common.get_pod_tasks(pod_id)[0] network_info = task['statuses'][0]['container_status']['network_infos'][0] assert network_info['name'] == "mesos-bridge", \ "The network is {}, but mesos-bridge was expected".format(network_info['name']) # get the port on the host port = task['discovery']['ports']['ports'][0]['number'] # the agent IP:port will be routed to the bridge IP:port # test against the agent_ip, however it is hard to get.. translating from # slave_id agent_ip = common.agent_hostname_by_id(task['slave_id']) assert agent_ip is not None, "Failed to get the agent IP address" container_ip = network_info['ip_addresses'][0]['ip_address'] assert agent_ip != container_ip, "The container IP address is the same as the agent one" url = "http://{}:{}/".format(agent_ip, port) common.assert_http_code(url)
def test_pod_container_bridge(): """ Tests using "container" network (using default network "dcos") """ client = marathon.create_client() pod_id = "/pod-container-bridge-{}".format(uuid.uuid4().hex) pod_json = _pods_json('pod-container-bridge.json') pod_json["id"] = pod_id client.add_pod(pod_json) shakedown.deployment_wait() task = get_pod_tasks(pod_id)[0] network_info = task['statuses'][0]['container_status']['network_infos'][0] assert network_info['name'] == "mesos-bridge" # port on the host port = task['discovery']['ports']['ports'][0]['number'] # the agent IP:port will be routed to the bridge IP:port # test against the agent_ip, however it is hard to get.. translating from # slave_id agent_ip = common.agent_hostname_by_id(task['slave_id']) assert agent_ip is not None container_ip = network_info['ip_addresses'][0]['ip_address'] assert agent_ip != container_ip # assert container_ip is not None # url = "http://{}:{}/".format(agent_ip, port) common.assert_http_code(url)
def test_vip_docker_bridge_mode(marathon_service_name): """ Tests the creation of a VIP from a python command in a docker image using bridge mode. the test validates the creation of an app with the VIP label and the accessability of the service via the VIP. """ vip_name = 'vip-docker-service' fqn = '{}.{}.l4lb.thisdcos.directory'.format(vip_name, marathon_service_name) app_def = app_docker() app_def['container']['docker']['portMappings'] = [ { "containerPort": 8080, "hostPort": 0, "labels": { "VIP_0": "/{}:10000".format(vip_name) }, "protocol": "tcp", "name": "{}".format(vip_name) } ] app_def['id'] = vip_name client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() common.assert_http_code('{}:{}'.format(fqn, 10000))
def test_pod_with_container_network(): """Tests creation of a pod with a "container" network, and its HTTP endpoint accessibility.""" pod_def = pods.container_net_pod() pod_id = pod_def['id'] # In strict mode all tasks are started as user `nobody` by default and `nobody` # doesn't have permissions to write to /var/log within the container. if shakedown.ee_version() == 'strict': pod_def['user'] = '******' common.add_dcos_marathon_user_acls() client = marathon.create_client() client.add_pod(pod_def) common.deployment_wait(service_id=pod_id) tasks = common.get_pod_tasks(pod_id) network_info = tasks[0]['statuses'][0]['container_status'][ 'network_infos'][0] assert network_info['name'] == "dcos", \ "The network name is {}, but 'dcos' was expected".format(network_info['name']) container_ip = network_info['ip_addresses'][0]['ip_address'] assert container_ip is not None, "No IP address has been assigned to the pod's container" url = "http://{}:80/".format(container_ip) common.assert_http_code(url)
def test_vip_docker_bridge_mode(marathon_service_name): """ Tests the creation of a VIP from a python command in a docker image using bridge mode. the test validates the creation of an app with the VIP label and the accessability of the service via the VIP. """ vip_name = 'vip-docker-service' fqn = '{}.{}.l4lb.thisdcos.directory'.format(vip_name, marathon_service_name) app_def = app_docker() app_def['container']['docker']['portMappings'] = [{ "containerPort": 8080, "hostPort": 0, "labels": { "VIP_0": "/{}:10000".format(vip_name) }, "protocol": "tcp", "name": "{}".format(vip_name) }] app_def['id'] = vip_name client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() common.assert_http_code('{}:{}'.format(fqn, 10000))
def test_pod_with_container_bridge_network(): """Tests creation of a pod with a "container/bridge" network, and its HTTP endpoint accessibility.""" pod_def = pods.container_bridge_pod() client = marathon.create_client() client.add_pod(pod_def) shakedown.deployment_wait() task = common.get_pod_tasks(pod_def["id"])[0] network_info = task['statuses'][0]['container_status']['network_infos'][0] assert network_info['name'] == "mesos-bridge", \ "The network is {}, but mesos-bridge was expected".format(network_info['name']) # get the port on the host port = task['discovery']['ports']['ports'][0]['number'] # the agent IP:port will be routed to the bridge IP:port # test against the agent_ip, however it is hard to get.. translating from # slave_id agent_ip = common.agent_hostname_by_id(task['slave_id']) assert agent_ip is not None, "Failed to get the agent IP address" container_ip = network_info['ip_addresses'][0]['ip_address'] assert agent_ip != container_ip, "The container IP address is the same as the agent one" url = "http://{}:{}/".format(agent_ip, port) common.assert_http_code(url)
def test_pod_with_container_bridge_network(): """Tests creation of a pod with a "container/bridge" network, and its HTTP endpoint accessibility.""" pod_def = pods.container_bridge_pod() pod_id = pod_def['id'] # In strict mode all tasks are started as user `nobody` by default and `nobody` # doesn't have permissions to write to /var/log within the container. if shakedown.ee_version() == 'strict': pod_def['user'] = '******' common.add_dcos_marathon_user_acls() client = marathon.create_client() client.add_pod(pod_def) common.deployment_wait(service_id=pod_id) task = common.task_by_name(common.get_pod_tasks(pod_id), "nginx") network_info = common.running_status_network_info(task['statuses']) assert network_info['name'] == "mesos-bridge", \ "The network is {}, but mesos-bridge was expected".format(network_info['name']) # get the port on the host port = task['discovery']['ports']['ports'][0]['number'] # the agent IP:port will be routed to the bridge IP:port # test against the agent_ip, however it is hard to get.. translating from # slave_id agent_ip = common.agent_hostname_by_id(task['slave_id']) assert agent_ip is not None, "Failed to get the agent IP address" container_ip = network_info['ip_addresses'][0]['ip_address'] assert agent_ip != container_ip, "The container IP address is the same as the agent one" url = "http://{}:{}/".format(agent_ip, port) common.assert_http_code(url)
def test_pod_with_container_network(): """Tests creation of a pod with a "container" network, and its HTTP endpoint accessibility.""" pod_def = pods.container_net_pod() pod_id = pod_def['id'] # In strict mode all tasks are started as user `nobody` by default and `nobody` # doesn't have permissions to write to /var/log within the container. if shakedown.ee_version() == 'strict': pod_def['user'] = '******' common.add_dcos_marathon_user_acls() client = marathon.create_client() client.add_pod(pod_def) common.deployment_wait(service_id=pod_id) task = common.task_by_name(common.get_pod_tasks(pod_id), "nginx") network_info = common.running_status_network_info(task['statuses']) assert network_info['name'] == "dcos", \ "The network name is {}, but 'dcos' was expected".format(network_info['name']) container_ip = network_info['ip_addresses'][0]['ip_address'] assert container_ip is not None, "No IP address has been assigned to the pod's container" url = "http://{}:80/".format(container_ip) common.assert_http_code(url)
def test_pod_container_network(): """ Tests using "container" network (using default network "dcos") """ client = marathon.create_client() pod_id = "/pod-container-net-{}".format(uuid.uuid4().hex) pod_json = _pods_json('pod-container-net.json') pod_json["id"] = pod_id client.add_pod(pod_json) shakedown.deployment_wait() tasks = get_pod_tasks(pod_id) network_info = tasks[0]['statuses'][0]['container_status']['network_infos'][0] assert network_info['name'] == "dcos" container_ip = network_info['ip_addresses'][0]['ip_address'] assert container_ip is not None url = "http://{}:80/".format(container_ip) common.assert_http_code(url)
def test_pod_with_container_network(): """Tests creation of a pod with a "container" network, and its HTTP endpoint accessibility.""" pod_def = pods.container_net_pod() client = marathon.create_client() client.add_pod(pod_def) shakedown.deployment_wait() tasks = common.get_pod_tasks(pod_def["id"]) network_info = tasks[0]['statuses'][0]['container_status'][ 'network_infos'][0] assert network_info['name'] == "dcos", \ "The network name is {}, but 'dcos' was expected".format(network_info['name']) container_ip = network_info['ip_addresses'][0]['ip_address'] assert container_ip is not None, "No IP address has been assigned to the pod's container" url = "http://{}:80/".format(container_ip) common.assert_http_code(url)
def test_vip_mesos_cmd(marathon_service_name): """ Tests the creation of a VIP from a python command NOT in a docker. the test validates the creation of an app with the VIP label and the accessability of the service via the VIP. """ vip_name = 'vip-service' fqn = '{}.{}.l4lb.thisdcos.directory'.format(vip_name, marathon_service_name) app_def = python_http_app() app_def['portDefinitions'] = [{ "port": 0, "protocol": "tcp", "name": "{}".format(vip_name), "labels": { "VIP_0": "/{}:10000".format(vip_name) } }] app_def['id'] = vip_name client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() common.assert_http_code('{}:{}'.format(fqn, 10000))
def test_vip_mesos_cmd(marathon_service_name): """ Tests the creation of a VIP from a python command NOT in a docker. the test validates the creation of an app with the VIP label and the accessability of the service via the VIP. """ vip_name = 'vip-service' fqn = '{}.{}.l4lb.thisdcos.directory'.format(vip_name, marathon_service_name) app_def = python_http_app() app_def['portDefinitions'] = [ { "port": 0, "protocol": "tcp", "name": "{}".format(vip_name), "labels": { "VIP_0": "/{}:10000".format(vip_name) } } ] app_def['id'] = vip_name client = marathon.create_client() client.add_app(app_def) shakedown.deployment_wait() common.assert_http_code('{}:{}'.format(fqn, 10000))
def http_output_check(stop_max_attempt_number=30): common.assert_http_code('{}:{}'.format(fqn, 10000))
def http_output_check(): time.sleep(1) common.assert_http_code('{}:{}'.format(fqn, 10000))
def http_output_check(): time.sleep(1) common.assert_http_code('{}:{}'.format(fqn, 10000))