Back to Repositories

Testing MySQL-backed gRPC Endpoints in Conductor-OSS

This integration test suite validates the gRPC endpoint functionality for Conductor using MySQL as the persistence layer. It ensures proper communication between Conductor’s gRPC clients and server while utilizing MySQL for data storage.

Test Coverage Overview

The test suite provides comprehensive coverage of Conductor’s gRPC endpoints with MySQL backend integration.

Key areas covered include:
  • Task management operations via TaskClient
  • Workflow execution through WorkflowClient
  • Metadata operations using MetadataClient
  • Event handling via EventClient
Integration points focus on MySQL persistence and gRPC communication channels.

Implementation Analysis

The testing approach leverages Spring’s test framework with TestPropertySource for configuration management. The implementation extends AbstractGrpcEndToEndTest, utilizing JUnit4 with SpringRunner for test execution.

Notable patterns include:
  • TestContainer usage for MySQL instance management
  • Hikari connection pool configuration
  • gRPC client initialization in @Before setup

Technical Details

Testing tools and configuration:
  • Spring Test Context framework
  • MySQL 8.0.27 with TestContainers
  • gRPC server port: 8094
  • Hikari connection pool settings
  • Elasticsearch version 7 integration
  • Workflow name validation enabled

Best Practices Demonstrated

The test implementation showcases several testing best practices for distributed systems.

Notable practices include:
  • Proper test isolation using TestContainers
  • Clean client initialization before each test
  • Comprehensive configuration management
  • Separation of concerns through inheritance
  • Proper resource management with connection pooling

conductor-oss/conductor

mysql-persistence/src/test/java/com/netflix/conductor/test/integration/grpc/mysql/MySQLGrpcEndToEndTest.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.mysql;

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=mysql",
            "conductor.grpc-server.port=8094",
            "spring.datasource.url=jdbc:tc:mysql:8.0.27:///conductor", // "tc" prefix starts the
            // MySql
            // container
            "spring.datasource.username=root",
            "spring.datasource.password=root",
            "spring.datasource.hikari.maximum-pool-size=8",
            "spring.datasource.hikari.minimum-idle=300000",
            "conductor.elasticsearch.version=7",
            "conductor.app.workflow.name-validation.enabled=true"
        })
public class MySQLGrpcEndToEndTest extends AbstractGrpcEndToEndTest {

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