Beispiel #1
0
def test_swarm():
    Containerized.start_swarm()

    client = Containerized.api_client()
    logging.debug(client.services())
    Containerized.clean_swarm()
    logging.debug(client.services())

    logging.debug(pformat(client.version()))

    api_vers = client.version()["ApiVersion"]
    logging.debug(api_vers)

    assert (len(client.services()) == 0)

    C = Containerized(dkr_name="testing",
                      dkr_image="alpine",
                      dkr_command="tail -f > /dev/null")
    C.start_service()

    assert (len(client.services()) == 1)

    logging.debug(client.services())

    assert ("testing" in client.services()[0]["Spec"]["Name"])

    C.stop_service()
Beispiel #2
0
def test_mock_svcs():

    C.start_swarm()
    C.clean_swarm()

    c = C.api_client()

    admin_stack = find_resource("platform/docker-stacks/admin/admin-stack.yml")
    cmd = ["docker", "stack", "deploy", "-c", admin_stack, "admin"]
    subprocess.run(cmd)

    service_names = [x['Spec']['Name'] for x in c.services()]

    assert ("admin_portainer" in service_names)
    assert ("admin_traefik" in service_names)

    mock_stack = find_resource(
        "platform/docker-stacks/diana-workers/mock-stack.yml")
    cmd = ["docker", "stack", "deploy", "-c", mock_stack, "mock"]

    # Don't forget to set the password, or docker-compose will
    # interpret it as empty rather than default
    os.environ["ORTHANC_PASSWORD"] = "******"
    subprocess.run(cmd)

    service_names = [x['Spec']['Name'] for x in c.services()]

    assert ("mock_diana-mock" in service_names)
    assert ("mock_orthanc-mock" in service_names)

    # Pause to generate some data
    time.sleep(20)

    O = Orthanc(path="orthanc-mock", port=80)
    info = O.gateway._get("statistics")

    # At least 100 new images in the PACS
    assert (info['CountInstances'] > 100)

    C.clean_swarm()