Skip to content

Commit 4fd5585

Browse files
committed
test kubernetes worker with k3d
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 3609204 commit 4fd5585

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

tests/helpers/k3d.go

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,26 @@ func NewK3dServer(cfg *integration.BackendConfig) (kubeConfig string, cl func()
2828
}
2929
}()
3030

31-
clusterName := "buildkit-" + identity.NewID()
31+
clusterName := "bk-" + identity.NewID()
3232

33-
stop, err := integration.StartCmd(exec.Command(k3dBin, "cluster", "create", clusterName,
33+
cmd := exec.Command(k3dBin, "cluster", "create", clusterName,
3434
"--wait",
35-
), cfg.Logs)
35+
)
36+
out, err := cmd.CombinedOutput()
3637
if err != nil {
37-
return "", nil, err
38+
return "", nil, errors.Wrapf(err, "failed to create k3d cluster %s: %s", clusterName, string(out))
3839
}
39-
deferF.Append(stop)
40+
deferF.Append(func() error {
41+
cmd := exec.Command(k3dBin, "cluster", "delete", clusterName)
42+
out, err := cmd.CombinedOutput()
43+
if err != nil {
44+
return errors.Wrapf(err, "failed to delete k3d cluster %s: %s", clusterName, string(out))
45+
}
46+
return nil
47+
})
4048

41-
cmd := exec.Command(k3dBin, "kubeconfig", "write", clusterName)
42-
out, err := cmd.CombinedOutput()
49+
cmd = exec.Command(k3dBin, "kubeconfig", "write", clusterName)
50+
out, err = cmd.CombinedOutput()
4351
if err != nil {
4452
return "", nil, errors.Wrapf(err, "failed to write kubeconfig for cluster %s: %s", clusterName, string(out))
4553
}

0 commit comments

Comments
 (0)