Пример #1
0
def test_fireworks_server_example():
    """Make sure the Fireworks example works as intended"""

    testing.check_active_mongo_server()

    kwargs = {"dump_stdout": True}

    with testing.preserve_cwd():
        os.chdir(os.path.join(_pwd, "fireworks_dataset"))
        server_args = [
            "qcfractal-server", "qca_fw_testing", "--fireworks-manager"
        ]
        with testing.popen(server_args, **kwargs) as server:
            time.sleep(5)  # Boot up server

            assert testing.run_process(["python", "build_database.py"],
                                       **kwargs)
            assert testing.run_process(["python", "compute_database.py"],
                                       **kwargs)

            time.sleep(3)  # Ensure tasks are pushed to QueueManager
            assert testing.run_process(
                ["rlaunch", "-l", "fw_lpad.yaml", "rapidfire"], **kwargs)

            time.sleep(3)  # Ensure all tasks are gathered
            assert testing.run_process(["python", "query_database.py"],
                                       **kwargs)
Пример #2
0
def test_cli_user_modify(qcfractal_base_init):
    args = [
        "qcfractal-server", "user", qcfractal_base_init, "add",
        "test_user_modify", "--permissions", "read"
    ]
    assert testing.run_process(args, **_options)

    args = [
        "qcfractal-server", "user", qcfractal_base_init, "modify",
        "test_user_modify", "--permissions", "read", "write",
        "--reset-password"
    ]
    assert testing.run_process(args, **_options)

    args = [
        "qcfractal-server", "user", qcfractal_base_init, "modify",
        "test_user_modify", "--password", "foopass"
    ]
    assert testing.run_process(args, **_options)

    args = [
        "qcfractal-server", "user", qcfractal_base_init, "modify",
        "test_user_modify", "--permissions", "read"
    ]
    assert testing.run_process(args, **_options)

    args = [
        "qcfractal-server", "user", qcfractal_base_init, "modify",
        "badname_1234"
    ]
    assert testing.run_process(args, **_options) is False
Пример #3
0
def test_cli_user_remove(qcfractal_base_init):
    args = ["qcfractal-server", "user", qcfractal_base_init, "add", "test_user_remove", "--permissions", "admin"]
    assert testing.run_process(args, **_options)

    args = ["qcfractal-server", "user", qcfractal_base_init, "remove", "test_user_remove"]
    assert testing.run_process(args, **_options)

    args = ["qcfractal-server", "user", qcfractal_base_init, "remove", "badname_1234"]
    assert testing.run_process(args, **_options) is False
Пример #4
0
def test_cli_user_add(qcfractal_base_init):
    args = ["qcfractal-server", "user", qcfractal_base_init, "add", "test_user_add_1", "--permissions", "admin"]
    assert testing.run_process(args, **_options)

    args = ["qcfractal-server", "user", qcfractal_base_init, "add", "test_user_add_1", "--permissions", "admin"]
    assert testing.run_process(args, **_options) is False

    args = ["qcfractal-server", "user", qcfractal_base_init, "add", "test_user_add_2", "--password", "foo",
            "--permissions", "admin"]
    assert testing.run_process(args, **_options)

    args = ["qcfractal-server", "user", qcfractal_base_init, "add", "test_user_add_3"]
    assert testing.run_process(args, **_options) is False
Пример #5
0
def test_with_api_logging(postgres_server, log_apis):

    tmpdir = tempfile.TemporaryDirectory()

    args = [
        "qcfractal-server", "init", "--base-folder",
        str(tmpdir.name), "--db-own=False", "--clear-database",
        f"--db-port={postgres_server.config.database.port}",
        f"--log-apis={log_apis}"
    ]
    assert testing.run_process(args, **_options)

    port = "--port=" + str(testing.find_open_port())
    args = ["qcfractal-server", "start", f"--base-folder={tmpdir.name}", port]
    assert testing.run_process(args, interupt_after=10, **_options)
Пример #6
0
def test_manager_fireworks_config_boot(active_server):
    config_path = os.path.join(_pwd, "fw_config_boot.yaml")
    args = [
        "qcfractal-manager", active_server.test_uri_cli, "--rapidfire",
        "--config-file=" + config_path, "fireworks"
    ]
    assert testing.run_process(args, **_options)
Пример #7
0
def test_cli_server_local_boot(qcfractal_base_init):
    port = "--port=" + str(testing.find_open_port())
    args = [
        "qcfractal-server", "start", "--local-manager=1", port,
        qcfractal_base_init
    ]
    assert testing.run_process(args, interupt_after=10, **_options)
Пример #8
0
def test_cli_template_generator(adapter, scheduler, tmp_path):
    if adapter == "parsl" and scheduler == "lsf":
        pytest.xfail("Parsl has no LSF implementation")

    tmpl_path = tmp_path / "tmp_template.py"
    args = [
        "qcfractal-template", adapter, scheduler, "--test", "-o",
        str(tmpl_path)
    ]
    testing.run_process(args)

    with open(tmpl_path, 'r') as handle:
        data = handle.read()

    # Will throw a syntax error if incorrect
    c = ast.parse(data)
Пример #9
0
def test_cli_server_boot(qcfractal_base_init):
    port = "--port=" + str(testing.find_open_port())
    args = [
        "qcfractal-server", "start", qcfractal_base_init,
        "--database-name=test_cli_db", port
    ]
    assert testing.run_process(args, interupt_after=10, **_options)
Пример #10
0
def test_local_server_example():
    """Make sure the Fireworks example works as intended"""

    testing.check_active_mongo_server()

    kwargs = {"dump_stdout": True}

    with testing.preserve_cwd():
        os.chdir(os.path.join(_pwd, "local_dataset"))
        server_args = ["qcfractal-server", "qca_local_testing", "--local-manager"]
        with testing.popen(server_args, **kwargs) as server:
            time.sleep(5)  # Boot up server

            assert testing.run_process(["python", "build_database.py"], **kwargs)
            assert testing.run_process(["python", "compute_database.py"], **kwargs)

            assert wait_true(40, testing.run_process, ["python", "query_database.py"], **kwargs)
Пример #11
0
def active_server(request, qcfractal_base_init):
    port = str(testing.find_open_port())
    args = ["qcfractal-server", "start", qcfractal_base_init, f"--port={port}"]
    assert testing.run_process(args, interupt_after=10, **_options)
    with testing.popen(args, **_options) as server:
        time.sleep(2)

        server.test_uri_cli = "--fractal-uri=localhost:" + port
        yield server
Пример #12
0
def qcfractal_base_init(postgres_server):

    tmpdir = tempfile.TemporaryDirectory()

    args = [
        "qcfractal-server", "init", "--base-folder",
        str(tmpdir.name), "--db-own=False", "--clear-database",
        f"--db-port={postgres_server.config.database.port}"
    ]
    assert testing.run_process(args, **_options)

    yield f"--base-folder={tmpdir.name}"
Пример #13
0
def test_manager_executor_manager_boot_from_file(active_server, tmp_path):

    yaml_file = """
    common:
        adapter: pool
        tasks_per_worker: 4
        cores_per_worker: 4
    server:
        fractal_uri: {}
        verify: False
    """.format(active_server.test_uri_cli.split("=")[1])

    p = tmp_path / "config.yaml"
    p.write_text(yaml_file)

    args = ["qcfractal-manager", "--config-file={}".format(p)]
    assert testing.run_process(args, interupt_after=7, **_options)
Пример #14
0
def test_parsl_server_example():
    """Make sure the Parsl example works as intended"""

    testing.check_active_mongo_server()

    kwargs = {"dump_stdout": True}

    with testing.preserve_cwd():
        os.chdir(os.path.join(_pwd, "parsl_torsiondrive"))
        server_args = ["qcfractal-server", "qca_parsl_testing"]
        with testing.popen(server_args, **kwargs) as server:
            time.sleep(5)  # Boot up server

            manager_args = ["python", "parsl_manager.py"]
            with testing.popen(manager_args, **kwargs) as manager:

                assert testing.run_process(["python", "compute_torsion.py"],
                                           **kwargs)
                assert wait_true(40, testing.run_process,
                                 ["python", "query_torsion.py"], **kwargs)
Пример #15
0
def test_cli_server_boot():
    port = "--port=" + str(testing.find_open_port())
    assert testing.run_process(["qcfractal-server", "mydb", port],
                               interupt_after=10,
                               **_options)
Пример #16
0
def test_cli_upgrade(qcfractal_base_init):
    args = ["qcfractal-server", "upgrade", qcfractal_base_init]
    assert testing.run_process(args, interupt_after=10, **_options)
Пример #17
0
def test_cli_managers_skel(tmp_path):
    """Test that qcfractal_manager --skeleton works"""
    config = tmp_path / "config.yaml"
    args = ["qcfractal-manager", "--skel", config.as_posix()]
    testing.run_process(args, **_options)
Пример #18
0
def test_cli_managers_schema():
    """Test that qcfractal_manager --schema works"""
    args = ["qcfractal-manager", "--schema"]
    testing.run_process(args, **_options)
Пример #19
0
def test_cli_managers_help():
    """Test that qcfractal_manager --help works"""
    args = ["qcfractal-manager", "--help"]
    testing.run_process(args, **_options)
Пример #20
0
def cli_manager_runs(config_data, tmp_path):
    temp_config = tmp_path / "temp_config.yaml"
    temp_config.write_text(yaml.dump(config_data))
    args = ["qcfractal-manager", f"--config-file={temp_config}", "--test"]
    assert testing.run_process(args, **_options)
Пример #21
0
def test_manager_executor_manager_boot(active_server):
    args = [
        "qcfractal-manager", active_server.test_uri_cli, "--adapter=pool", "--tasks-per-worker=2", "--verify=False"
    ]
    assert testing.run_process(args, interupt_after=7, **_options)
Пример #22
0
def test_manager_local_testing_process():
    assert testing.run_process(["qcfractal-manager", "--adapter=pool", "--test", "--tasks-per-worker=2"], **_options)
Пример #23
0
def test_cli_server_dask_boot():
    port = "--port=" + str(testing.find_open_port())
    args = ["qcfractal-server", "mydb", "--dask-manager-single", port]
    assert testing.run_process(args, interupt_after=10, **_options)
Пример #24
0
def test_manager_dask_manager_local_boot(active_server):
    args = [
        "qcfractal-manager", active_server.test_uri_cli, "dask",
        "--local-cluster", "--local-workers=1"
    ]
    assert testing.run_process(args, interupt_after=7, **_options)
Пример #25
0
def test_manager_fireworks_boot(active_server):
    args = ["qcfractal-manager", active_server.test_uri_cli, "fireworks"]
    assert testing.run_process(args, interupt_after=5, **_options)