This guide provides information for contributors who want to build and test the Apache Beam SDK for Astra DB.
- Java 11 or higher - The project is built with Java 11
- Maven 3.6+ - Build tool for compiling and running tests
- Astra DB Token - Required for running integration tests
The integration tests require an Astra DB token to create and access test databases. You have two options to provide this token:
Set the ASTRA_DB_APPLICATION_TOKEN environment variable:
# Linux/macOS
export ASTRA_DB_APPLICATION_TOKEN="AstraCS:your-token-here"
# Windows (Command Prompt)
set ASTRA_DB_APPLICATION_TOKEN=AstraCS:your-token-here
# Windows (PowerShell)
$env:ASTRA_DB_APPLICATION_TOKEN="AstraCS:your-token-here"Install and configure the Astra CLI:
# Install Astra CLI
curl -Ls "https://dtsx.io/get-astra-cli" | bash
# Configure with your token
astra setup
# Verify configuration
astra db listThe Astra CLI stores your token in ~/.astrarc which the tests will automatically detect.
The test framework looks for the token in this order:
~/.astrarcconfiguration file (if Astra CLI is installed)ASTRA_DB_APPLICATION_TOKENenvironment variable
If neither is found, tests will fail with:
IllegalStateException: Create environment variable ASTRA_DB_APPLICATION_TOKEN with your token
- Log in to Astra DB
- Navigate to your organization settings
- Go to "Token Management"
- Create a new token with "Database Administrator" role
- Copy the token (starts with
AstraCS:)
mvn clean compileUnit tests don't require Astra DB connection:
mvn test -Dtest=SimpleRateLimiterTestIntegration tests will automatically create a test database in your Astra account:
mvn clean testNote: Integration tests will:
- Create a temporary Astra database (if needed)
- Run tests against the database
- The database may remain after tests (check your Astra console)
mvn clean install -DskipTestsmvn javadoc:javadocThe generated documentation will be in target/site/apidocs/.
beam-sdks-java-io-astra/
├── src/
│ ├── main/
│ │ └── java/
│ │ └── org/apache/beam/sdk/io/astra/
│ │ └── db/
│ │ ├── AstraDbIO.java # Main IO connector
│ │ ├── ReadFn.java # Read operations
│ │ ├── CqlSessionHolder.java # Session management
│ │ ├── mapping/ # Entity mapping
│ │ ├── options/ # Configuration options
│ │ │ ├── RateLimiter.java # Rate limiting interface
│ │ │ └── SimpleRateLimiter.java
│ │ ├── transforms/ # Data transformations
│ │ └── utils/ # Utilities
│ └── test/
│ └── java/
│ └── org/apache/beam/sdk/io/astra/
│ ├── AbstractAstraTest.java # Base test class
│ ├── AstraDbIOTest.java # Integration tests
│ └── db/options/
│ └── SimpleRateLimiterTest.java
├── pom.xml # Maven configuration
└── README.md # User documentation
- Follow existing code formatting
- Use 2-space indentation
- Add Javadoc for public APIs
- Include unit tests for new features
- Ensure all tests pass before submitting PR
Solution: Set up your Astra token using one of the methods above.
Solution: Check your Astra account limits. Free tier has limits on concurrent database creation.
Solution: Run mvn clean compile to regenerate AutoValue classes.
Solution: Ensure all public classes, methods, and fields have proper Javadoc comments.
# Run a specific test class
mvn test -Dtest=AstraDbIOTest
# Run a specific test method
mvn test -Dtest=AstraDbIOTest#test01ReadWithTable
# Run multiple test classes
mvn test -Dtest=AstraDbIOTest,SimpleRateLimiterTestAdd to src/test/resources/logback-test.xml:
<logger name="org.apache.beam.sdk.io.astra" level="DEBUG"/>- Import project as Maven project
- Set breakpoints in code
- Run tests in debug mode
- Ensure
ASTRA_DB_APPLICATION_TOKENis set in run configuration
- Fork the repository
- Create a feature branch
- Make your changes
- Add/update tests
- Ensure all tests pass
- Update documentation
- Submit a pull request
This project is licensed under the Apache License 2.0. See LICENSE file for details.