def test_docker(docker_image_with_cartridge, docker_client, request): image_name = docker_image_with_cartridge.name project = docker_image_with_cartridge.project instance_name = 'instance-1' http_port = '8182' advertise_port = '3302' environment = [ 'TARANTOOL_APP_NAME=%s' % project.name, 'TARANTOOL_INSTANCE_NAME=%s' % instance_name, 'TARANTOOL_ADVERTISE_URI=%s' % advertise_port, 'TARANTOOL_HTTP_PORT=%s' % http_port, ] container = docker_client.containers.run( image_name, environment=environment, ports={http_port: http_port}, name='{}-{}'.format(project.name, instance_name), detach=True, ) request.addfinalizer(lambda: container.remove(force=True)) assert container.status == 'created' examine_application_instance_container( InstanceContainer(container=container, instance_name=instance_name, http_port=http_port, advertise_port=advertise_port)) container.stop()
def test_tgz(instance_container_with_unpacked_tgz): container = instance_container_with_unpacked_tgz.container container.start() assert container.status == 'created' examine_application_instance_container(instance_container_with_unpacked_tgz) container.stop()
def test_version_update_at_roles_reload(instance_container_with_unpacked_tgz): container = instance_container_with_unpacked_tgz.container container.start() assert container.status == 'created' examine_application_instance_container( instance_container_with_unpacked_tgz) headers = {'content-type': 'application/json'} http_port = instance_container_with_unpacked_tgz.http_port r = requests.put(f"http://localhost:{http_port}/eval", data=json.dumps( {"eval_string": "return require('VERSION')"}), headers=headers) assert '0.1.0.0' in r.json()['data'] # Update VERSION.lua file new_project_version = 100500 version_lua_filepath = "/opt/${TARANTOOL_APP_NAME}/VERSION.lua" run_command_on_container( container, f"echo 'return {new_project_version}' > {version_lua_filepath}") # Reload cartridge r = requests.put(f"http://localhost:{http_port}/eval", data=json.dumps({ "eval_string": "return require('cartridge').reload_roles()" }), headers=headers) assert r.json()['data'] # Try with new VERSION.lua file r = requests.put(f"http://localhost:{http_port}/eval", data=json.dumps( {"eval_string": "return require('VERSION')"}), headers=headers) assert r.json()['data'] == new_project_version container.stop()
def test_custom_directories(docker_image_with_cartridge, docker_client, request): image_name = docker_image_with_cartridge.name project = docker_image_with_cartridge.project instance_name = 'instance-1' http_port = '8182' advertise_port = '3302' run_dir = "/var/lib/tarantool/custom_run" data_dir = "/var/lib/tarantool/custom_data" environment = [ f"TARANTOOL_APP_NAME={project.name}", f"TARANTOOL_INSTANCE_NAME={instance_name}", f"TARANTOOL_ADVERTISE_URI={advertise_port}", f"TARANTOOL_HTTP_PORT={http_port}", f"CARTRIDGE_RUN_DIR={run_dir}", f"CARTRIDGE_DATA_DIR={data_dir}", ] container = docker_client.containers.run( image_name, environment=environment, ports={http_port: http_port}, name='{}-{}'.format(project.name, instance_name), detach=True, ) request.addfinalizer(lambda: container.remove(force=True)) assert container.status == 'created' examine_application_instance_container( InstanceContainer(container=container, instance_name=instance_name, http_port=http_port, advertise_port=advertise_port)) container.stop()