Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.github/workflows: Add CLI installation checks. #651

Merged
merged 1 commit into from
Jun 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 }}
kfirtoledo marked this conversation as resolved.
Show resolved Hide resolved
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
Loading