-
Notifications
You must be signed in to change notification settings - Fork 100
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Splitting functional tests as cloud and non-cloud (#7716)
The goal of this PR is to create another workflow to run functional tests that don't use cloud resources and also remove the non-cloud tests from the existing functional test workflow that requires approval. In brief: 1. Workflow: **functional-test-cloud** (This requires an approval) 2. Workflow: **functional-test-noncloud** (This doesn't require an approval and it should be enabled on forks) **RP tests that use cloud resources:** * Core * DataStores * UCP **RP tests that use non-cloud resources:** * CLI * Core * Dapr * DataStores * Kubernetes * Messaging * Samples * UCP - This pull request adds or changes features of Radius and has an approved issue (issue link required). Fixes: #7624 --------- Signed-off-by: ytimocin <[email protected]>
- Loading branch information
Showing
33 changed files
with
979 additions
and
345 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
name: "Create a KinD cluster" | ||
description: | | ||
Create a KinD cluster. | ||
inputs: | ||
secure: | ||
description: "Whether the KinD cluster should be created with a secure local registry configuration" | ||
required: false | ||
default: "false" | ||
temp-cert-dir: | ||
description: "The temporary directory where the certificates are stored" | ||
required: false | ||
default: "" | ||
kind-version: | ||
description: "The version of KinD to install" | ||
required: false | ||
default: "v0.23.0" | ||
with-local-registry: | ||
description: "Whether the KinD cluster should be created with a local registry configuration" | ||
required: false | ||
default: "false" | ||
registry-name: | ||
description: "The name of the local registry" | ||
required: true | ||
default: "radius-registry" | ||
registry-server: | ||
description: "The server name for the local registry" | ||
required: true | ||
default: "localhost" | ||
registry-port: | ||
description: "The port for the local registry" | ||
required: true | ||
default: "5000" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Install KinD | ||
shell: bash | ||
run: | | ||
curl -sSLo "kind" "https://github.com/kubernetes-sigs/kind/releases/download/${{ inputs.kind-version }}/kind-linux-amd64" | ||
chmod +x ./kind | ||
- name: Create a KinD cluster without a local registry | ||
if: ${{ inputs.with-local-registry == 'false' }} | ||
shell: bash | ||
run: | | ||
# https://kind.sigs.k8s.io/docs/user/local-registry/ | ||
cat <<EOF | kind create cluster --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
EOF | ||
- name: Create a KinD cluster with an insecure local registry | ||
if: ${{ inputs.with-local-registry == 'true' && inputs.secure == 'false' }} | ||
shell: bash | ||
run: | | ||
cat <<EOF | kind create cluster --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
containerdConfigPatches: | ||
- |- | ||
[plugins."io.containerd.grpc.v1.cri".registry] | ||
config_path = "/etc/containerd/certs.d" | ||
EOF | ||
REGISTRY_DIR="/etc/containerd/certs.d/localhost:${{ inputs.registry-port }}" | ||
for node in $(kind get nodes); do | ||
docker exec "${node}" mkdir -p "${REGISTRY_DIR}" | ||
cat <<EOF | docker exec -i "${node}" cp /dev/stdin "${REGISTRY_DIR}/hosts.toml" | ||
[host."http://${{ inputs.registry-name }}:5000"] | ||
EOF | ||
done | ||
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${{ inputs.registry-name }}")" = 'null' ]; then | ||
docker network connect "kind" "${reg_name}" | ||
fi | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: local-registry-hosting | ||
namespace: kube-public | ||
data: | ||
localRegistryHosting.v1: | | ||
host: "localhost:${{ inputs.registry-port }}" | ||
help: "https://kind.sigs.k8s.io/docs/user/local-registry/" | ||
EOF | ||
# Reference: https://kind.sigs.k8s.io/docs/user/local-registry/ | ||
- name: Create a KinD cluster with a secure local registry | ||
if: ${{ inputs.with-local-registry == 'true' && inputs.secure == 'true' }} | ||
shell: bash | ||
run: | | ||
# Create the cluster with necessary configurations for the secure local registry | ||
cat <<EOF | kind create cluster --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
nodes: | ||
- role: control-plane | ||
extraMounts: | ||
- containerPath: "/etc/containerd/certs.d/${{ inputs.registry-name }}" | ||
hostPath: "${{ inputs.temp-cert-dir }}/certs/${{ inputs.registry-server }}" | ||
containerdConfigPatches: | ||
- |- | ||
[plugins."io.containerd.grpc.v1.cri".registry] | ||
config_path = "/etc/containerd/certs.d" | ||
EOF | ||
# Create the directory for the certificates and add the certificate to the system trust store | ||
LOCALHOST_DIR="/etc/containerd/certs.d/${{ inputs.registry-server }}:${{ inputs.registry-port }}" | ||
RADIUS_DIR="/etc/containerd/certs.d/${{ inputs.registry-name }}:${{ inputs.registry-port }}" | ||
for node in $(kind get nodes); do | ||
docker exec "${node}" mkdir -p "${LOCALHOST_DIR}" | ||
cat <<EOF | docker exec -i "${node}" cp /dev/stdin "${LOCALHOST_DIR}/hosts.toml" | ||
[host."http://${{ inputs.registry-name }}:${{ inputs.registry-port }}"] | ||
capabilities = ["pull", "resolve", "push"] | ||
skip_verify = true | ||
EOF | ||
docker exec "${node}" mkdir -p "${RADIUS_DIR}" | ||
cat <<EOF | docker exec -i "${node}" cp /dev/stdin "${RADIUS_DIR}/hosts.toml" | ||
[host."http://${{ inputs.registry-name }}:${{ inputs.registry-port }}"] | ||
capabilities = ["pull", "resolve", "push"] | ||
skip_verify = true | ||
EOF | ||
docker exec "${node}" systemctl restart containerd | ||
done | ||
# Connect the registry to the KinD network | ||
if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${{ inputs.registry-name }}")" = 'null' ]; then | ||
docker network connect "kind" "${{ inputs.registry-name }}" | ||
fi | ||
# Document the local registry | ||
cat <<EOF | kubectl apply -f - | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: local-registry-hosting | ||
namespace: kube-public | ||
data: | ||
localRegistryHosting.v1: | | ||
host: "${{ inputs.registry-name }}:${{ inputs.registry-port }}" | ||
help: "https://kind.sigs.k8s.io/docs/user/local-registry/" | ||
EOF |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
name: "Create a local registry" | ||
description: | | ||
This action creates a local registry for the images to be pushed to. | ||
It uses the `docker` CLI to create a registry container and then starts it. | ||
The registry is then available at `localhost:5000` by default. | ||
inputs: | ||
secure: | ||
description: "Whether the registry should be secure or not" | ||
required: false | ||
default: "false" | ||
registry-name: | ||
description: "The name of the local registry" | ||
required: false | ||
default: "radius-registry" | ||
registry-server: | ||
description: "The server name for the local registry" | ||
required: false | ||
default: "localhost" | ||
registry-port: | ||
description: "The port for the local registry" | ||
required: false | ||
default: "5000" | ||
outputs: | ||
temp-cert-dir: | ||
description: "The temporary directory where the certificates are stored" | ||
value: ${{ steps.create-temp-cert-dir.outputs.TEMP_CERT_DIR }} | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Create temporary directory for certificates | ||
if: ${{ inputs.secure == 'true' }} | ||
shell: bash | ||
id: create-temp-cert-dir | ||
run: | | ||
# Create a temporary directory to store the certificates | ||
temp_cert_dir=$(mktemp -d 2>/dev/null || mktemp -d -t 'temp_cert_dir') | ||
echo "TEMP_CERT_DIR=$temp_cert_dir" >> $GITHUB_OUTPUT | ||
- name: Create certificates for local registry | ||
if: ${{ inputs.secure == 'true' }} | ||
shell: bash | ||
run: | | ||
create_openssl_cfg() { | ||
CFG=$( | ||
cat <<'EOF' | ||
[req] | ||
distinguished_name = subject | ||
x509_extensions = x509_ext | ||
prompt = no | ||
[subject] | ||
CN = localhost | ||
[x509_ext] | ||
basicConstraints = critical, CA:TRUE | ||
subjectKeyIdentifier = hash | ||
authorityKeyIdentifier = keyid:always, issuer:always | ||
keyUsage = critical, cRLSign, digitalSignature, keyCertSign | ||
nsComment = "OpenSSL Generated Certificate" | ||
subjectAltName = @alt_names | ||
[alt_names] | ||
DNS.1 = ${{ inputs.registry-name }} | ||
DNS.2 = ${{ inputs.registry-server }} | ||
EOF | ||
) | ||
echo "$CFG" | ||
} | ||
TEMP_CERT_DIR=${{ steps.create-temp-cert-dir.outputs.TEMP_CERT_DIR }} | ||
pushd $TEMP_CERT_DIR | ||
# Create the directory for the certificates | ||
mkdir -p certs/${{ inputs.registry-server }} | ||
echo "==== Generate the openssl config" | ||
create_openssl_cfg >req.cnf | ||
echo "==== Create the self signed certificate certificate and client key files" | ||
openssl req -x509 \ | ||
-nodes \ | ||
-days 365 \ | ||
-newkey rsa:4096 \ | ||
-keyout certs/${{ inputs.registry-server }}/client.key \ | ||
-out certs/${{ inputs.registry-server }}/client.crt \ | ||
-config req.cnf \ | ||
-sha256 | ||
- name: Add the certificate to the system trust store | ||
if: ${{ inputs.secure == 'true' }} | ||
shell: bash | ||
run: | | ||
TEMP_CERT_DIR=${{ steps.create-temp-cert-dir.outputs.TEMP_CERT_DIR }} | ||
sudo apt install ca-certificates | ||
sudo cp $TEMP_CERT_DIR/certs/${{ inputs.registry-server }}/client.crt /usr/local/share/ca-certificates/${{ inputs.registry-server }}.crt | ||
sudo cp $TEMP_CERT_DIR/certs/${{ inputs.registry-server }}/client.crt /usr/local/share/ca-certificates/${{ inputs.registry-name }}.crt | ||
sudo update-ca-certificates | ||
- name: Create secure Docker registry | ||
if: ${{ inputs.secure == 'true' }} | ||
shell: bash | ||
run: | | ||
TEMP_CERT_DIR=${{ steps.create-temp-cert-dir.outputs.TEMP_CERT_DIR }} | ||
echo "==== Create secure Docker registry" | ||
docker run -d \ | ||
-p ${{ inputs.registry-port }}:5000 \ | ||
--restart=always \ | ||
--name ${{ inputs.registry-name }} \ | ||
-v $TEMP_CERT_DIR/certs/${{ inputs.registry-server }}:/certs \ | ||
-e REGISTRY_HTTP_TLS_CERTIFICATE=/certs/client.crt \ | ||
-e REGISTRY_HTTP_TLS_KEY=/certs/client.key \ | ||
registry:2 | ||
- name: Create insecure Docker registry | ||
if: ${{ inputs.secure == 'false' }} | ||
shell: bash | ||
run: | | ||
echo "==== Create insecure Docker registry" | ||
docker run -d \ | ||
-p ${{ inputs.registry-port }}:5000 \ | ||
--restart=always \ | ||
--name ${{ inputs.registry-name }} \ | ||
registry:2 |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -35,4 +35,3 @@ runs: | |
shell: bash | ||
run: chmod +x rad | ||
working-directory: dist | ||
|
This file contains 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
Oops, something went wrong.