From 4df67482cc7cfc815d7ccc42b9cb80db6bb91b48 Mon Sep 17 00:00:00 2001 From: Sanika Chavan Date: Wed, 29 Oct 2025 18:22:05 +0530 Subject: [PATCH 1/5] add tests --- .github/workflows/ci.yml | 106 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 106 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74d4b8299..14378244a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,6 +20,23 @@ jobs: os: [ubuntu-latest] go: [^1] consul-ent-tag: ["", "-enterprise"] + include: + # Add specific Consul versions for compatibility testing + - os: ubuntu-latest + go: ^1 + consul-ent-tag: "" + consul-version: "1.22.0" + test-type: "compatibility" + - os: ubuntu-latest + go: ^1 + consul-ent-tag: "" + consul-version: "1.21.5" + test-type: "compatibility" + - os: ubuntu-latest + go: ^1 + consul-ent-tag: "" + consul-version: "1.20.11" + test-type: "compatibility" steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -31,11 +48,100 @@ jobs: cache: false - name: Install Consul${{ matrix.consul-ent-tag }}, Vault and Nomad for integration testing + if: matrix.test-type != 'compatibility' run: | curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" sudo apt-get update && sudo apt-get install consul${{ matrix.consul-ent-tag }} vault nomad + - name: Install specific Consul version for compatibility testing + if: matrix.test-type == 'compatibility' + run: | + # Download specific Consul version for compatibility testing + curl -L "https://releases.hashicorp.com/consul/${{ matrix.consul-version }}/consul_${{ matrix.consul-version }}_linux_amd64.zip" -o consul.zip + unzip consul.zip + sudo mv consul /usr/local/bin/consul-${{ matrix.consul-version }} + sudo chmod +x /usr/local/bin/consul-${{ matrix.consul-version }} + # Also install vault and nomad from apt for regular integration tests + curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - + sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" + sudo apt-get update && sudo apt-get install vault nomad + - name: Run tests + if: matrix.test-type != 'compatibility' run: | make test-race + + - name: Run compatibility tests + if: matrix.test-type == 'compatibility' + run: | + # Build consul-template + make dev + # Run compatibility test if framework exists + if [ -f test/compatibility/quick-test.sh ]; then + cd test/compatibility + # Use the specific consul version we downloaded + CONSUL_BINARY="/usr/local/bin/consul-${{ matrix.consul-version }}" ./quick-test.sh ${{ matrix.consul-version }} + else + # Fallback: basic compatibility test + echo "Testing consul-template with Consul ${{ matrix.consul-version }}..." + /usr/local/bin/consul-${{ matrix.consul-version }} agent -dev & + CONSUL_PID=$! + sleep 5 + # Basic test + echo '{{ key "test/compatibility" }}' > test.tpl + /usr/local/bin/consul-${{ matrix.consul-version }} kv put test/compatibility "consul-${{ matrix.consul-version }}-working" + ./consul-template -template "test.tpl:test.out" -once + if [ "$(cat test.out)" = "consul-${{ matrix.consul-version }}-working" ]; then + echo "✅ Consul ${{ matrix.consul-version }} compatibility test PASSED" + else + echo "❌ Consul ${{ matrix.consul-version }} compatibility test FAILED" + exit 1 + fi + kill $CONSUL_PID + fi + + - name: Upload compatibility test results + if: matrix.test-type == 'compatibility' && always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: compatibility-results-${{ matrix.consul-version }} + path: test/compatibility/results/ + retention-days: 30 + + consul-compatibility-test: + name: Test Consul Compatibility + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + consul_version: ["1.22.0", "1.21.5", "1.20.11"] + + steps: + - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 + + - name: Set up Go + uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 + with: + go-version: ^1 + cache: false + + - name: Build consul-template + run: make dev + + - name: Test compatibility with Consul ${{ matrix.consul_version }} + run: | + if [ -f test/compatibility/quick-test.sh ]; then + cd test/compatibility + ./quick-test.sh ${{ matrix.consul_version }} + else + echo "Compatibility test framework not found, skipping..." + fi + + - name: Upload compatibility test results + if: always() + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 + with: + name: compatibility-results-${{ matrix.consul_version }} + path: test/compatibility/results/ + retention-days: 30 From e53b9db29abf44c1d6873767019d872ea5b1a852 Mon Sep 17 00:00:00 2001 From: Sanika Chavan Date: Wed, 29 Oct 2025 18:28:01 +0530 Subject: [PATCH 2/5] try compatibility testing --- .github/workflows/ci.yml | 120 +++++++++++++++++---------------------- 1 file changed, 53 insertions(+), 67 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 14378244a..0d8dcf139 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,7 +12,7 @@ env: jobs: run-tests: - name: Run test cases (with consul${{ matrix.consul-ent-tag }}) + name: Test CT${{ matrix.ct-version }} + Consul${{ matrix.consul-ent-tag }} ${{ matrix.consul-version }} runs-on: ${{ matrix.os }} strategy: fail-fast: false @@ -20,23 +20,15 @@ jobs: os: [ubuntu-latest] go: [^1] consul-ent-tag: ["", "-enterprise"] - include: - # Add specific Consul versions for compatibility testing - - os: ubuntu-latest - go: ^1 - consul-ent-tag: "" - consul-version: "1.22.0" - test-type: "compatibility" - - os: ubuntu-latest - go: ^1 - consul-ent-tag: "" - consul-version: "1.21.5" - test-type: "compatibility" - - os: ubuntu-latest - go: ^1 - consul-ent-tag: "" - consul-version: "1.20.11" - test-type: "compatibility" + consul-version: ["1.18.15", "1.20.11", "1.21.5", "1.22.0"] + ct-version: ["current", "0.40.0", "0.39.1"] + exclude: + # Don't test every combination - too many jobs + # Only test current CT version with enterprise Consul + - ct-version: "0.40.0" + consul-ent-tag: "-enterprise" + - ct-version: "0.39.1" + consul-ent-tag: "-enterprise" steps: - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 @@ -47,67 +39,61 @@ jobs: go-version: ${{ matrix.go }} cache: false - - name: Install Consul${{ matrix.consul-ent-tag }}, Vault and Nomad for integration testing - if: matrix.test-type != 'compatibility' + - name: Install specific Consul version ${{ matrix.consul-version }}${{ matrix.consul-ent-tag }} run: | - curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - sudo apt-get update && sudo apt-get install consul${{ matrix.consul-ent-tag }} vault nomad - - - name: Install specific Consul version for compatibility testing - if: matrix.test-type == 'compatibility' - run: | - # Download specific Consul version for compatibility testing - curl -L "https://releases.hashicorp.com/consul/${{ matrix.consul-version }}/consul_${{ matrix.consul-version }}_linux_amd64.zip" -o consul.zip + # Download specific Consul version + if [ "${{ matrix.consul-ent-tag }}" = "-enterprise" ]; then + CONSUL_URL="https://releases.hashicorp.com/consul/${{ matrix.consul-version }}+ent/consul_${{ matrix.consul-version }}+ent_linux_amd64.zip" + else + CONSUL_URL="https://releases.hashicorp.com/consul/${{ matrix.consul-version }}/consul_${{ matrix.consul-version }}_linux_amd64.zip" + fi + + curl -L "$CONSUL_URL" -o consul.zip unzip consul.zip - sudo mv consul /usr/local/bin/consul-${{ matrix.consul-version }} - sudo chmod +x /usr/local/bin/consul-${{ matrix.consul-version }} - # Also install vault and nomad from apt for regular integration tests + sudo mv consul /usr/local/bin/consul + sudo chmod +x /usr/local/bin/consul + + # Install Vault and Nomad from apt (latest versions are fine for testing) curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" sudo apt-get update && sudo apt-get install vault nomad - - name: Run tests - if: matrix.test-type != 'compatibility' + - name: Setup consul-template version ${{ matrix.ct-version }} run: | - make test-race - - - name: Run compatibility tests - if: matrix.test-type == 'compatibility' - run: | - # Build consul-template - make dev - # Run compatibility test if framework exists - if [ -f test/compatibility/quick-test.sh ]; then - cd test/compatibility - # Use the specific consul version we downloaded - CONSUL_BINARY="/usr/local/bin/consul-${{ matrix.consul-version }}" ./quick-test.sh ${{ matrix.consul-version }} + if [ "${{ matrix.ct-version }}" = "current" ]; then + # Build current version from source + make dev + echo "Using current consul-template version from source" else - # Fallback: basic compatibility test - echo "Testing consul-template with Consul ${{ matrix.consul-version }}..." - /usr/local/bin/consul-${{ matrix.consul-version }} agent -dev & - CONSUL_PID=$! - sleep 5 - # Basic test - echo '{{ key "test/compatibility" }}' > test.tpl - /usr/local/bin/consul-${{ matrix.consul-version }} kv put test/compatibility "consul-${{ matrix.consul-version }}-working" - ./consul-template -template "test.tpl:test.out" -once - if [ "$(cat test.out)" = "consul-${{ matrix.consul-version }}-working" ]; then - echo "✅ Consul ${{ matrix.consul-version }} compatibility test PASSED" - else - echo "❌ Consul ${{ matrix.consul-version }} compatibility test FAILED" - exit 1 - fi - kill $CONSUL_PID + # Download specific released version + CT_URL="https://releases.hashicorp.com/consul-template/${{ matrix.ct-version }}/consul-template_${{ matrix.ct-version }}_linux_amd64.zip" + curl -L "$CT_URL" -o consul-template.zip + unzip consul-template.zip + chmod +x consul-template + echo "Downloaded consul-template ${{ matrix.ct-version }}" fi - - name: Upload compatibility test results - if: matrix.test-type == 'compatibility' && always() + - name: Verify versions + run: | + consul version + ./consul-template -version + echo "Testing consul-template ${{ matrix.ct-version }} with Consul ${{ matrix.consul-version }}${{ matrix.consul-ent-tag }}" + + - name: Run integration tests with race detection + run: | + # Run the integration test suite with race detection + # This tests consul-template functionality against the specific Consul version + make test-race + + - name: Upload test results on failure + if: failure() uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 with: - name: compatibility-results-${{ matrix.consul-version }} - path: test/compatibility/results/ - retention-days: 30 + name: test-failure-ct${{ matrix.ct-version }}-consul${{ matrix.consul-version }}${{ matrix.consul-ent-tag }} + path: | + *.log + test-results/ + retention-days: 7 consul-compatibility-test: name: Test Consul Compatibility From 6f57bd89d6760c81a6ff57ce9f95885d44499fa1 Mon Sep 17 00:00:00 2001 From: Sanika Chavan Date: Wed, 29 Oct 2025 18:34:19 +0530 Subject: [PATCH 3/5] refactor CI workflow to install Consul and consul-template via apt instead of downloading; remove compatibility test job --- .github/workflows/ci.yml | 77 ++++++++++++---------------------------- 1 file changed, 22 insertions(+), 55 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0d8dcf139..a6692df8f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,24 +39,26 @@ jobs: go-version: ${{ matrix.go }} cache: false + - name: Setup HashiCorp apt repository + run: | + curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - + sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" + sudo apt-get update + - name: Install specific Consul version ${{ matrix.consul-version }}${{ matrix.consul-ent-tag }} run: | - # Download specific Consul version + # Install specific Consul version via apt if [ "${{ matrix.consul-ent-tag }}" = "-enterprise" ]; then - CONSUL_URL="https://releases.hashicorp.com/consul/${{ matrix.consul-version }}+ent/consul_${{ matrix.consul-version }}+ent_linux_amd64.zip" + CONSUL_PACKAGE="consul=${{ matrix.consul-version }}+ent-1" else - CONSUL_URL="https://releases.hashicorp.com/consul/${{ matrix.consul-version }}/consul_${{ matrix.consul-version }}_linux_amd64.zip" + CONSUL_PACKAGE="consul=${{ matrix.consul-version }}-1" fi - curl -L "$CONSUL_URL" -o consul.zip - unzip consul.zip - sudo mv consul /usr/local/bin/consul - sudo chmod +x /usr/local/bin/consul + echo "Installing Consul package: $CONSUL_PACKAGE" + sudo apt-get install -y "$CONSUL_PACKAGE" - # Install Vault and Nomad from apt (latest versions are fine for testing) - curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - - sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" - sudo apt-get update && sudo apt-get install vault nomad + # Also install Vault and Nomad (latest versions are fine for testing) + sudo apt-get install -y vault nomad - name: Setup consul-template version ${{ matrix.ct-version }} run: | @@ -65,18 +67,20 @@ jobs: make dev echo "Using current consul-template version from source" else - # Download specific released version - CT_URL="https://releases.hashicorp.com/consul-template/${{ matrix.ct-version }}/consul-template_${{ matrix.ct-version }}_linux_amd64.zip" - curl -L "$CT_URL" -o consul-template.zip - unzip consul-template.zip - chmod +x consul-template - echo "Downloaded consul-template ${{ matrix.ct-version }}" + # Install specific released version via apt + CT_PACKAGE="consul-template=${{ matrix.ct-version }}-1" + echo "Installing consul-template package: $CT_PACKAGE" + sudo apt-get install -y "$CT_PACKAGE" fi - name: Verify versions run: | consul version - ./consul-template -version + if [ "${{ matrix.ct-version }}" = "current" ]; then + ./bin/consul-template -version + else + consul-template -version + fi echo "Testing consul-template ${{ matrix.ct-version }} with Consul ${{ matrix.consul-version }}${{ matrix.consul-ent-tag }}" - name: Run integration tests with race detection @@ -94,40 +98,3 @@ jobs: *.log test-results/ retention-days: 7 - - consul-compatibility-test: - name: Test Consul Compatibility - runs-on: ubuntu-latest - strategy: - fail-fast: false - matrix: - consul_version: ["1.22.0", "1.21.5", "1.20.11"] - - steps: - - uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 - - - name: Set up Go - uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32 # v5.0.2 - with: - go-version: ^1 - cache: false - - - name: Build consul-template - run: make dev - - - name: Test compatibility with Consul ${{ matrix.consul_version }} - run: | - if [ -f test/compatibility/quick-test.sh ]; then - cd test/compatibility - ./quick-test.sh ${{ matrix.consul_version }} - else - echo "Compatibility test framework not found, skipping..." - fi - - - name: Upload compatibility test results - if: always() - uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2 - with: - name: compatibility-results-${{ matrix.consul_version }} - path: test/compatibility/results/ - retention-days: 30 From 6d0b7f300b189bb1538244451f60270792ed088c Mon Sep 17 00:00:00 2001 From: Sanika Chavan Date: Wed, 29 Oct 2025 18:44:37 +0530 Subject: [PATCH 4/5] update CI workflow to use specific Consul versions; add package availability check before installation --- .github/workflows/ci.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a6692df8f..c76e00cc9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -20,7 +20,7 @@ jobs: os: [ubuntu-latest] go: [^1] consul-ent-tag: ["", "-enterprise"] - consul-version: ["1.18.15", "1.20.11", "1.21.5", "1.22.0"] + consul-version: ["1.18.2", "1.20.6", "1.21.5", "1.22.0"] ct-version: ["current", "0.40.0", "0.39.1"] exclude: # Don't test every combination - too many jobs @@ -55,6 +55,14 @@ jobs: fi echo "Installing Consul package: $CONSUL_PACKAGE" + + # Check if package is available first + if ! apt-cache show "$CONSUL_PACKAGE" >/dev/null 2>&1; then + echo "Package $CONSUL_PACKAGE not found. Available consul versions:" + apt-cache madison consul | head -10 + exit 1 + fi + sudo apt-get install -y "$CONSUL_PACKAGE" # Also install Vault and Nomad (latest versions are fine for testing) @@ -77,7 +85,9 @@ jobs: run: | consul version if [ "${{ matrix.ct-version }}" = "current" ]; then - ./bin/consul-template -version + # For current version built with make dev, binary is in $GOPATH/bin + GOPATH=$(go env GOPATH) + $GOPATH/bin/consul-template -version else consul-template -version fi From ed50e79f1ec76e035005b2b58922e329edf7b964 Mon Sep 17 00:00:00 2001 From: Sanika Chavan Date: Wed, 29 Oct 2025 18:51:11 +0530 Subject: [PATCH 5/5] fix(ci): correct package name for enterprise Consul and add availability check --- .github/workflows/ci.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c76e00cc9..f45b4e366 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -49,7 +49,7 @@ jobs: run: | # Install specific Consul version via apt if [ "${{ matrix.consul-ent-tag }}" = "-enterprise" ]; then - CONSUL_PACKAGE="consul=${{ matrix.consul-version }}+ent-1" + CONSUL_PACKAGE="consul-enterprise=${{ matrix.consul-version }}+ent-1" else CONSUL_PACKAGE="consul=${{ matrix.consul-version }}-1" fi @@ -59,7 +59,11 @@ jobs: # Check if package is available first if ! apt-cache show "$CONSUL_PACKAGE" >/dev/null 2>&1; then echo "Package $CONSUL_PACKAGE not found. Available consul versions:" - apt-cache madison consul | head -10 + if [ "${{ matrix.consul-ent-tag }}" = "-enterprise" ]; then + apt-cache madison consul-enterprise | head -10 + else + apt-cache madison consul | head -10 + fi exit 1 fi