Exemple #1
0
def test_queue_manager_heartbeat(compute_adapter_fixture):
    """Tests to ensure tasks are returned to queue when the manager shuts down"""

    client, server, adapter = compute_adapter_fixture

    with testing.loop_in_thread() as loop:

        # Build server, manually handle IOLoop (no start/stop needed)
        server = FractalServer(
            port=testing.find_open_port(),
            storage_project_name=server.storage_database,
            storage_uri=server.storage_uri,
            loop=loop,
            ssl_options=False,
            heartbeat_frequency=0.1,
        )

        # Clean and re-init the database
        testing.reset_server_database(server)

        client = ptl.FractalClient(server)
        manager = queue.QueueManager(client, adapter)

        sman = server.list_managers(name=manager.name())
        assert len(sman) == 1
        assert sman[0]["status"] == "ACTIVE"

        # Make sure interval exceeds heartbeat time
        time.sleep(1)
        server.check_manager_heartbeats()

        sman = server.list_managers(name=manager.name())
        assert len(sman) == 1
        assert sman[0]["status"] == "INACTIVE"
Exemple #2
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)
def sec_server(request, postgres_server):
    """
    Builds a server instance with the event loop running in a thread.
    """

    storage_name = "test_qcarchivedb"
    postgres_server.create_database(storage_name)

    with testing.loop_in_thread() as loop:

        # Build server, manually handle IOLoop (no start/stop needed)
        server = qcfractal.FractalServer(
            port=testing.find_open_port(),
            storage_uri=postgres_server.database_uri(),
            storage_project_name=storage_name,
            loop=loop,
            security="local")

        # Clean and re-init the databse
        server.storage._clear_db(storage_name)

        # Add local users
        for k, v in _users.items():
            assert server.storage.add_user(k, _users[k]["pw"],
                                           _users[k]["perm"])

        yield server
Exemple #4
0
def sec_server(request):
    """
    Builds a server instance with the event loop running in a thread.
    """

    # Check mongo
    testing.check_active_mongo_server()

    storage_name = "qcf_local_server_auth_test"

    with testing.loop_in_thread() as loop:

        # Build server, manually handle IOLoop (no start/stop needed)
        server = qcfractal.FractalServer(port=testing.find_open_port(),
                                         storage_project_name=storage_name,
                                         loop=loop,
                                         security="local")

        # Clean and re-init the databse
        server.storage.client.drop_database(server.storage._project_name)

        # Add local users
        for k, v in _users.items():
            assert server.storage.add_user(k, _users[k]["pw"],
                                           _users[k]["perm"])

        yield server
Exemple #5
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)
Exemple #6
0
def active_server(request):
    port = str(testing.find_open_port())
    args = ["qcfractal-server", "mydb", "--port=" + port]
    with testing.popen(args, **_options) as server:
        time.sleep(2)

        server.test_uri_cli = "--fractal-uri=localhost:" + port
        yield server
Exemple #7
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
def sec_server_allow_read(sec_server, postgres_server):
    """
    New sec server with read allowed
    """
    yield qcfractal.FractalServer(name="qcf_server_allow_read",
                                  port=testing.find_open_port(),
                                  storage_project_name=sec_server.storage.get_project_name(),
                                  storage_uri=postgres_server.database_uri(),
                                  loop=sec_server.loop,
                                  security="local",
                                  allow_read=True)
Exemple #9
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)
Exemple #10
0
def test_start_stop():

    with pristine_loop() as loop:

        # Build server, manually handle IOLoop (no start/stop needed)
        server = FractalServer(port=find_open_port(),
                               storage_project_name="something",
                               io_loop=loop,
                               ssl_options=False)

        thread = threading.Thread(target=server.start, name="test IOLoop")
        thread.daemon = True
        thread.start()

        loop_started = threading.Event()
        loop.add_callback(loop_started.set)
        loop_started.wait()

        try:
            loop.add_callback(server.stop)
            thread.join(timeout=5)
        except:
            pass
Exemple #11
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)
Exemple #12
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)