Пример #1
0
def test_commands(tmp_path):

    tmpdir = os.path.join(tmp_path, "repo")
    repo = "https://github.com/singularityhub/singularity-compose-examples"

    # Clone the example
    run_command(["git", "clone", repo, tmpdir])

    # Test the simple apache example
    workdir = os.path.join(tmpdir, "apache-simple")
    os.chdir(workdir)

    # Check for required files
    assert "singularity-compose.yml" in os.listdir()

    print("Creating project...")

    # Loading project validates config
    project = Project()

    print("Testing build")
    assert "httpd.sif" not in os.listdir("httpd")
    project.build()
    assert "httpd.sif" in os.listdir("httpd")

    print("Testing view config")
    project.view_config()

    print("Testing up")
    project.up()
    assert "etc.hosts" in os.listdir()
    assert "resolv.conf" in os.listdir()

    print("Waiting for instance to start")
    sleep(10)

    print("Testing logs")
    project.logs(["httpd"], tail=20)

    print("Clearing logs")
    project.clear_logs(["httpd"])
    project.logs(["httpd"], tail=20)

    print("Testing ps")
    project.ps()

    print("Testing exec")
    project.execute("httpd", ["echo", "MarsBar"])

    # Ensure running
    print(requests.get("http://127.0.0.1").status_code)

    print("Testing down")
    project.down()

    print("Testing ip lookup")
    lookup = project.get_ip_lookup(["httpd"])
    assert "httpd" in lookup
    assert lookup["httpd"] == "10.22.0.2"
Пример #2
0
def test_commands(tmp_path):

    tmpdir = os.path.join(tmp_path, 'repo')
    repo = "https://github.com/singularityhub/singularity-compose-simple"

    # Clone the example
    run_command(["git", "clone", repo, tmpdir])
    os.chdir(tmpdir)

    # Check for required files
    assert 'singularity-compose.yml' in os.listdir()

    print('Creating project...')

    # Loading project validates config
    project = Project()

    print('Testing build')
    assert 'app.sif' not in os.listdir('app')
    project.build()
    assert 'app.sif' in os.listdir('app')

    print('Testing view config')
    project.view_config()

    print('Testing up')
    project.up()
    assert 'etc.hosts' in os.listdir()
    assert 'resolv.conf' in os.listdir()

    print('Waiting for instance to start')
    sleep(10)

    print('Testing logs')
    project.logs(['app'], tail=20)

    print('Clearing logs')
    project.clear_logs(['app'])
    project.logs(['app'], tail=20)

    print('Testing ps')
    project.ps()

    print('Testing exec')
    project.execute('app', ['echo', 'MarsBar'])

    # Ensure running
    assert requests.get('http://127.0.0.1/').status_code == 200

    assert 'db.sqlite3' in os.listdir('app')

    print('Testing down')
    project.down()

    print('Testing ip lookup')
    lookup = project.get_ip_lookup(['app'])
    assert 'app' in lookup
    assert lookup['app'] == '10.22.0.2'
Пример #3
0
def main(args, parser, extra):
    '''bring one or more instances down
    '''
    # Initialize the project
    project = Project(filename=args.file,
                      name=args.project_name,
                      env_file=args.env_file)

    if args.clear:
        project.clear_logs(args.names)
    else:
        project.logs(args.names, args.tail)