Skip to content

feat: add junit XML export to airbyte-cdk connector test command#582

Merged
Aaron ("AJ") Steers (aaronsteers) merged 4 commits into
mainfrom
devin/1749081916-junit-test-results
Jun 5, 2025
Merged

feat: add junit XML export to airbyte-cdk connector test command#582
Aaron ("AJ") Steers (aaronsteers) merged 4 commits into
mainfrom
devin/1749081916-junit-test-results

Conversation

@devin-ai-integration
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot commented Jun 5, 2025

Add JUnit XML export to airbyte-cdk connector test command

Summary

This PR adds the ability to export pytest results to JUnit XML format when running the airbyte-cdk connector test command. The XML file is saved to <connector_dir>/build/standard-tests-junit.xml.

Changes

  • Modified airbyte_cdk/cli/airbyte_cdk/_connector.py to add --junitxml argument to pytest command
  • Added logic to create the build directory if it doesn't exist
  • Maintains all existing functionality while adding test result export capability

Testing

  • Verified the implementation works with source-hardcoded-records connector
  • Confirmed the build directory is created automatically
  • Validated that the generated XML file contains proper JUnit format test results
  • All linting, formatting, and type checking passes

Example Output

When running airbyte-cdk connector test source-hardcoded-records, the command now:

  1. Creates <connector_dir>/build/ directory if it doesn't exist
  2. Exports test results to <connector_dir>/build/standard-tests-junit.xml
  3. Maintains all existing test functionality

The pytest args now include: --junitxml /path/to/connector/build/standard-tests-junit.xml


Link to Devin run: https://app.devin.ai/sessions/8f6ad1a612a64bb2b2d10b814946ea69

Requested by: AJ Steers (aj@airbyte.io)

Important

Auto-merge enabled.

This PR is set to merge automatically when all requirements are met.

- Add --junitxml argument to pytest command to export results to <connector_dir>/build/standard-tests-junit.xml
- Create build directory if it doesn't exist
- Maintains existing functionality while adding test result export capability

Co-Authored-By: AJ Steers <aj@airbyte.io>
@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

Original prompt from AJ Steers:

@Devin - can you update the CDK's `airbyte-cdk connector test` command to export its pytest results to `<connector_dir>/build/standard-tests-junit.xml`? The relevant part of the code is already printing this exact text "Pytest args:" - which will help you find the correct location.

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@github-actions github-actions Bot added the enhancement New feature or request label Jun 5, 2025
Comment thread airbyte_cdk/cli/airbyte_cdk/_connector.py Outdated
Comment thread airbyte_cdk/cli/airbyte_cdk/_connector.py Outdated
Comment thread airbyte_cdk/cli/airbyte_cdk/_connector.py Outdated
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

Matches what we are using in connectors' poe tasks file: --junitxml=build/test-results/pytest-unit-tests-junit.xml

@dbgold17
Copy link
Copy Markdown
Contributor

David Gold (dbgold17) commented Jun 5, 2025

/poe connector source-hardcoded-records dummy-change

Running poe connector source-hardcoded-records dummy-change...

Link to job logs.

❌ Poe command connector source-hardcoded-records dummy-change failed. Please inspect the logs.

@dbgold17
Copy link
Copy Markdown
Contributor

/poe connector source-hardcoded-records dummy-change

oh ignore this!

@aaronsteers
Copy link
Copy Markdown
Member

Devin - if you have airbyte-python-cdk and airbyte both checked out in the same parent directory, could you run this from the CDK repo and report back?: poetry run airbyte-cdk connector test source-hardcoded-records

We want to confirm the junit results are in the expected location.

If the above doesn't work, you can also give an absolute path to the connector directory when you invoke it, like this: poetry run airbyte-cdk connector test path/to/source-hardcoded-records.

@devin-ai-integration
Copy link
Copy Markdown
Contributor Author

Test Results Confirmed

I ran the requested test command: poetry run airbyte-cdk connector test source-hardcoded-records

Results:

  • ✅ JUnit XML file successfully generated at expected location: /home/ubuntu/repos/airbyte/airbyte-integrations/connectors/source-hardcoded-records/build/test-results/standard-tests-junit.xml
  • ✅ Pytest args correctly include: --junitxml /path/to/connector/build/test-results/standard-tests-junit.xml
  • ✅ XML file contains proper JUnit format with test results (9 tests total, 4 failed, 5 passed)

Test Summary:

  • 5 tests passed (including test_spec, invalid_config.json scenarios)
  • 4 tests failed due to missing secrets/config.json file (expected for this test connector)
  • The failures are not related to the junit XML implementation - they're configuration-related

The junit XML export functionality is working exactly as intended! 🎉

@aaronsteers Aaron ("AJ") Steers (aaronsteers) merged commit c64ff62 into main Jun 5, 2025
27 of 28 checks passed
@aaronsteers Aaron ("AJ") Steers (aaronsteers) deleted the devin/1749081916-junit-test-results branch June 5, 2025 00:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants