Skip to content

Add Testcontainers-based integration tests for setup and deploy flows#53

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/add-deploy4j-integration-tests
Draft

Add Testcontainers-based integration tests for setup and deploy flows#53
Copilot wants to merge 3 commits intomainfrom
copilot/add-deploy4j-integration-tests

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Nov 13, 2025

Implements automated integration tests for deploy4j core functionality using Testcontainers to spin up teggr/deploy4j-docker-droplet containers. Tests verify end-to-end setup and deployment flows against a live SSH/Docker environment.

Changes

  • Test Infrastructure

    • BaseIntegrationTest: Manages Testcontainers lifecycle, provides SSH connection helpers
    • TestConfigurationFactory: Creates programmatic configurations without file dependencies
    • Tagged with @Tag("integration") and @EnabledIfEnvironmentVariable(ENABLE_INTEGRATION_TESTS=true) to skip by default
  • Test Coverage

    • SetupIntegrationTest: Verifies server bootstrap, environment push, and initial deployment
    • DeployIntegrationTest: Verifies image pull, container deployment, and lifecycle management
    • Uses teggr/deploy4j-demo:0.0.2-SNAPSHOT as test image
  • Dependencies

    • Added testcontainers:1.20.4 and junit-jupiter:1.20.4 to deploy4j-core
    • Maven Surefire configured to exclude integration tests by default

Usage

# Run integration tests (requires Docker)
export ENABLE_INTEGRATION_TESTS=true
mvn test -pl deploy4j-core -Dgroups=integration

Example

@Test
void shouldSetupDeploymentEnvironment() throws Exception {
    Configuration config = TestConfigurationFactory.createTestConfiguration(
        "test-service",
        "teggr/deploy4j-demo",
        List.of(getSshHost()),
        getSshUsername(),
        getSshPort()
    );
    
    try (SshHosts sshHosts = new SshHosts(config)) {
        deployApplicationContext.deploy().setup(deployContext);
    }
}
Original prompt

This section details on the original issue you should resolve

<issue_title>deploy4j integration tests</issue_title>
<issue_description># Integration Testing with deploy4j

Overview

This document describes approaches for end-to-end integration testing of deploy4j.

Manual Integration Testing

For manual integration testing, you can use the deploy4j Docker droplet container which simulates a deployment target server.

Setup

  1. Start the deploy4j-docker-droplet container:
docker run -d -p 2222:22 --name deploy4j-droplet \
  -v "$HOME/.ssh/id_rsa.pub":/root/.ssh/authorized_keys \
  -v /var/run/docker.sock:/var/run/docker.sock \
  teggr/deploy4j-docker-droplet:latest
  1. Test SSH connectivity:
ssh -o StrictHostKeyChecking=no -p 2222 root@localhost
  1. Test deployment commands against the container:
# Run deploy4j commands targeting localhost:2222
deploy4j test --host localhost --port 2222

Cleanup

docker stop deploy4j-droplet
docker rm deploy4j-droplet

Automated Integration Testing

Current Status

Automated integration tests using Testcontainers are currently not implemented due to dependency conflicts between Testcontainers and Jackson libraries used by deploy4j.

Future Implementation

To implement automated integration tests:

  1. Resolve Dependency Conflicts: Update Jackson dependencies to versions compatible with Testcontainers, or use dependency management to isolate versions.

  2. Add Testcontainers Support: Add the following dependencies to deploy4j-core/pom.xml:

<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>testcontainers</artifactId>
    <version>1.20.4</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>junit-jupiter</artifactId>
    <version>1.20.4</version>
    <scope>test</scope>
</dependency>
  1. Create Integration Tests: Create tests in src/test/java/dev/deploy4j/integration/ that:
    • Spin up the deploy4j-docker-droplet container
    • Test SSH connectivity
    • Test deployment commands
    • Test application lifecycle (deploy, rollback, etc.)

Example Integration Test Pattern

@Testcontainers
@Tag("integration")
@EnabledIfEnvironmentVariable(named = "ENABLE_INTEGRATION_TESTS", matches = "true")
class DeploymentIntegrationTest {

    @Container
    private final GenericContainer<?> sshContainer = 
        new GenericContainer<>("teggr/deploy4j-docker-droplet:latest")
            .withExposedPorts(22)
            .withPrivilegedMode(true);

    @Test
    void shouldDeployApplication() {
        // Test full deployment flow
    }
}

Constraints

  • Add the integration tests to the deploy4j-core module. We won't integration test the cli/maven modules
  • keep to the main use case of setup + deploy
  • use the deploy4j-demo 0.0.2-SNAPSHOT image for the tests
  • add support for loading configuration in an alternative testable way to avoid reliance on having to load values via the config and env files </issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 13, 2025 08:56
Co-authored-by: teggr <837787+teggr@users.noreply.github.com>
Co-authored-by: teggr <837787+teggr@users.noreply.github.com>
Copilot AI changed the title [WIP] Add integration tests for deploy4j Add Testcontainers-based integration tests for setup and deploy flows Nov 13, 2025
Copilot AI requested a review from teggr November 13, 2025 09:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deploy4j integration tests

2 participants