Skip to content

Commit

Permalink
SecureComms: Add testing facility for e2e tests
Browse files Browse the repository at this point in the history
Modify the .github/workflow files to enable addting e2e tests for secure
comms.

Signed-off-by: David Hadas <[email protected]>
Signed-off-by: David Hadas <[email protected]>
  • Loading branch information
davidhIBM authored and davidhadas committed Nov 9, 2024
1 parent 8e08587 commit 5a2f1c2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/e2e_libvirt.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ on:
description: Git ref to checkout the cloud-api-adaptor repository. Defaults to main.
required: false
type: string

secure_comms:
default: 'none'
description: SecureComms configuration. Defaults to none.
required: false
type: string
env:
CLOUD_PROVIDER: libvirt
DEBIAN_FRONTEND: noninteractive
Expand Down Expand Up @@ -86,6 +90,7 @@ jobs:

- name: Config Libvirt
run: |
export TEST_E2E_SECURE_COMMS="${{ inputs.secure_comms }}"
./libvirt/config_libvirt.sh
echo "CAA_IMAGE=\"${{ inputs.caa_image }}\"" >> libvirt.properties
# For debugging
Expand Down Expand Up @@ -124,6 +129,7 @@ jobs:
export TEST_PROVISION_FILE="$PWD/libvirt.properties"
export TEST_PODVM_IMAGE="${{ env.PODVM_QCOW2 }}"
export TEST_E2E_TIMEOUT="75m"
export TEST_E2E_SECURE_COMMS="${{ inputs.secure_comms }}"
make test-e2e
Expand Down
16 changes: 9 additions & 7 deletions .github/workflows/e2e_run_all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ jobs:
prep_install:
needs: [image]
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.matrix.outputs.matrix }}
env:
PROVIDERS: "libvirt"
steps:
Expand Down Expand Up @@ -148,6 +150,11 @@ jobs:
path: src/cloud-api-adaptor/install/
retention-days: 7

- name: Define Test Matrix
id: matrix
run: |
echo "matrix=$(jq -c . < ./libvirt/e2e_matrix_libvirt.json)" >> "$GITHUB_OUTPUT"
# Run libvirt e2e tests if pull request labeled 'test_e2e_libvirt'
libvirt:
name: libvirt
Expand All @@ -158,17 +165,12 @@ jobs:
needs: [podvm, image, prep_install]
strategy:
fail-fast: false
matrix:
os:
- ubuntu
provider:
- generic
arch:
- amd64
matrix: ${{ fromJSON(needs.prep_install.outputs.matrix) }}
uses: ./.github/workflows/e2e_libvirt.yaml
with:
caa_image: ${{ inputs.registry }}/cloud-api-adaptor:${{ inputs.caa_image_tag }}-dev
podvm_image: ${{ inputs.registry }}/podvm-${{ matrix.provider }}-${{ matrix.os }}-${{ matrix.arch }}:${{ inputs.podvm_image_tag }}
install_directory_artifact: install_directory
git_ref: ${{ inputs.git_ref }}
secure_comms: ${{ matrix.secure_comms }}
secrets: inherit
4 changes: 4 additions & 0 deletions src/cloud-api-adaptor/docs/SecureComms.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ Successful connection result in exit code of 0

Alternatively, the client and server can be separately executed in independent terminals using `./test/securecomms/double/wnssh.go` and `./test/securecomms/ppssh/main.go` respectively.

# E2E Testing

To facilitate end-to-end testing, the libvirt github workflow `e2e_libvirt.yaml` adds an environment variable named `TEST_E2E_SECURE_COMMS` which indicates the secure comm configuration set to be used. The `config_libvirt.sh` uses this environment variable to set proper values in the `libvirt.properties` file.

## Future Plans

- Add DeleteResource() support in KBS, KBC, api-server-rest, than cleanup resources added by Secure Comms to KBS whenever a Peer Pod fail to be created or when a Peer Pod is terminated.
Expand Down
12 changes: 12 additions & 0 deletions src/cloud-api-adaptor/libvirt/config_libvirt.sh
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@ installK8sclis() {
fi
}

TEST_E2E_SECURE_COMMS=${TEST_E2E_SECURE_COMMS:-none}.
echo "SECURE_COMMS is ${TEST_E2E_SECURE_COMMS}"

echo "Installing Go..."
installGolang
echo "Installing Libvirt..."
Expand All @@ -118,3 +121,12 @@ rm -f libvirt.properties
echo "libvirt_uri=\"qemu+ssh://${USER}@${IP}/system?no_verify=1\"" >> libvirt.properties
echo "libvirt_ssh_key_file=\"id_rsa\"" >> libvirt.properties
echo "CLUSTER_NAME=\"peer-pods\"" >> libvirt.properties

# switch to the appropriate e2e test and add configs to libvirt.properties as needed
case $TEST_E2E_SECURE_COMMS in

*)
echo "processing none"
echo "SECURE_COMMS=\"false\"" >> libvirt.properties
;;
esac
6 changes: 6 additions & 0 deletions src/cloud-api-adaptor/libvirt/e2e_matrix_libvirt.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"secure_comms": ["none"],
"os": ["ubuntu"],
"provider": ["generic"],
"arch": ["amd64"]
}

0 comments on commit 5a2f1c2

Please sign in to comment.