Feat: revert ci to kind (#6035)

* Feat: revert ci to kind

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* feat: use internal runner

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

* fix test bug

Signed-off-by: Somefive <yd219913@alibaba-inc.com>

---------

Signed-off-by: Somefive <yd219913@alibaba-inc.com>
This commit is contained in:
Somefive
2023-05-25 17:49:44 +08:00
committed by GitHub
parent ef4bb07fb3
commit 2298dd73dc
13 changed files with 65 additions and 108 deletions
+4 -5
View File
@@ -32,11 +32,10 @@ jobs:
with:
submodules: true
- name: Setup K3d
uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96
with:
version: v1.26
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: Setup KinD
run: |
go install sigs.k8s.io/kind@v0.19.0
kind create cluster
- name: Definition Doc generate check
run: |
+12 -40
View File
@@ -57,10 +57,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install make gcc jq ca-certificates curl gnupg -y
snap remove docker --purge || true
snap install docker --channel=core18/stable
snap install kubectl --classic
snap install helm --classic
sudo snap install kubectl --classic
sudo snap install helm --classic
- name: Setup Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
@@ -71,43 +69,19 @@ jobs:
run: |
go get -v -t -d ./...
- name: Tear down K3d if exist
- name: Setup KinD
run: |
k3d cluster delete || true
k3d cluster delete worker || true
go install sigs.k8s.io/kind@v0.19.0
kind delete cluster --name worker || true
kind create cluster --name worker --image=kindest/node:v1.26.4
kind export kubeconfig --internal --name worker --kubeconfig /tmp/worker.kubeconfig
kind delete cluster || true
kind create cluster --image=kindest/node:v1.26.4
- name: Calculate K3d args
- name: Load image
run: |
EGRESS_ARG=""
if [[ "${{ matrix.k8s-version }}" == v1.26 ]]; then
EGRESS_ARG="--k3s-arg --egress-selector-mode=disabled@server:0"
fi
echo "EGRESS_ARG=${EGRESS_ARG}" >> $GITHUB_ENV
- name: Setup K3d (Hub)
uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96
with:
version: ${{ matrix.k8s-version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
k3d-args: ${{ env.EGRESS_ARG }}
- name: Setup K3d (Worker)
uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96
with:
version: ${{ matrix.k8s-version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
k3d-name: worker
k3d-args: --kubeconfig-update-default=false --network=k3d-k3s-default ${{ env.EGRESS_ARG }}
- name: Generating internal worker kubeconfig
run: |
internal_ip=$(docker network inspect k3d-k3s-default|jq ".[0].Containers"| jq -r '.[]| select(.Name=="k3d-worker-server-0")|.IPv4Address' | cut -d/ -f1)
k3d kubeconfig get worker > /tmp/worker.client.kubeconfig
cp /tmp/worker.client.kubeconfig /tmp/worker.kubeconfig
sed -i "s/0.0.0.0:[0-9]\+/$internal_ip:6443/" /tmp/worker.kubeconfig
- name: Load image to k3d cluster (hub and worker)
run: make image-load
mkdir -p $HOME/tmp/
TMPDIR=$HOME/tmp/ make image-load
- name: Cleanup for e2e tests
run: |
@@ -140,5 +114,3 @@ jobs:
run: |
make image-cleanup
docker image prune -f --filter "until=24h"
docker network prune -f --filter "until=24h"
ifconfig | grep br- | awk '{print substr($1, 1, length($1)-1)}' | awk '{system("ifconfig "$1" down")}'
+15 -24
View File
@@ -57,9 +57,8 @@ jobs:
run: |
sudo apt-get update
sudo apt-get install make gcc jq ca-certificates curl gnupg -y
snap install docker --channel=core18/stable
snap install kubectl --classic
snap install helm --classic
sudo snap install kubectl --classic
sudo snap install helm --classic
- name: Setup Go
uses: actions/setup-go@fac708d6674e30b6ba41289acaab6d4b75aa0753
@@ -70,33 +69,27 @@ jobs:
run: |
go get -v -t -d ./...
- name: Setup KinD
run: |
go install sigs.k8s.io/kind@v0.19.0
kind delete cluster || true
kind create cluster
- name: Get Ginkgo
run: |
go install github.com/onsi/ginkgo/v2/ginkgo
go get github.com/onsi/gomega/...
- name: Tear down K3d if exist
- name: Setup KinD
run: |
k3d cluster delete || true
k3d cluster delete worker || true
go install sigs.k8s.io/kind@v0.19.0
kind delete cluster --name kind || true
kind create cluster --name kind --image=kindest/node:v1.26.4
- name: Calculate K3d args
- name: Load image
run: |
EGRESS_ARG=""
if [[ "${{ matrix.k8s-version }}" == v1.26 ]]; then
EGRESS_ARG="--k3s-arg --egress-selector-mode=disabled@server:0"
fi
echo "EGRESS_ARG=${EGRESS_ARG}" >> $GITHUB_ENV
- name: Setup K3d
uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96
with:
version: ${{ matrix.k8s-version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
k3d-args: ${{ env.EGRESS_ARG }}
- name: Load image to k3d cluster
run: make image-load
mkdir -p $HOME/tmp/
TMPDIR=$HOME/tmp/ make image-load
- name: Run Make
run: make
@@ -135,5 +128,3 @@ jobs:
run: |
make image-cleanup
docker image prune -f --filter "until=24h"
docker network prune -f --filter "until=24h"
ifconfig | grep br- | awk '{print substr($1, 1, length($1)-1)}' | awk '{system("ifconfig "$1" down")}'
+4 -8
View File
@@ -115,15 +115,11 @@ jobs:
key: ${{ runner.os }}-pkg-${{ hashFiles('**/go.sum') }}
restore-keys: ${{ runner.os }}-pkg-
- name: Tear down K3d if exist
- name: Setup KinD
run: |
k3d cluster delete || true
- name: Setup K3d (Hub)
uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96
with:
version: ${{ matrix.k8s-version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
go install sigs.k8s.io/kind@v0.19.0
kind delete cluster --name kind || true
kind create cluster --name kind --image=kindest/node:v1.26.4 --kubeconfig ~/.kube/config
- name: Run cross-build
run: make cross-build
+4 -6
View File
@@ -65,13 +65,11 @@ jobs:
sudo apt-get update
sudo apt-get install -y golang-ginkgo-dev
- name: Setup K3d
uses: nolar/setup-k3d-k3s@293b8e5822a20bc0d5bcdd4826f1a665e72aba96
with:
version: v1.26
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Setup KinD
run: |
go install sigs.k8s.io/kind@v0.19.0
kind create cluster
# TODO need update action version to resolve node 12 deprecated.
- name: install Kubebuilder
uses: RyanSiu1995/kubebuilder-action@ed0e300b13152c2c2bfb104475665c7bf609332f
with:
+4 -4
View File
@@ -94,18 +94,18 @@ endif
endif
## image-load: load docker image to the k3d cluster
## image-load: load docker image to the kind cluster
image-load:
docker build -t $(VELA_CORE_TEST_IMAGE) -f Dockerfile.e2e .
k3d image import $(VELA_CORE_TEST_IMAGE) || { echo >&2 "kind not installed or error loading image: $(VELA_CORE_TEST_IMAGE)"; exit 1; }
kind load docker-image $(VELA_CORE_TEST_IMAGE) || { echo >&2 "kind not installed or error loading image: $(VELA_CORE_TEST_IMAGE)"; exit 1; }
## image-load-runtime-cluster: Load the run-time cluster image
image-load-runtime-cluster:
/bin/sh hack/e2e/build_runtime_rollout.sh
docker build -t $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE) -f runtime/rollout/e2e/Dockerfile.e2e runtime/rollout/e2e/
rm -rf runtime/rollout/e2e/tmp
k3d image import $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE) || { echo >&2 "kind not installed or error loading image: $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE)"; exit 1; }
k3d cluster get $(RUNTIME_CLUSTER_NAME) && k3d image import $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE) --cluster=$(RUNTIME_CLUSTER_NAME) || echo "no worker cluster"
kind load docker-image $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE) || { echo >&2 "kind not installed or error loading image: $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE)"; exit 1; }
kind load docker-image $(VELA_RUNTIME_ROLLOUT_TEST_IMAGE) --name=$(RUNTIME_CLUSTER_NAME) || echo "no worker cluster"
## core-test: Run tests
core-test:
-3
View File
@@ -290,9 +290,6 @@ var VelaQLPodListContext = func(context string, velaQL string) bool {
if v.Status.Phase != "" {
gomega.Expect(v.Status.Phase).To(gomega.ContainSubstring("Running"))
}
if v.Status.NodeName != "" {
gomega.Expect(v.Status.NodeName).To(gomega.ContainSubstring("k3d-k3s-default-server-0"))
}
if v.Metadata.Namespace != "" {
gomega.Expect(v.Metadata.Namespace).To(gomega.ContainSubstring("default"))
}
+6 -5
View File
@@ -1,20 +1,21 @@
. ./hack/e2e/end_e2e_core.sh
OAM_CONTAINER_ID=$(docker exec k3d-k3s-default-server-0 crictl ps | grep oam-runtime | grep --regexp '^.............' -o)
OAM_DOCKER_DIR=$(docker exec k3d-k3s-default-server-0 crictl inspect --output go-template --template '{{range .info.runtimeSpec.mounts}}{{if (eq .destination "/workspace/data")}}{{.source}}{{end}}{{end}}' "${OAM_CONTAINER_ID}")
DOCKER_CONTAINER=kind-control-plane
OAM_CONTAINER_ID=$(docker exec $DOCKER_CONTAINER crictl ps | grep oam-runtime | grep --regexp '^.............' -o)
OAM_DOCKER_DIR=$(docker exec $DOCKER_CONTAINER crictl inspect --output go-template --template '{{range .info.runtimeSpec.mounts}}{{if (eq .destination "/workspace/data")}}{{.source}}{{end}}{{end}}' "${OAM_CONTAINER_ID}")
echo "${OAM_CONTAINER_ID}"
echo "${OAM_DOCKER_DIR}"
docker exec k3d-k3s-default-server-0 crictl exec "${OAM_CONTAINER_ID}" kill -2 1
docker exec $DOCKER_CONTAINER crictl exec "${OAM_CONTAINER_ID}" kill -2 1
file=$OAM_DOCKER_DIR/e2e-profile.out
echo "$file"
n=1
while [ $n -le 60 ];do
if_exist=$(docker exec k3d-k3s-default-server-0 sh -c "test -f $file && echo 'ok'")
if_exist=$(docker exec $DOCKER_CONTAINER sh -c "test -f $file && echo 'ok'")
echo "$if_exist"
if [ -n "$if_exist" ];then
docker exec k3d-k3s-default-server-0 cat "$file" > /tmp/oam-e2e-profile.out
docker exec $DOCKER_CONTAINER cat "$file" > /tmp/oam-e2e-profile.out
break
fi
echo file not generated yet
+6 -5
View File
@@ -1,19 +1,20 @@
CORE_NAME="${CORE_NAME:-kubevela}"
CONTAINER_ID=$(docker exec k3d-k3s-default-server-0 crictl ps | grep $CORE_NAME'\s' | grep --regexp '^.............' -o)
DOCKER_DIR=$(docker exec k3d-k3s-default-server-0 crictl inspect --output go-template --template '{{range .info.runtimeSpec.mounts}}{{if (eq .destination "/workspace/data")}}{{.source}}{{end}}{{end}}' "${CONTAINER_ID}")
DOCKER_CONTAINER=kind-control-plane
CONTAINER_ID=$(docker exec $DOCKER_CONTAINER crictl ps | grep $CORE_NAME'\s' | grep --regexp '^.............' -o)
DOCKER_DIR=$(docker exec $DOCKER_CONTAINER crictl inspect --output go-template --template '{{range .info.runtimeSpec.mounts}}{{if (eq .destination "/workspace/data")}}{{.source}}{{end}}{{end}}' "${CONTAINER_ID}")
echo "${CONTAINER_ID}"
echo "${DOCKER_DIR}"
docker exec k3d-k3s-default-server-0 crictl exec "${CONTAINER_ID}" kill -2 1
docker exec $DOCKER_CONTAINER crictl exec "${CONTAINER_ID}" kill -2 1
file=$DOCKER_DIR/e2e-profile.out
echo "$file"
n=1
while [ $n -le 60 ];do
if_exist=$(docker exec k3d-k3s-default-server-0 sh -c "test -f $file && echo 'ok'")
if_exist=$(docker exec $DOCKER_CONTAINER sh -c "test -f $file && echo 'ok'")
echo "$if_exist"
if [ -n "$if_exist" ];then
docker exec k3d-k3s-default-server-0 cat "$file" >> /tmp/e2e-profile.out
docker exec $DOCKER_CONTAINER cat "$file" >> /tmp/e2e-profile.out
break
fi
echo file not generated yet
-1
View File
@@ -78,7 +78,6 @@ setup-runtime-e2e-cluster:
--set optimize.disableComponentRevision=false \
./runtime/rollout/charts
k3d cluster get $(RUNTIME_CLUSTER_NAME) && \
helm upgrade --install \
--create-namespace \
--namespace vela-system \
@@ -22,6 +22,8 @@ import (
"fmt"
"time"
"k8s.io/klog/v2"
"github.com/oam-dev/kubevela/pkg/oam/testutil"
. "github.com/onsi/ginkgo/v2"
@@ -351,6 +353,9 @@ spec:
name := fmt.Sprintf("component-%s%s", types.CapabilityConfigMapNamePrefix, componentDefinitionName)
Eventually(func() bool {
err := k8sClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: name}, &cm)
if err != nil {
klog.ErrorS(err, "failed to get configmap")
}
return err == nil
}, 10*time.Second, time.Second).Should(BeTrue())
Expect(cm.Data[types.OpenapiV3JSONSchema]).Should(Not(Equal("")))
@@ -30,6 +30,7 @@ import (
apierrors "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/types"
"k8s.io/klog/v2"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/reconcile"
"sigs.k8s.io/yaml"
@@ -107,9 +108,12 @@ var _ = Describe("Test DefinitionRevision created by ComponentDefinition", func(
var cdGet v1beta1.ComponentDefinition
Eventually(func() bool {
if err := k8sClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: cdName}, &cdGet); err == nil {
err := k8sClient.Get(ctx, client.ObjectKey{Namespace: namespace, Name: cdName}, &cdGet)
if err == nil {
klog.Infof("component definition %s status: %v", cdName, cdGet.Status)
return len(cdGet.Status.Conditions) > 0 && cdGet.Status.Conditions[0].Status == v1.ConditionTrue && cdGet.Status.ConfigMapRef == schemeCMName
}
klog.ErrorS(err, "unable to get component definition")
return false
}, 10*time.Second, time.Second).Should(BeTrue())
-6
View File
@@ -44,12 +44,6 @@ import (
var ResponseString = "Hello HTTP Get."
func TestInitBaseRestConfig(t *testing.T) {
args, err := InitBaseRestConfig()
assert.NotNil(t, t, args)
assert.NoError(t, err, "you need to have a kubeconfig in your Environment")
}
func TestHTTPGet(t *testing.T) {
type want struct {
data string