Example #1
0
def test_postgres_instance(multi_postgres):
    run_storage_conn_string, event_log_storage_conn_string = multi_postgres

    run_storage = PostgresRunStorage.create_clean_storage(
        run_storage_conn_string)
    event_storage = PostgresEventLogStorage.create_clean_storage(
        event_log_storage_conn_string)

    with seven.TemporaryDirectory() as temp_dir:
        instance = DagsterInstance(
            instance_type=InstanceType.PERSISTENT,
            local_artifact_storage=LocalArtifactStorage(temp_dir),
            run_storage=run_storage,
            event_storage=event_storage,
            compute_log_manager=LocalComputeLogManager(temp_dir),
        )

        result = execute_pipeline(simple, instance=instance)

        assert run_storage.has_run(result.run_id)
        assert run_storage.get_run_by_id(
            result.run_id).status == PipelineRunStatus.SUCCESS
        assert DagsterEventType.PIPELINE_SUCCESS in [
            event.dagster_event.event_type
            for event in event_storage.get_logs_for_run(result.run_id)
            if event.is_dagster_event
        ]
        stats = event_storage.get_stats_for_run(result.run_id)
        assert stats.steps_succeeded == 1
        assert stats.end_time is not None
    def clean_run_storage(conn_string):
        check.invariant(
            TestPostgresInstance.dagster_postgres_installed(),
            "dagster_postgres must be installed to test with postgres",
        )
        from dagster_postgres.run_storage import PostgresRunStorage  # pylint: disable=import-error

        storage = PostgresRunStorage.create_clean_storage(conn_string)
        assert storage
        return storage
Example #3
0
def clean_storage(conn_string):  # pylint: disable=redefined-outer-name
    storage = PostgresRunStorage.create_clean_storage(conn_string)
    assert storage
    return storage
Example #4
0
 def run_storage(self, conn_string):  # pylint: disable=arguments-differ
     storage = PostgresRunStorage.create_clean_storage(conn_string)
     assert storage
     return storage