Merge pull request #72 from burmanm/v1019 #136
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Cass Config Builder Build & Deploy | |
| on: | |
| push: | |
| branches: [ master ] | |
| pull_request: | |
| branches: [ master ] | |
| jobs: | |
| build_operator_docker: | |
| name: Build Cass Config Builder Docker Image | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| if: github.event_name == 'pull_request' | |
| with: | |
| ref: ${{ github.event.pull_request.head.sha }} | |
| submodules: true | |
| - uses: actions/checkout@v4 | |
| if: github.event_name != 'pull_request' | |
| with: | |
| submodules: true | |
| - uses: actions/setup-java@v4 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '8' | |
| - name: Login to DockerHub | |
| if: ${{ !env.ACT }} | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Cache Docker layers | |
| uses: actions/cache@v4 | |
| id: cache | |
| with: | |
| path: /tmp/.buildx-cache | |
| key: ${{ runner.os }}-buildx-${{ github.sha }} | |
| restore-keys: | | |
| ${{ runner.os }}-buildx- | |
| - name: Setup Gradle | |
| uses: gradle/actions/setup-gradle@v3 | |
| - name: Build with Gradle | |
| run: ./gradlew test | |
| - name: Build docker image | |
| env: | |
| GITHUB_REPO_OWNER: ${{ github.repository_owner }} | |
| run: | | |
| export GITHUB_REPO_URL="https://github.com/${{ github.repository }}" | |
| ./scripts/build-push-images.sh | |
| - name: Smoke test Docker image | |
| env: | |
| GITHUB_REPO_OWNER: ${{ github.repository_owner }} | |
| run: | | |
| # Calculate image tag using same logic as build script | |
| VERSION_NUMBER="$(cat version.txt | tr -d '[:space:]')" | |
| VERSION_DATE="$(date -u +%Y%m%d)" | |
| RELEASE_VERSION="${VERSION_NUMBER}-${VERSION_DATE}-ubi" | |
| IMAGE_TAG="ghcr.io/${GITHUB_REPO_OWNER}/cass-config-builder/cass-config-builder:${RELEASE_VERSION}" | |
| echo "Testing image: $IMAGE_TAG" | |
| # Create temporary directory for config output | |
| TEST_DIR=$(mktemp -d) | |
| echo "Test directory: $TEST_DIR" | |
| # Set proper permissions for the UBI image (runs as cassandra user) | |
| # The UBI image runs as user cassandra:root, so we need to make the directory writable | |
| chmod 777 "$TEST_DIR" | |
| # Run the container with the specified environment variables | |
| docker run --rm \ | |
| -v "$TEST_DIR:/config" \ | |
| -e POD_IP="10.244.1.5" \ | |
| -e HOST_IP="192.168.1.100" \ | |
| -e USE_HOST_IP_FOR_BROADCAST="false" \ | |
| -e RACK_NAME="default" \ | |
| -e PRODUCT_VERSION="4.0.17" \ | |
| -e PRODUCT_NAME="cassandra" \ | |
| -e CONFIG_FILE_DATA='{"cassandra-env-sh":{"additional-jvm-opts":["-Dcassandra.allow_alter_rf_during_range_movement=true","-Dcassandra.system_distributed_replication=dc1:3","-Dfoo=true","-Dbar"]},"cassandra-yaml":{"authenticator":"TestAuthenticator","authorizer":"TestAuthorizer","commitlog_directory":"/var/lib/cassandra/commitlog2","data_file_directories":["/var/lib/cassandra/data","/var/lib/extra/data"],"num_tokens":16,"role_manager":"CassandraRoleManager"},"cluster-info":{"name":"Weird Cluster Name","seeds":"weirdclustername-seed-service,weirdclustername-dc1-additional-seed-service"},"datacenter-info":{"graph-enabled":0,"name":"dc1","solr-enabled":0,"spark-enabled":0},"jvm-server-options":{"agent_lib_jdwp":false,"always_pre_touch":false,"cassandra_available_processors":2,"cassandra_disable_auth_caches_remote_configuration":false,"cassandra_force_default_indexing_page_size":false,"cassandra_ring_delay_ms":100,"cassandra_write_survey":false,"enable_assertions":false,"flight_recorder":false,"heap_dump_on_out_of_memory_error":false,"initial_heap_size":536870912,"java_net_prefer_ipv4_stack":true,"jmx-connection-type":"local-no-auth","jmx-port":7199,"jmx-remote-ssl":false,"jmx-remote-ssl-opts":"abc","max_heap_size":536870912,"per_thread_stack_size":262144,"perf_disable_shared_mem":false,"resize_tlb":false,"string_table_size":1048576,"unlock_commercial_features":false,"use-biased-locking":false,"use_thread_priorities":false,"use_tlb":false},"jvm11-server-options":{"conc_gc_threads":2,"g1r_set_updating_pause_time_percent":5,"garbage_collector":"G1GC","initiating_heap_occupancy_percent":75,"max_gc_pause_millis":500,"parallel_gc_threads":2}}' \ | |
| "$IMAGE_TAG" | |
| echo "Container execution completed. Checking output..." | |
| # Check if /config directory was created and contains files | |
| if [ ! -d "$TEST_DIR" ]; then | |
| echo "ERROR: Config directory was not created" | |
| exit 1 | |
| fi | |
| # List generated files | |
| echo "Generated files:" | |
| ls -la "$TEST_DIR/" | |
| # Debug: Show what files were actually generated | |
| echo "Files in test directory:" | |
| find "$TEST_DIR" -type f -exec basename {} \; | |
| # Check if cassandra.yaml exists | |
| if [ ! -f "$TEST_DIR/cassandra.yaml" ]; then | |
| echo "ERROR: cassandra.yaml was not generated" | |
| exit 1 | |
| fi | |
| # Verify key configuration values in cassandra.yaml | |
| echo "Checking cassandra.yaml contents..." | |
| # Check for authenticator setting | |
| if ! grep -q "authenticator: TestAuthenticator" "$TEST_DIR/cassandra.yaml"; then | |
| echo "ERROR: authenticator not set correctly" | |
| cat "$TEST_DIR/cassandra.yaml" | |
| exit 1 | |
| fi | |
| # Check for authorizer setting | |
| if ! grep -q "authorizer: TestAuthorizer" "$TEST_DIR/cassandra.yaml"; then | |
| echo "ERROR: authorizer not set correctly" | |
| cat "$TEST_DIR/cassandra.yaml" | |
| exit 1 | |
| fi | |
| # Check for num_tokens setting | |
| if ! grep -q "num_tokens: 16" "$TEST_DIR/cassandra.yaml"; then | |
| echo "ERROR: num_tokens not set correctly" | |
| cat "$TEST_DIR/cassandra.yaml" | |
| exit 1 | |
| fi | |
| # Check for data directories | |
| if ! grep -q "/var/lib/cassandra/data" "$TEST_DIR/cassandra.yaml"; then | |
| echo "ERROR: data directories not set correctly" | |
| cat "$TEST_DIR/cassandra.yaml" | |
| exit 1 | |
| fi | |
| # Check for commitlog directory | |
| if ! grep -q "commitlog_directory: /var/lib/cassandra/commitlog2" "$TEST_DIR/cassandra.yaml"; then | |
| echo "ERROR: commitlog directory not set correctly" | |
| cat "$TEST_DIR/cassandra.yaml" | |
| exit 1 | |
| fi | |
| echo "✅ cassandra.yaml checks passed!" | |
| # Check if cassandra-env.sh exists | |
| if [ ! -f "$TEST_DIR/cassandra-env.sh" ]; then | |
| echo "ERROR: cassandra-env.sh was not generated" | |
| exit 1 | |
| fi | |
| # Verify cassandra-env.sh contents | |
| echo "Checking cassandra-env.sh contents..." | |
| # Check for additional JVM options that were specified in CONFIG_FILE_DATA | |
| if ! grep -q "\-Dcassandra.allow_alter_rf_during_range_movement=true" "$TEST_DIR/cassandra-env.sh"; then | |
| echo "ERROR: JVM option -Dcassandra.allow_alter_rf_during_range_movement=true not found in cassandra-env.sh" | |
| cat "$TEST_DIR/cassandra-env.sh" | |
| exit 1 | |
| fi | |
| if ! grep -q "\-Dcassandra.system_distributed_replication=dc1:3" "$TEST_DIR/cassandra-env.sh"; then | |
| echo "ERROR: JVM option -Dcassandra.system_distributed_replication=dc1:3 not found in cassandra-env.sh" | |
| cat "$TEST_DIR/cassandra-env.sh" | |
| exit 1 | |
| fi | |
| if ! grep -q "\-Dfoo=true" "$TEST_DIR/cassandra-env.sh"; then | |
| echo "ERROR: JVM option -Dfoo=true not found in cassandra-env.sh" | |
| cat "$TEST_DIR/cassandra-env.sh" | |
| exit 1 | |
| fi | |
| if ! grep -q "\-Dbar" "$TEST_DIR/cassandra-env.sh"; then | |
| echo "ERROR: JVM option -Dbar not found in cassandra-env.sh" | |
| cat "$TEST_DIR/cassandra-env.sh" | |
| exit 1 | |
| fi | |
| echo "✅ cassandra-env.sh checks passed!" | |
| # Check if jvm11-server.options exists | |
| if [ ! -f "$TEST_DIR/jvm11-server.options" ]; then | |
| echo "ERROR: jvm11-server.options was not generated" | |
| exit 1 | |
| fi | |
| # Verify jvm11-server.options contents | |
| echo "Checking jvm11-server.options contents..." | |
| # Check for G1GC garbage collector | |
| if ! grep -q "\-XX:+UseG1GC" "$TEST_DIR/jvm11-server.options"; then | |
| echo "ERROR: G1GC garbage collector not configured in jvm11-server.options" | |
| cat "$TEST_DIR/jvm-server.options" | |
| exit 1 | |
| fi | |
| # Check for concurrent GC threads setting | |
| if ! grep -q "\-XX:ConcGCThreads=2" "$TEST_DIR/jvm11-server.options"; then | |
| echo "ERROR: ConcGCThreads=2 not found in jvm11-server.options" | |
| cat "$TEST_DIR/jvm11-server.options" | |
| exit 1 | |
| fi | |
| # Check for parallel GC threads setting | |
| if ! grep -q "\-XX:ParallelGCThreads=2" "$TEST_DIR/jvm11-server.options"; then | |
| echo "ERROR: ParallelGCThreads=2 not found in jvm11-server.options" | |
| cat "$TEST_DIR/jvm11-server.options" | |
| exit 1 | |
| fi | |
| # Check for G1 heap occupancy percent | |
| #if ! grep -q "\-XX:G1HeapRegionSize" "$TEST_DIR/jvm11-server.options" || ! grep -q "\-XX:InitiatingHeapOccupancyPercent=75" "$TEST_DIR/jvm11-server.options"; then | |
| # echo "ERROR: G1 heap occupancy settings not configured correctly in jvm11-server.options" | |
| # cat "$TEST_DIR/jvm11-server.options" | |
| # exit 1 | |
| #fi | |
| # Check for max GC pause time | |
| if ! grep -q "\-XX:MaxGCPauseMillis=500" "$TEST_DIR/jvm11-server.options"; then | |
| echo "ERROR: MaxGCPauseMillis=500 not found in jvm11-server.options" | |
| cat "$TEST_DIR/jvm11-server.options" | |
| exit 1 | |
| fi | |
| # Check for G1 R Set updating pause time percent | |
| if ! grep -q "\-XX:G1RSetUpdatingPauseTimePercent=5" "$TEST_DIR/jvm11-server.options"; then | |
| echo "ERROR: G1RSetUpdatingPauseTimePercent=5 not found in jvm11-server.options" | |
| cat "$TEST_DIR/jvm11-server.options" | |
| exit 1 | |
| fi | |
| echo "✅ jvm11-server.options checks passed!" | |
| echo "✅ All smoke tests passed! Configuration generation verified successfully." | |
| # Clean up | |
| rm -rf "$TEST_DIR" | |
| - name: Archive build logs | |
| if: ${{ failure() }} | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: gradle-logs | |
| path: build/reports | |