Exemplo n.º 1
0
def test_compute_log_subscription(mock_watch_completed):
    mock_watch_completed.return_value = False

    schema = create_schema()
    server = DagsterSubscriptionServer(schema=schema)

    with instance_for_test() as instance:
        run = execute_pipeline(example_pipeline, instance=instance)
        assert run.success
        assert run.run_id

        with create_subscription_context(instance) as context:
            start_subscription(
                server,
                context,
                COMPUTE_LOG_SUBSCRIPTION,
                {
                    "runId": run.run_id,
                    "stepKey": "example_solid",
                    "ioType": "STDERR",
                },
            )
            gc.collect()
            assert len(objgraph.by_type("SubscriptionObserver")) == 1
            assert len(objgraph.by_type("ComputeLogSubscription")) == 1
            end_subscription(server, context)
            gc.collect()
            assert len(objgraph.by_type("SubscriptionObserver")) == 0
            assert len(objgraph.by_type("ComputeLogSubscription")) == 0
Exemplo n.º 2
0
def test_event_log_subscription_chunked():
    schema = create_schema()
    server = DagsterSubscriptionServer(schema=schema)

    with instance_for_test() as instance, environ(
        {"DAGIT_EVENT_LOAD_CHUNK_SIZE": "2"}):
        run = execute_pipeline(example_pipeline, instance=instance)
        assert run.success
        assert run.run_id

        with create_subscription_context(instance) as context:
            start_subscription(server, context, EVENT_LOG_SUBSCRIPTION,
                               {"runId": run.run_id})
            gc.collect()
            assert len(objgraph.by_type("SubscriptionObserver")) == 1
            subs = objgraph.by_type("PipelineRunObservableSubscribe")
            assert len(subs) == 1
            subscription_obj = subs[0]
            end_subscription(server, context)
            subscription_obj.stopped.wait(30)
            subs = None
            subscription_obj = None
            gc.collect()

            assert len(objgraph.by_type("SubscriptionObserver")) == 0
            assert len(objgraph.by_type("PipelineRunObservableSubscribe")) == 0
Exemplo n.º 3
0
def test_generic_subscriptions():
    server = DagsterSubscriptionServer(schema=None)
    with instance_for_test() as instance:
        with create_subscription_context(instance) as context:
            start_subscription(server, context)
            gc.collect()
            assert len(objgraph.by_type("SubscriptionObserver")) == 1
            end_subscription(server, context)
            gc.collect()
            assert len(objgraph.by_type("SubscriptionObserver")) == 0
Exemplo n.º 4
0
def test_event_log_subscription():
    schema = create_schema()
    server = DagsterSubscriptionServer(schema=schema)

    with instance_for_test() as instance:
        run = execute_pipeline(example_pipeline, instance=instance)
        assert run.success
        assert run.run_id

        with create_subscription_context(instance) as context:
            start_subscription(server, context, EVENT_LOG_SUBSCRIPTION,
                               {"runId": run.run_id})
            gc.collect()
            assert len(objgraph.by_type("SubscriptionObserver")) == 1
            assert len(objgraph.by_type("PipelineRunObservableSubscribe")) == 1
            end_subscription(server, context)
            gc.collect()
            assert len(objgraph.by_type("SubscriptionObserver")) == 0
            assert len(objgraph.by_type("PipelineRunObservableSubscribe")) == 0