Skip to content

Commit

Permalink
Merge pull request #1173 from NeerajNagure/dryrun-migration
Browse files Browse the repository at this point in the history
Migration for dryrun tests to e2e
  • Loading branch information
k8s-ci-robot committed Jul 22, 2024
2 parents bfd571c + 80a6e5d commit 368079d
Show file tree
Hide file tree
Showing 45 changed files with 445 additions and 72 deletions.
45 changes: 45 additions & 0 deletions test/e2e/export_logs.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
Copyright 2024 The Kubernetes 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.
*/

package e2e

import (
"context"
"runtime"
"testing"

"sigs.k8s.io/e2e-framework/pkg/envconf"
"sigs.k8s.io/e2e-framework/pkg/features"
)

func CaseDryRunExportLogs(kwokctlPath, clusterName, clusterRuntime string, rootDir string, updateTestdata bool) *features.FeatureBuilder {
return features.New("Dryrun Export Logs").
Assess("test dryrun export logs", func(ctx context.Context, t *testing.T, cfg *envconf.Config) context.Context {
absPath := "test/e2e/kwokctl/dryrun/testdata/" + clusterRuntime + "/export_logs.txt"
args := []string{
"--name", clusterName, "--dry-run", "export", "logs",
}
diff, err := executeCommand(args, absPath, clusterName, kwokctlPath, rootDir, updateTestdata)
if err != nil {
t.Fatal(err)
}
if diff != "" && runtime.GOOS == "linux" {
updateCmd := "go test -v ./test/e2e/kwokctl/" + clusterRuntime + " -args --update-testdata"
t.Fatalf("Expected vs got:\n%s\nExeceute this command to update the testdata manually:%s", diff, updateCmd)
}
return ctx
})
}
10 changes: 8 additions & 2 deletions test/e2e/kwokctl/binary/kubectl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ import (
"sigs.k8s.io/kwok/test/e2e"
)

func TestDryrunExportLogs(t *testing.T) {
f0 := e2e.CaseDryRunExportLogs(kwokctlPath, clusterName, runtimeEnv, rootDir, updateTestdata).
Feature()
testEnv.Test(t, f0)
}

func TestHack(t *testing.T) {
f0 := e2e.CaseHack(kwokctlPath, clusterName, envconf.RandomName("node", 16)).
Feature()
Expand Down Expand Up @@ -74,13 +80,13 @@ func TestExec(t *testing.T) {
}

func TestRestart(t *testing.T) {
f0 := e2e.CaseRestart(kwokctlPath, clusterName).
f0 := e2e.CaseRestart(kwokctlPath, clusterName, runtimeEnv, rootDir, updateTestdata).
Feature()
testEnv.Test(t, f0)
}

func TestSnapshot(t *testing.T) {
f0 := e2e.CaseSnapshot(kwokctlPath, clusterName, pwd).
f0 := e2e.CaseSnapshot(kwokctlPath, clusterName, runtimeEnv, rootDir, updateTestdata, pwd).
Feature()
testEnv.Test(t, f0)
}
Expand Down
23 changes: 13 additions & 10 deletions test/e2e/kwokctl/binary/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package binary_test

import (
"flag"
"os"
"runtime"
"testing"
Expand All @@ -32,16 +33,17 @@ import (
)

var (
runtimeEnv = consts.RuntimeTypeBinary
testEnv env.Environment
pwd = os.Getenv("PWD")
rootDir = path.Join(pwd, "../../../..")
logsDir = path.Join(rootDir, "logs")
clusterName = envconf.RandomName("kwok-e2e-binary", 16)
namespace = envconf.RandomName("ns", 16)
kwokPath = path.Join(rootDir, "bin", runtime.GOOS, runtime.GOARCH, "kwok"+helper.BinSuffix)
kwokctlPath = path.Join(rootDir, "bin", runtime.GOOS, runtime.GOARCH, "kwokctl"+helper.BinSuffix)
baseArgs = []string{
runtimeEnv = consts.RuntimeTypeBinary
testEnv env.Environment
updateTestdata = false
pwd = os.Getenv("PWD")
rootDir = path.Join(pwd, "../../../..")
logsDir = path.Join(rootDir, "logs")
clusterName = envconf.RandomName("kwok-e2e-binary", 16)
namespace = envconf.RandomName("ns", 16)
kwokPath = path.Join(rootDir, "bin", runtime.GOOS, runtime.GOARCH, "kwok"+helper.BinSuffix)
kwokctlPath = path.Join(rootDir, "bin", runtime.GOOS, runtime.GOARCH, "kwokctl"+helper.BinSuffix)
baseArgs = []string{
"--kwok-controller-binary=" + kwokPath,
"--runtime=" + runtimeEnv,
"--enable-metrics-server",
Expand All @@ -51,6 +53,7 @@ var (

func init() {
_ = os.Setenv("KWOK_WORKDIR", path.Join(rootDir, "workdir"))
flag.BoolVar(&updateTestdata, "update-testdata", false, "update all of testdata")
}

func TestMain(m *testing.M) {
Expand Down
10 changes: 8 additions & 2 deletions test/e2e/kwokctl/docker/kubectl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import (
"sigs.k8s.io/kwok/test/e2e"
)

func TestDryrunExportLogs(t *testing.T) {
f0 := e2e.CaseDryRunExportLogs(kwokctlPath, clusterName, runtimeEnv, rootDir, updateTestdata).
Feature()
testEnv.Test(t, f0)
}

func TestHack(t *testing.T) {
f0 := e2e.CaseHack(kwokctlPath, clusterName, envconf.RandomName("node", 16)).
Feature()
Expand Down Expand Up @@ -67,13 +73,13 @@ func TestExec(t *testing.T) {
}

func TestRestart(t *testing.T) {
f0 := e2e.CaseRestart(kwokctlPath, clusterName).
f0 := e2e.CaseRestart(kwokctlPath, clusterName, runtimeEnv, rootDir, updateTestdata).
Feature()
testEnv.Test(t, f0)
}

func TestSnapshot(t *testing.T) {
f0 := e2e.CaseSnapshot(kwokctlPath, clusterName, pwd).
f0 := e2e.CaseSnapshot(kwokctlPath, clusterName, runtimeEnv, rootDir, updateTestdata, pwd).
Feature()
testEnv.Test(t, f0)
}
Expand Down
23 changes: 13 additions & 10 deletions test/e2e/kwokctl/docker/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ limitations under the License.
package docker_test

import (
"flag"
"os"
"runtime"
"testing"
Expand All @@ -32,16 +33,17 @@ import (
)

var (
runtimeEnv = consts.RuntimeTypeDocker
testEnv env.Environment
pwd = os.Getenv("PWD")
rootDir = path.Join(pwd, "../../../..")
logsDir = path.Join(rootDir, "logs")
clusterName = envconf.RandomName("kwok-e2e-docker", 16)
namespace = envconf.RandomName("ns", 16)
testImage = "localhost/kwok:test"
kwokctlPath = path.Join(rootDir, "bin", runtime.GOOS, runtime.GOARCH, "kwokctl"+helper.BinSuffix)
baseArgs = []string{
runtimeEnv = consts.RuntimeTypeDocker
updateTestdata = false
testEnv env.Environment
pwd = os.Getenv("PWD")
rootDir = path.Join(pwd, "../../../..")
logsDir = path.Join(rootDir, "logs")
clusterName = envconf.RandomName("kwok-e2e-docker", 16)
namespace = envconf.RandomName("ns", 16)
testImage = "localhost/kwok:test"
kwokctlPath = path.Join(rootDir, "bin", runtime.GOOS, runtime.GOARCH, "kwokctl"+helper.BinSuffix)
baseArgs = []string{
"--kwok-controller-image=" + testImage,
"--runtime=" + runtimeEnv,
"--enable-metrics-server",
Expand All @@ -51,6 +53,7 @@ var (

func init() {
_ = os.Setenv("KWOK_WORKDIR", path.Join(rootDir, "workdir"))
flag.BoolVar(&updateTestdata, "update-testdata", false, "update all of testdata")
}

func TestMain(m *testing.M) {
Expand Down
10 changes: 10 additions & 0 deletions test/e2e/kwokctl/dryrun/testdata/binary/export_logs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mkdir -p <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs
cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kwok.yaml <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/kwok.yaml
mkdir -p <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components
echo <OS>/<ARCH> ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/binary-info.txt
cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/etcd.log <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/etcd.log
cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/kube-apiserver.log <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kube-apiserver.log
cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/kube-controller-manager.log <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kube-controller-manager.log
cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/kube-scheduler.log <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kube-scheduler.log
cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/kwok-controller.log <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kwok-controller.log
cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/metrics-server.log <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/metrics-server.log
15 changes: 15 additions & 0 deletions test/e2e/kwokctl/dryrun/testdata/binary/snapshot_restore_etcd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/etcd.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/etcd.pid
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-apiserver.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-apiserver.pid
rm -rf <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd-data
# Download https://github.com/etcd-io/etcd/releases/download/v3.5.11/etcd-v3.5.11-<OS>-<ARCH>.<TAR> and extract etcdctl to <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/bin/etcdctl
ETCDCTL_API=3 etcdctl --endpoints 127.0.0.1:32765 snapshot restore <ROOT_DIR>/test/e2e/kwokctl/binary/snapshot.db --data-dir <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd-data
rm -rf <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd
mv <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd-data <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kwok-controller.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kwok-controller.pid
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-controller-manager.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-controller-manager.pid
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-scheduler.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-scheduler.pid
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Download https://github.com/etcd-io/etcd/releases/download/v3.5.11/etcd-v3.5.11-<OS>-<ARCH>.<TAR> and extract etcdctl to <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/bin/etcdctl
ETCDCTL_API=3 etcdctl --endpoints 127.0.0.1:32765 snapshot save <ROOT_DIR>/test/e2e/kwokctl/binary/snapshot.db
12 changes: 12 additions & 0 deletions test/e2e/kwokctl/dryrun/testdata/binary/start_cluster.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
cd <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME> && etcd --name=node0 --auto-compaction-retention=1 --quota-backend-bytes=8589934592 --data-dir=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd --initial-advertise-peer-urls=http://0.0.0.0:32766 --listen-peer-urls=http://0.0.0.0:32766 --advertise-client-urls=http://0.0.0.0:32765 --listen-client-urls=http://0.0.0.0:32765 --initial-cluster=node0=http://0.0.0.0:32766 ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/etcd.log 2>&1 &
echo $! ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/etcd.pid
cd <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME> && kube-apiserver --etcd-prefix=/registry --allow-privileged=true --etcd-servers=http://127.0.0.1:32765 --authorization-mode=Node,RBAC --bind-address=0.0.0.0 --secure-port=32764 --tls-cert-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.crt --tls-private-key-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.key --client-ca-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/ca.crt --service-account-key-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.key --service-account-signing-key-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.key --service-account-issuer=https://kubernetes.default.svc.cluster.local --proxy-client-key-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.key --proxy-client-cert-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.crt ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/kube-apiserver.log 2>&1 &
echo $! ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-apiserver.pid
cd <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME> && kube-controller-manager --node-monitor-period=25s --node-monitor-grace-period=3m20s --kubeconfig=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kubeconfig.yaml --authorization-always-allow-paths=/healthz,/readyz,/livez,/metrics --bind-address=0.0.0.0 --secure-port=32763 --root-ca-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/ca.crt --service-account-private-key-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.key ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/kube-controller-manager.log 2>&1 &
echo $! ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-controller-manager.pid
cd <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME> && kube-scheduler --kubeconfig=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kubeconfig.yaml --authorization-always-allow-paths=/healthz,/readyz,/livez,/metrics --bind-address=0.0.0.0 --secure-port=32762 ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/kube-scheduler.log 2>&1 &
echo $! ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-scheduler.pid
cd <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME> && kwok-controller --manage-all-nodes=true --kubeconfig=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kubeconfig.yaml --config=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kwok.yaml --tls-cert-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.crt --tls-private-key-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.key --node-ip= --node-name=localhost --node-port=10247 --server-address=0.0.0.0:10247 --node-lease-duration-seconds=200 ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/kwok-controller.log 2>&1 &
echo $! ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kwok-controller.pid
cd <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME> && metrics-server --kubelet-preferred-address-types=InternalIP,ExternalIP,Hostname --kubelet-use-node-status-port --kubelet-insecure-tls --metric-resolution=15s --bind-address=0.0.0.0 --secure-port=32761 --kubeconfig=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kubeconfig.yaml --authentication-kubeconfig=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kubeconfig.yaml --authorization-kubeconfig=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kubeconfig.yaml --tls-cert-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.crt --tls-private-key-file=<ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pki/admin.key ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/logs/metrics-server.log 2>&1 &
echo $! ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/metrics-server.pid
12 changes: 12 additions & 0 deletions test/e2e/kwokctl/dryrun/testdata/binary/stop_cluster.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/metrics-server.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/metrics-server.pid
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-controller-manager.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-controller-manager.pid
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-scheduler.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-scheduler.pid
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kwok-controller.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kwok-controller.pid
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-apiserver.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/kube-apiserver.pid
kill $(cat <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/etcd.pid)
rm <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/pids/etcd.pid
10 changes: 10 additions & 0 deletions test/e2e/kwokctl/dryrun/testdata/docker/export_logs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mkdir -p <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs
cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kwok.yaml <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/kwok.yaml
mkdir -p <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components
docker info ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/docker-info.txt
etcd logs kwok-<CLUSTER_NAME>-etcd ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/etcd.log
kube-apiserver logs kwok-<CLUSTER_NAME>-kube-apiserver ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kube-apiserver.log
kube-controller-manager logs kwok-<CLUSTER_NAME>-kube-controller-manager ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kube-controller-manager.log
kube-scheduler logs kwok-<CLUSTER_NAME>-kube-scheduler ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kube-scheduler.log
kwok-controller logs kwok-<CLUSTER_NAME>-kwok-controller ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kwok-controller.log
metrics-server logs kwok-<CLUSTER_NAME>-metrics-server ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/metrics-server.log
14 changes: 14 additions & 0 deletions test/e2e/kwokctl/dryrun/testdata/docker/snapshot_restore_etcd.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Download https://github.com/etcd-io/etcd/releases/download/v3.5.11/etcd-v3.5.11-<OS>-<ARCH>.<TAR> and extract etcdctl to <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/bin/etcdctl
ETCDCTL_API=3 etcdctl snapshot restore <ROOT_DIR>/test/e2e/kwokctl/docker/snapshot.db --data-dir <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd-data
docker stop kwok-<CLUSTER_NAME>-etcd --time=0
docker stop kwok-<CLUSTER_NAME>-kube-apiserver --time=0
docker cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd-data kwok-<CLUSTER_NAME>-etcd:/
docker start kwok-<CLUSTER_NAME>-etcd
docker start kwok-<CLUSTER_NAME>-kube-apiserver
docker stop kwok-<CLUSTER_NAME>-kwok-controller --time=0
docker start kwok-<CLUSTER_NAME>-kwok-controller
docker stop kwok-<CLUSTER_NAME>-kube-controller-manager --time=0
docker start kwok-<CLUSTER_NAME>-kube-controller-manager
docker stop kwok-<CLUSTER_NAME>-kube-scheduler --time=0
docker start kwok-<CLUSTER_NAME>-kube-scheduler
rm -rf <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd-data
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
docker exec --env=ETCDCTL_API=3 -i kwok-<CLUSTER_NAME>-etcd etcdctl snapshot save /snapshot.db
docker cp kwok-<CLUSTER_NAME>-etcd:/snapshot.db <ROOT_DIR>/test/e2e/kwokctl/docker/snapshot.db
6 changes: 6 additions & 0 deletions test/e2e/kwokctl/dryrun/testdata/docker/start_cluster.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
docker start kwok-<CLUSTER_NAME>-etcd
docker start kwok-<CLUSTER_NAME>-kube-apiserver
docker start kwok-<CLUSTER_NAME>-kube-controller-manager
docker start kwok-<CLUSTER_NAME>-kube-scheduler
docker start kwok-<CLUSTER_NAME>-kwok-controller
docker start kwok-<CLUSTER_NAME>-metrics-server
6 changes: 6 additions & 0 deletions test/e2e/kwokctl/dryrun/testdata/docker/stop_cluster.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
docker stop kwok-<CLUSTER_NAME>-metrics-server --time=0
docker stop kwok-<CLUSTER_NAME>-kube-controller-manager --time=0
docker stop kwok-<CLUSTER_NAME>-kube-scheduler --time=0
docker stop kwok-<CLUSTER_NAME>-kwok-controller --time=0
docker stop kwok-<CLUSTER_NAME>-kube-apiserver --time=0
docker stop kwok-<CLUSTER_NAME>-etcd --time=0
10 changes: 10 additions & 0 deletions test/e2e/kwokctl/dryrun/testdata/kind-podman/export_logs.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
mkdir -p <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs
cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kwok.yaml <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/kwok.yaml
mkdir -p <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components
kind version ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/kind-podman-info.txt
etcd logs -n kube-system etcd-kwok-<CLUSTER_NAME>-control-plane ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/etcd.log
kube-apiserver logs -n kube-system kube-apiserver-kwok-<CLUSTER_NAME>-control-plane ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kube-apiserver.log
kube-controller-manager logs -n kube-system kube-controller-manager-kwok-<CLUSTER_NAME>-control-plane ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kube-controller-manager.log
kube-scheduler logs -n kube-system kube-scheduler-kwok-<CLUSTER_NAME>-control-plane ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kube-scheduler.log
kwok-controller logs -n kube-system kwok-controller-kwok-<CLUSTER_NAME>-control-plane ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/kwok-controller.log
metrics-server logs -n kube-system metrics-server-kwok-<CLUSTER_NAME>-control-plane ><ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/export/logs/components/metrics-server.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
podman exec kwok-<CLUSTER_NAME>-control-plane mv /etc/kubernetes/manifests/etcd.yaml /etc/kubernetes/etcd.yaml.bak
# Download https://github.com/etcd-io/etcd/releases/download/v3.5.11/etcd-v3.5.11-<OS>-<ARCH>.<TAR> and extract etcdctl to <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/bin/etcdctl
ETCDCTL_API=3 etcdctl snapshot restore <ROOT_DIR>/test/e2e/kwokctl/kind-podman/snapshot.db --data-dir <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd
podman cp <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd kwok-<CLUSTER_NAME>-control-plane:/var/lib/
rm -rf <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/etcd
podman exec kwok-<CLUSTER_NAME>-control-plane mv /etc/kubernetes/etcd.yaml.bak /etc/kubernetes/manifests/etcd.yaml
podman stop kwok-<CLUSTER_NAME>-control-plane
podman start kwok-<CLUSTER_NAME>-control-plane
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
kubectl --kubeconfig <ROOT_DIR>/workdir/clusters/<CLUSTER_NAME>/kubeconfig.yaml exec -i -n kube-system etcd-kwok-<CLUSTER_NAME>-control-plane -- etcdctl --endpoints=127.0.0.1:2379 --cert=/etc/kubernetes/pki/etcd/server.crt --key=/etc/kubernetes/pki/etcd/server.key --cacert=/etc/kubernetes/pki/etcd/ca.crt snapshot save /var/lib/etcd/snapshot.db
podman cp kwok-<CLUSTER_NAME>-control-plane:/var/lib/etcd/snapshot.db <ROOT_DIR>/test/e2e/kwokctl/kind-podman/snapshot.db
podman exec -i kwok-<CLUSTER_NAME>-control-plane rm -f /var/lib/etcd/snapshot.db
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
podman start kwok-<CLUSTER_NAME>-control-plane
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
podman stop kwok-<CLUSTER_NAME>-control-plane
Loading

0 comments on commit 368079d

Please sign in to comment.