Back to Repositories

Testing gRPC-PostgreSQL Integration Workflow in Conductor OSS

This test suite implements end-to-end integration testing for Conductor’s gRPC interface with PostgreSQL persistence. It validates the complete workflow execution pipeline through gRPC endpoints while ensuring proper PostgreSQL database integration and configuration.

Test Coverage Overview

The test suite provides comprehensive coverage of Conductor’s gRPC interface integration with PostgreSQL.

Key areas tested include:
  • Workflow execution through gRPC endpoints
  • Task management and coordination
  • Metadata operations
  • Event handling mechanisms
  • PostgreSQL persistence layer integration

Implementation Analysis

The testing approach utilizes Spring’s test framework with JUnit4, leveraging TestPropertySource for extensive configuration control. The implementation extends AbstractGrpcEndToEndTest while initializing specific gRPC clients for tasks, workflows, metadata, and events, ensuring complete API coverage.

Notable patterns include:
  • TestContainers integration for PostgreSQL instance management
  • Spring Runner configuration for dependency injection
  • Hikari connection pool configuration
  • Experimental queue notification settings

Technical Details

Testing tools and configuration:
  • JUnit4 testing framework
  • Spring Test context framework
  • TestContainers for PostgreSQL 11.15
  • gRPC server configuration on port 8098
  • Hikari connection pool settings
  • Flyway migration controls
  • Elasticsearch indexing configuration

Best Practices Demonstrated

The test implementation showcases several testing best practices for enterprise-grade applications.

Notable practices include:
  • Isolated database testing using TestContainers
  • Comprehensive client initialization in setup phase
  • Clear separation of concerns in test configuration
  • Explicit property configurations for reproducibility
  • Proper resource management through Spring context

conductor-oss/conductor

postgres-persistence/src/test/java/com/netflix/conductor/test/integration/grpc/postgres/PostgresGrpcEndToEndTest.java

            
/*
 * Copyright 2023 Conductor Authors.
 * <p>
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
 * the License. You may obtain a copy of the License at
 * <p>
 * http://www.apache.org/licenses/LICENSE-2.0
 * <p>
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
 * specific language governing permissions and limitations under the License.
 */
package com.netflix.conductor.test.integration.grpc.postgres;

import org.junit.Before;
import org.junit.runner.RunWith;
import org.springframework.test.context.TestPropertySource;
import org.springframework.test.context.junit4.SpringRunner;

import com.netflix.conductor.client.grpc.EventClient;
import com.netflix.conductor.client.grpc.MetadataClient;
import com.netflix.conductor.client.grpc.TaskClient;
import com.netflix.conductor.client.grpc.WorkflowClient;
import com.netflix.conductor.test.integration.grpc.AbstractGrpcEndToEndTest;

@RunWith(SpringRunner.class)
@TestPropertySource(
        properties = {
            "conductor.db.type=postgres",
            "conductor.postgres.experimentalQueueNotify=true",
            "conductor.app.asyncIndexingEnabled=false",
            "conductor.elasticsearch.version=7",
            "conductor.grpc-server.port=8098",
            "conductor.indexing.type=elasticsearch",
            "spring.datasource.url=jdbc:tc:postgresql:11.15-alpine:///conductor", // "tc" prefix
            // starts the
            // Postgres container
            "spring.datasource.username=postgres",
            "spring.datasource.password=postgres",
            "spring.datasource.hikari.maximum-pool-size=8",
            "spring.datasource.hikari.minimum-idle=300000",
            "spring.flyway.clean-disabled=true",
            "conductor.app.workflow.name-validation.enabled=true"
        })
public class PostgresGrpcEndToEndTest extends AbstractGrpcEndToEndTest {

    @Before
    public void init() {
        taskClient = new TaskClient("localhost", 8098);
        workflowClient = new WorkflowClient("localhost", 8098);
        metadataClient = new MetadataClient("localhost", 8098);
        eventClient = new EventClient("localhost", 8098);
    }
}