Skip to content

Commit

Permalink
Merge branch 'main' into cli
Browse files Browse the repository at this point in the history
  • Loading branch information
kfirtoledo authored Jun 26, 2024
2 parents edbd565 + ec85f75 commit 0b8082d
Show file tree
Hide file tree
Showing 4 changed files with 122 additions and 3 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
5 changes: 3 additions & 2 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ linters:
- bodyclose
- contextcheck
- durationcheck
- errcheck
- errcheck
- errname
- errorlint
- exportloopref
Expand Down Expand Up @@ -122,7 +122,8 @@ linters-settings:

output:
# prefer the simplest output: `line-number` without saving to file
format: line-number
formats:
- format: line-number
print-issued-lines: false
print-linter-name: true
# allow multiple reports per line
Expand Down
1 change: 0 additions & 1 deletion pkg/controlplane/control/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,6 @@ func generateJWKSecret() ([]byte, error) {
Type: "RSA PRIVATE KEY",
Bytes: x509.MarshalPKCS1PrivateKey(rsaKey),
})

if err != nil {
return nil, fmt.Errorf("cannot encode JWK key: %w", err)
}
Expand Down
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 0b8082d

Please sign in to comment.