Skip to content

Commit

Permalink
.github/workflows: Add CLI installation checks for differnt platforms (
Browse files Browse the repository at this point in the history
…#651)

Add installation check using the CLI, This test checks the CLI commands 
for creating certificates, deploying peers, and deleting them.

Signed-off-by: Kfir Toledo <[email protected]>
  • Loading branch information
kfirtoledo authored Jun 26, 2024
1 parent 2a7fd06 commit ec85f75
Show file tree
Hide file tree
Showing 2 changed files with 119 additions and 0 deletions.
39 changes: 39 additions & 0 deletions .github/workflows/pr-cli.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PR check - CLI Installation test
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
cli-test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

steps:
- name: checkout
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod
- name: Install kind
uses: helm/[email protected]
with:
install_only: true
- name: Run build
run: make build
- name: Build docker images
run: make docker-build
- name: Run installation test using CLI
run: ./tests/cli/basic_test.sh
- name: upload e2e k8s test logs
uses: actions/upload-artifact@v4
if: failure()
with:
name: tests-cli
path: /tmp/clusterlink-cli
80 changes: 80 additions & 0 deletions tests/cli/basic_test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env bash
# Copyright (c) The ClusterLink Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

set -ex

SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
TEST_DIR=$(mktemp -d)
CLI=$SCRIPT_DIR/../../bin/clusterlink

function clean_up {
kind delete cluster --name peer1

cd -
}

function clean_up_with_logs {
# export logs
kind export logs /tmp/clusterlink-cli --name peer1

clean_up
}

function test_k8s {
# create fabric with a single peer (peer1)
$CLI create fabric
$CLI create peer-cert --name peer1

# create kind cluster
kind create cluster --name peer1

# load images to cluster
kind load docker-image cl-controlplane --name peer1
kind load docker-image cl-dataplane --name peer1
kind load docker-image cl-operator --name peer1

# configure kubectl
kubectl config use-context kind-peer1

# wait for service account to be created
timeout 30 sh -c 'until kubectl -n default get serviceaccount default -o name; do sleep 0.1; done > /dev/null 2>&1'

# create clusterlink objects
$CLI deploy peer --name peer1 --container-registry=docker.io/library --ingress=NodePort --ingress-port=30443

# wait for cl-controlplane and cl-dataplane to be created
if ! timeout 30 sh -c 'until kubectl rollout status deployment cl-controlplane -n clusterlink-system; do sleep 0.1; done > /dev/null 2>&1'; then
echo "Error: Timeout occurred while waiting for cl-controlplane deployment"
exit 1
fi

if ! timeout 30 sh -c 'until kubectl rollout status deployment cl-dataplane -n clusterlink-system; do sleep 0.1; done > /dev/null 2>&1'; then
echo "Error: Timeout occurred while waiting for cl-dataplane deployment"
exit 1
fi

# Delete clusterlink objects
$CLI delete peer --name peer1

}

cd $TEST_DIR
clean_up

trap clean_up_with_logs INT TERM EXIT

cd $TEST_DIR
test_k8s

echo OK

0 comments on commit ec85f75

Please sign in to comment.