def project_with_instances(built_project, start_stop_cli, request): cli = start_stop_cli project = built_project # This is necessary, because default app config has parameter `stateboard: true` remove_project_file(project, '.cartridge.yml') router = Instance('router', 8081, 'localhost:3301') s1_master = Instance('s1-master', 8082, 'localhost:3302') s1_replica = Instance('s1-replica', 8083, 'localhost:3303') s1_replica_2 = Instance('s1-replica-2', 8084, 'localhost:3304') s2_master = Instance('s2-master', 8085, 'localhost:3305') p = ProjectWithTopology( cli, project, instances_list=[ router, s1_master, s1_replica, s1_replica_2, s2_master ], ) request.addfinalizer(lambda: p.stop()) p.start() return p
def test_version_command_invalid_project(project_without_dependencies, version_cmd, cartridge_cmd, tmpdir): project = project_without_dependencies remove_project_file(project, f'{project.name}-scm-1.rockspec') cmd = [cartridge_cmd, version_cmd, "--rocks", f"--project-path={tmpdir}"] rc, output = run_command_and_get_output(cmd) assert rc == 1 assert f'Failed to show Cartridge version: Project path {tmpdir} is not a project' in output
def project_with_cartridge(cartridge_cmd, short_tmpdir): project = Project(cartridge_cmd, 'project-with-cartridge', short_tmpdir, 'cartridge') # This is necessary, because default app config has parameter `stateboard: true` remove_project_file(project, '.cartridge.yml') add_dependency_submodule(project) return project
def custom_admin_project(cartridge_cmd, short_tmpdir): project = Project(cartridge_cmd, 'admin-project', short_tmpdir, 'cartridge') remove_dependency(project, 'cartridge') # This is necessary, because default app config has parameter `stateboard: true` remove_project_file(project, '.cartridge.yml') replace_project_file(project, 'init.lua', INIT_ADMIN_FUNCS_FILEPATH) return project
def project_ignore_sigterm(cartridge_cmd, short_tmpdir): project = Project(cartridge_cmd, 'ignore-sigterm', short_tmpdir, 'cartridge') remove_all_dependencies(project) # This is necessary, because default app config has parameter `stateboard: true` remove_project_file(project, '.cartridge.yml') replace_project_file(project, 'init.lua', INIT_IGNORE_SIGTERM_FILEPATH) replace_project_file(project, 'stateboard.init.lua', INIT_IGNORE_SIGTERM_FILEPATH) return project
def project_without_dependencies(cartridge_cmd, short_tmpdir): project = Project(cartridge_cmd, 'empty-project', short_tmpdir, 'cartridge') remove_all_dependencies(project) # This is necessary, because default app config has parameter `stateboard: true` remove_project_file(project, '.cartridge.yml') replace_project_file(project, 'init.lua', INIT_NO_CARTRIDGE_FILEPATH) replace_project_file(project, 'stateboard.init.lua', INIT_NO_CARTRIDGE_FILEPATH) return project
def project_with_capital_letters_name(cartridge_cmd, short_tmpdir): project = Project(cartridge_cmd, 'App-withoutDependencies01', short_tmpdir, 'cartridge') remove_all_dependencies(project) # Remove file with Cartridge configuration, because default app # config has parameter `stateboard: true` remove_project_file(project, '.cartridge.yml') replace_project_file(project, 'init.lua', INIT_NO_CARTRIDGE_FILEPATH) replace_project_file(project, 'stateboard.init.lua', INIT_NO_CARTRIDGE_FILEPATH) return project
def built_default_project(cartridge_cmd, short_tmpdir): project = Project(cartridge_cmd, 'default-project', short_tmpdir, 'cartridge') # This is necessary, because default app config has parameter `stateboard: true` remove_project_file(project, '.cartridge.yml') # build project cmd = [ cartridge_cmd, "build", ] process = subprocess.run(cmd, cwd=project.path) assert process.returncode == 0, "Error during building the project" # don't change process title patch_cartridge_proc_titile(project) return project
def built_project_no_cartridge(cartridge_cmd, short_session_tmpdir): project = Project(cartridge_cmd, 'project-no-cartridge', short_session_tmpdir, 'cartridge') remove_dependency(project, 'cartridge') replace_project_file(project, 'init.lua', INIT_NO_CARTRIDGE_FILEPATH) remove_project_file(project, '.cartridge.yml') # build project cmd = [ cartridge_cmd, "build", ] process = subprocess.run(cmd, cwd=project.path) assert process.returncode == 0, "Error during building the project" os.remove(project.get_cfg_path()) return project
def project_with_replicaset_no_roles(cartridge_cmd, built_project, start_stop_cli, request): cli = start_stop_cli project = built_project # This is necessary, because default app config has parameter `stateboard: true` remove_project_file(project, '.cartridge.yml') instance = Instance('some-instance', 8081, 'localhost:3301') p = ProjectWithTopology( cli, project, instances_list=[instance], ) p.start() rpl = Replicaset('some-rpl', instances=[instance]) cmd = [ cartridge_cmd, 'replicasets', 'join', '--replicaset', rpl.name, ] cmd.extend([i.name for i in rpl.instances]) rc, output = run_command_and_get_output(cmd, cwd=project.path) assert rc == 0 p.set_replicasets([rpl]) request.addfinalizer(lambda: p.stop()) return p
def project_with_vshard_replicasets(cartridge_cmd, built_project, start_stop_cli, request): cli = start_stop_cli project = built_project # This is necessary, because default app config has parameter `stateboard: true` remove_project_file(project, '.cartridge.yml') router = Instance('router', 8081, 'localhost:3301') hot_master = Instance('hot-master', 8082, 'localhost:3302') hot_replica = Instance('hot-replica', 8083, 'localhost:3303') cold_master = Instance('cold-master', 8084, 'localhost:3304') VSHARD_ROUTER_ROLE = 'vshard-router' VSHARD_STORAGE_ROLE = 'vshard-storage' p = ProjectWithTopology( cli, project, instances_list=[router, hot_master, hot_replica, cold_master], ) p.start() # replicasets router_rpl = Replicaset('router', instances=[router]) hot_storage_rpl = Replicaset('hot-storage', instances=[ hot_master, hot_replica, ]) cold_storage_rpl = Replicaset('cold-storage', instances=[ cold_master, ]) # router cmd = [ cartridge_cmd, 'replicasets', 'join', '--replicaset', router_rpl.name, ] cmd.extend([i.name for i in router_rpl.instances]) rc, output = run_command_and_get_output(cmd, cwd=project.path) assert rc == 0 cmd = [ cartridge_cmd, 'replicasets', 'add-roles', '--replicaset', router_rpl.name, VSHARD_ROUTER_ROLE, ] rc, output = run_command_and_get_output(cmd, cwd=project.path) assert rc == 0 # hot-storage cmd = [ cartridge_cmd, 'replicasets', 'join', '--replicaset', hot_storage_rpl.name, ] cmd.extend([i.name for i in hot_storage_rpl.instances]) rc, output = run_command_and_get_output(cmd, cwd=project.path) assert rc == 0 cmd = [ cartridge_cmd, 'replicasets', 'add-roles', '--replicaset', hot_storage_rpl.name, '--vshard-group', 'hot', VSHARD_STORAGE_ROLE, ] rc, output = run_command_and_get_output(cmd, cwd=project.path) assert rc == 0 # cold-storage cmd = [ cartridge_cmd, 'replicasets', 'join', '--replicaset', cold_storage_rpl.name, ] cmd.extend([i.name for i in cold_storage_rpl.instances]) rc, output = run_command_and_get_output(cmd, cwd=project.path) assert rc == 0 cmd = [ cartridge_cmd, 'replicasets', 'add-roles', '--replicaset', cold_storage_rpl.name, '--vshard-group', 'cold', VSHARD_STORAGE_ROLE, ] rc, output = run_command_and_get_output(cmd, cwd=project.path) assert rc == 0 # save replicasets p.set_replicasets([router_rpl, hot_storage_rpl, cold_storage_rpl]) request.addfinalizer(lambda: p.stop()) return p