Example #1
0
def custom_admin_project(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'admin-project', short_tmpdir,
                      'cartridge')

    remove_dependency(project, 'cartridge')

    replace_project_file(project, 'init.lua', INIT_ADMIN_FUNCS_FILEPATH)

    return project
Example #2
0
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
Example #3
0
def deb_archive_with_cartridge(cartridge_cmd, tmpdir, project_with_cartridge):
    project = project_with_cartridge

    pre_install_filepath = os.path.join(tmpdir, "pre.sh")
    with open(pre_install_filepath, "w") as f:
        f.write("""
                /bin/sh -c 'touch $HOME/hello-bin-sh.txt'
                /bin/touch $HOME/hello-absolute.txt
                """)

    post_install_filepath = os.path.join(tmpdir, "post.sh")
    with open(post_install_filepath, "w") as f:
        f.write("""
                /bin/sh -c 'touch $HOME/bye-bin-sh.txt'
                /bin/touch $HOME/bye-absolute.txt
                """)

    deps_filepath = os.path.join(tmpdir, "deps.txt")
    with open(deps_filepath, "w") as f:
        f.write("unzip>1,<=7\n" +
                "stress\n" +
                "neofetch < 25")

    net_msg_max = 1024
    user_param = 'user_data'

    systemd_unit_params = os.path.join(tmpdir, "systemd-unit-params.yml")
    with open(systemd_unit_params, "w") as f:
        yaml.dump({
            "instance-env": {"net-msg-max": net_msg_max, "user-param": user_param}
        }, f)

    replace_project_file(project, 'init.lua', INIT_CHECK_PASSED_PARAMS)
    replace_project_file(project, 'stateboard.init.lua', INIT_CHECK_PASSED_PARAMS)

    cmd = [
        cartridge_cmd,
        "pack", "deb",
        "--deps-file", deps_filepath,
        "--preinst", pre_install_filepath,
        "--postinst", post_install_filepath,
        "--unit-params-file", systemd_unit_params,
        project.path,
        "--use-docker",
    ]

    process = subprocess.run(cmd, cwd=tmpdir)
    assert process.returncode == 0, \
        "Error during creating of deb archive with project"

    filepath = find_archive(tmpdir, project.name, 'deb')
    assert filepath is not None, "DEB archive isn't found in work directory"

    return Archive(filepath=filepath, project=project)
Example #4
0
def project_ignore_sigterm(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'ignore-sigterm', short_tmpdir,
                      'cartridge')

    remove_all_dependencies(project)

    replace_project_file(project, 'init.lua', INIT_IGNORE_SIGTERM_FILEPATH)
    replace_project_file(project, 'stateboard.init.lua',
                         INIT_IGNORE_SIGTERM_FILEPATH)

    return project
Example #5
0
def project_without_dependencies(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'empty-project', short_tmpdir,
                      'cartridge')

    remove_all_dependencies(project)

    replace_project_file(project, 'init.lua', INIT_NO_CARTRIDGE_FILEPATH)
    replace_project_file(project, 'stateboard.init.lua',
                         INIT_NO_CARTRIDGE_FILEPATH)

    return project
Example #6
0
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
Example #7
0
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
Example #8
0
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
Example #9
0
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)

    # 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 docker_image_print_environment(cartridge_cmd, tmpdir, project_without_dependencies, request, docker_client):
    project = project_without_dependencies
    replace_project_file(project, 'init.lua', INIT_PRINT_ENV_FILEPATH)

    cmd = [
        cartridge_cmd,
        "pack", "docker",
        "--tag", project.name,
        project.path,
    ]

    process = subprocess.run(cmd, cwd=tmpdir)
    assert process.returncode == 0, \
        "Error during creating of docker image"

    image_name = find_image(docker_client, project.name)
    assert image_name is not None, "Docker image isn't found"

    request.addfinalizer(lambda: delete_image(docker_client, image_name))

    image = Image(image_name, project)
    return image
Example #11
0
def tgz_archive_with_cartridge(cartridge_cmd, tmpdir, project_with_cartridge):
    project = project_with_cartridge
    replace_project_file(project, 'app/roles/custom.lua',
                         ROUTER_WITH_EVAL_FILEPATH)
    replace_project_file(project, 'init.lua',
                         INIT_ROLES_RELOAD_ALLOWED_FILEPATH)

    cmd = [
        cartridge_cmd,
        "pack",
        "tgz",
        project.path,
        "--use-docker",
    ]

    process = subprocess.run(cmd, cwd=tmpdir)
    assert process.returncode == 0, \
        "Error during creating of tgz archive with project"

    filepath = find_archive(tmpdir, project.name, 'tar.gz')
    assert filepath is not None, "TGZ archive isn't found in work directory"

    return Archive(filepath=filepath, project=project)
Example #12
0
def project_custom_rundir(cartridge_cmd, short_tmpdir):
    project = Project(cartridge_cmd, 'empty-project', short_tmpdir,
                      'cartridge')

    remove_all_dependencies(project)

    replace_project_file(project, '.cartridge.yml', RUNDIR_CLI_CONF)

    replace_project_file(project, 'init.lua', INIT_NO_CARTRIDGE_FILEPATH)
    replace_project_file(project, 'stateboard.init.lua',
                         INIT_NO_CARTRIDGE_FILEPATH)

    return project