diff --git a/.github/workflows/test-add-replica-matrix.yaml b/.github/workflows/test-add-replica-matrix.yaml new file mode 100644 index 00000000..ef3f2805 --- /dev/null +++ b/.github/workflows/test-add-replica-matrix.yaml @@ -0,0 +1,124 @@ +--- +name: "Add replica matrix" + +on: + pull_request: + paths: + - ".github/workflows/**/*" + - "spec/**/*" + - "lib/**/*" + - "tasks/**/*" + - "functions/**/*" + - "types/**/*" + - "plans/**/*" + - "hiera/**/*" + - "manifests/**/*" + - "templates/**/*" + - "files/**/*" + - "metadata.json" + - "Rakefile" + - "Gemfile" + - "provision.yaml" + - ".rspec" + - ".rubocop.yml" + - ".puppet-lint.rc" + - ".fixtures.yml" + branches: [main] + workflow_dispatch: {} + +jobs: + test-add-replica: + name: "PE ${{ matrix.version }} ${{ matrix.architecture }} on ${{ matrix.image }}" + runs-on: ubuntu-20.04 + env: + BOLT_GEM: true + BOLT_DISABLE_ANALYTICS: true + LANG: "en_US.UTF-8" + strategy: + fail-fast: false + matrix: + architecture: + - standard + - standard-with-dr + - large + - extra-large + version: + - 2021.7.7 + - 2023.6.0 + image: + - almalinux-cloud/almalinux-8 + steps: + - name: "Checkout Source" + uses: actions/checkout@v2 + + - name: "Activate Ruby 2.7" + uses: ruby/setup-ruby@v1 + with: + ruby-version: "2.7" + bundler-cache: true + + - name: "Print bundle environment" + if: ${{ github.repository_owner == 'puppetlabs' }} + run: | + echo ::group::info:bundler + bundle env + echo ::endgroup:: + + - name: 'Provision test cluster (specified architecture and a spare replica)' + timeout-minutes: 15 + run: | + echo ::group::prepare + mkdir -p $HOME/.ssh + echo 'Host *' > $HOME/.ssh/config + echo ' ServerAliveInterval 150' >> $HOME/.ssh/config + echo ' ServerAliveCountMax 2' >> $HOME/.ssh/config + bundle exec rake spec_prep + echo ::endgroup:: + + echo ::group::provision + bundle exec bolt plan run peadm_spec::provision_test_cluster \ + --modulepath spec/fixtures/modules \ + provider=provision_service \ + image=${{ matrix.image }} \ + architecture=${{ matrix.architecture }}-and-spare-replica + echo ::endgroup:: + + echo ::group::info:request + cat request.json || true; echo + echo ::endgroup:: + + echo ::group::info:inventory + sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true + echo ::endgroup:: + + - name: "Install PE on test cluster" + timeout-minutes: 120 + run: | + bundle exec bolt plan run peadm_spec::install_test_cluster \ + --inventoryfile spec/fixtures/litmus_inventory.yaml \ + --modulepath spec/fixtures/modules \ + architecture=${{ matrix.architecture }} \ + version=${{ matrix.version }} \ + code_manager_auto_configure=true + + - name: 'Run add_replica plan' + timeout-minutes: 60 + run: | + bundle exec bolt plan run peadm_spec::add_replica -v \ + --inventoryfile spec/fixtures/litmus_inventory.yaml \ + --modulepath spec/fixtures/modules \ + --stream + + - name: 'Tear down test cluster' + if: ${{ always() }} + continue-on-error: true + run: | + if [ -f spec/fixtures/litmus_inventory.yaml ]; then + echo ::group::tear_down + bundle exec rake 'litmus:tear_down' + echo ::endgroup:: + + echo ::group::info:request + cat request.json || true; echo + echo ::endgroup:: + fi diff --git a/.github/workflows/test-add-replica.yaml b/.github/workflows/test-add-replica.yaml index cc6c3297..6e92e0c3 100644 --- a/.github/workflows/test-add-replica.yaml +++ b/.github/workflows/test-add-replica.yaml @@ -5,21 +5,21 @@ on: workflow_dispatch: inputs: image: - description: 'GCP image for test cluster' + description: "GCP image for test cluster" required: true - default: 'almalinux-cloud/almalinux-8' + default: "almalinux-cloud/almalinux-8" architecture: - description: 'PE architecture to test' + description: "PE architecture to test" required: true - default: 'standard' + default: "standard" version: - description: 'PE version to install' + description: "PE version to install" required: true - default: '2021.7.8' + default: "2021.7.8" ssh-debugging: - description: 'Boolean; whether or not to pause for ssh debugging' + description: "Boolean; whether or not to pause for ssh debugging" required: true - default: 'false' + default: "false" jobs: test-add-replica: @@ -28,7 +28,7 @@ jobs: env: BOLT_GEM: true BOLT_DISABLE_ANALYTICS: true - LANG: 'en_US.UTF-8' + LANG: "en_US.UTF-8" strategy: fail-fast: false matrix: @@ -40,7 +40,7 @@ jobs: - "${{ github.event.inputs.image }}" steps: - - name: 'Start SSH session' + - name: "Start SSH session" if: ${{ github.event.inputs.ssh-debugging == 'true' }} uses: luchihoratiu/debug-via-ssh@main with: @@ -63,7 +63,7 @@ jobs: bundle env echo ::endgroup:: - - name: 'Provision test cluster (specified architecture with added DR)' + - name: "Provision test cluster (specified architecture with spare replica)" timeout-minutes: 15 run: | echo ::group::prepare @@ -79,7 +79,7 @@ jobs: --modulepath spec/fixtures/modules \ provider=provision_service \ image=${{ matrix.image }} \ - architecture=${{ matrix.architecture }}-with-dr + architecture=${{ matrix.architecture }}-and-spare-replica echo ::endgroup:: echo ::group::info:request @@ -90,7 +90,7 @@ jobs: sed -e 's/password: .*/password: "[redacted]"/' < spec/fixtures/litmus_inventory.yaml || true echo ::endgroup:: - - name: 'Install PE on test cluster' + - name: "Install PE on test cluster" timeout-minutes: 120 run: | bundle exec bolt plan run peadm_spec::install_test_cluster \ @@ -100,14 +100,15 @@ jobs: version=${{ matrix.version }} \ console_password=${{ secrets.CONSOLE_PASSWORD }} - - name: 'Run add_replica plan' - timeout-minutes: 30 + - name: "Run add_replica plan" + timeout-minutes: 60 run: | bundle exec bolt plan run peadm_spec::add_replica -v \ --inventoryfile spec/fixtures/litmus_inventory.yaml \ - --modulepath spec/fixtures/modules + --modulepath spec/fixtures/modules \ + --stream - - name: 'Wait as long as the file ${HOME}/pause file is present' + - name: "Wait as long as the file ${HOME}/pause file is present" if: ${{ always() && github.event.inputs.ssh-debugging == 'true' }} run: | while [ -f "${HOME}/pause" ] ; do @@ -116,7 +117,7 @@ jobs: done echo "${HOME}/pause absent, continuing workflow." - - name: 'Tear down test cluster' + - name: "Tear down test cluster" if: ${{ always() }} continue-on-error: true run: | diff --git a/plans/add_replica.pp b/plans/add_replica.pp index 95bfb5e1..8cc9b812 100644 --- a/plans/add_replica.pp +++ b/plans/add_replica.pp @@ -90,10 +90,10 @@ } run_plan('peadm::util::update_classification', $primary_target, - server_a_host => $replica_avail_group_letter ? { 'A' => $replica_host, default => undef }, - server_b_host => $replica_avail_group_letter ? { 'B' => $replica_host, default => undef }, - internal_compiler_a_pool_address => $replica_avail_group_letter ? { 'A' => $replica_host, default => undef }, - internal_compiler_b_pool_address => $replica_avail_group_letter ? { 'B' => $replica_host, default => undef }, + server_a_host => $replica_avail_group_letter ? { 'A' => $replica_target.peadm::certname(), default => undef }, + server_b_host => $replica_avail_group_letter ? { 'B' => $replica_target.peadm::certname(), default => undef }, + internal_compiler_a_pool_address => $replica_avail_group_letter ? { 'A' => $replica_target.peadm::certname(), default => undef }, + internal_compiler_b_pool_address => $replica_avail_group_letter ? { 'B' => $replica_target.peadm::certname(), default => undef }, peadm_config => $peadm_config ) diff --git a/spec/acceptance/peadm_spec/plans/add_replica.pp b/spec/acceptance/peadm_spec/plans/add_replica.pp index b2b053d8..7fc0f869 100644 --- a/spec/acceptance/peadm_spec/plans/add_replica.pp +++ b/spec/acceptance/peadm_spec/plans/add_replica.pp @@ -9,7 +9,7 @@ } $primary_host = $t.filter |$n| { $n.vars['role'] == 'primary' } - $replica_host = $t.filter |$n| { $n.vars['role'] == 'replica' } + $replica_host = $t.filter |$n| { $n.vars['role'] == 'spare-replica' } $replica_postgresql_host = $t.filter |$n| { $n.vars['role'] == 'replica-pdb-postgresql' } if $replica_host == [] { diff --git a/spec/acceptance/peadm_spec/plans/provision_test_cluster.pp b/spec/acceptance/peadm_spec/plans/provision_test_cluster.pp index a3a18d4e..9f4082d1 100644 --- a/spec/acceptance/peadm_spec/plans/provision_test_cluster.pp +++ b/spec/acceptance/peadm_spec/plans/provision_test_cluster.pp @@ -11,12 +11,24 @@ 'standard-with-dr': { ['primary', 'replica'] } + 'standard-and-spare-replica': { + ['primary', 'spare-replica'] + } + 'standard-with-dr-and-spare-replica': { + ['primary', 'replica', 'spare-replica'] + } 'large': { ['primary', 'compiler'] } 'large-with-dr': { ['primary', 'compiler', 'replica', 'compiler'] } + 'large-and-spare-replica': { + ['primary', 'compiler', 'compiler', 'spare-replica'] + } + 'large-with-dr-and-spare-replica': { + ['primary', 'compiler', 'replica', 'compiler', 'spare-replica'] + } 'extra-large': { ['primary', 'primary-pdb-postgresql', 'compiler'] } @@ -29,6 +41,9 @@ 'extra-large-with-extra-compiler': { ['primary', 'primary-pdb-postgresql', 'compiler', 'unconfigured-compiler'] } + 'extra-large-and-spare-replica': { + ['primary', 'primary-pdb-postgresql', 'compiler', 'compiler', 'spare-replica'] + } 'extra-large-with-dr-and-spare-replica': { ['primary', 'primary-pdb-postgresql', 'compiler', 'replica', 'replica-pdb-postgresql', 'compiler', 'spare-replica']