Skip to content

Commit fe8e691

Browse files
committed
test: restore warmup image in k8s serial tests
1 parent 58201a9 commit fe8e691

11 files changed

Lines changed: 41 additions & 21 deletions

Sources/ContainerK8s/Commands/K8sCreate.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,10 @@ import Foundation
2525
import Logging
2626
import TerminalProgress
2727

28-
struct K8sCreate: AsyncParsableCommand {
29-
static let configuration = CommandConfiguration(
28+
public struct K8sCreate: AsyncParsableCommand {
29+
public init() {}
30+
31+
public static let configuration = CommandConfiguration(
3032
commandName: "create",
3133
abstract: "Create and start a local Kubernetes cluster"
3234
)
@@ -49,7 +51,7 @@ struct K8sCreate: AsyncParsableCommand {
4951
@Option(help: "Node image reference (default: \(K8sHelper.nodeImage))")
5052
var nodeImage: String = K8sHelper.nodeImage
5153

52-
func run() async throws {
54+
public func run() async throws {
5355
LoggingSystem.bootstrap { _ in StderrLogHandler() }
5456
let log = Logger(label: K8sHelper.pluginName)
5557

Sources/ContainerK8s/Commands/K8sDelete.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import ContainerResource
2121
import ContainerizationError
2222
import Logging
2323

24-
struct K8sDelete: AsyncParsableCommand {
25-
static let configuration = CommandConfiguration(
24+
public struct K8sDelete: AsyncParsableCommand {
25+
public init() {}
26+
27+
public static let configuration = CommandConfiguration(
2628
commandName: "delete",
2729
abstract: "Delete a Kubernetes cluster",
2830
aliases: ["rm"]
@@ -31,7 +33,7 @@ struct K8sDelete: AsyncParsableCommand {
3133
@Option(name: .long, help: "Cluster name (default: \(K8sHelper.defaultName))")
3234
var name: String = K8sHelper.defaultName
3335

34-
func run() async throws {
36+
public func run() async throws {
3537
LoggingSystem.bootstrap { _ in StderrLogHandler() }
3638
let log = Logger(label: K8sHelper.pluginName)
3739

Sources/ContainerK8s/Commands/K8sList.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,16 @@ import ContainerLog
2020
import ContainerResource
2121
import Logging
2222

23-
struct K8sList: AsyncParsableCommand {
24-
static let configuration = CommandConfiguration(
23+
public struct K8sList: AsyncParsableCommand {
24+
public init() {}
25+
26+
public static let configuration = CommandConfiguration(
2527
commandName: "list",
2628
abstract: "List clusters and their nodes",
2729
aliases: ["ls"]
2830
)
2931

30-
func run() async throws {
32+
public func run() async throws {
3133
LoggingSystem.bootstrap { _ in StderrLogHandler() }
3234

3335
let snapshots = try await ContainerClient().list(

Sources/ContainerK8s/Commands/K8sLoadImage.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@ import Foundation
2525
import Logging
2626
import SystemPackage
2727

28-
struct K8sLoadImage: AsyncParsableCommand {
28+
public struct K8sLoadImage: AsyncParsableCommand {
29+
public init() {}
30+
2931
private static let ctrPath = "/usr/local/bin/ctr"
3032

31-
static let configuration = CommandConfiguration(
33+
public static let configuration = CommandConfiguration(
3234
commandName: "load-image",
3335
abstract: "Load a container image into a cluster's containerd"
3436
)
@@ -44,7 +46,7 @@ struct K8sLoadImage: AsyncParsableCommand {
4446
)
4547
var platform: String?
4648

47-
func run() async throws {
49+
public func run() async throws {
4850
LoggingSystem.bootstrap { _ in StderrLogHandler() }
4951
let log = Logger(label: K8sHelper.pluginName)
5052

Sources/ContainerK8s/Commands/K8sStart.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,18 @@ import ContainerizationError
2222
import Foundation
2323
import Logging
2424

25-
struct K8sStart: AsyncParsableCommand {
26-
static let configuration = CommandConfiguration(
25+
public struct K8sStart: AsyncParsableCommand {
26+
public init() {}
27+
28+
public static let configuration = CommandConfiguration(
2729
commandName: "start",
2830
abstract: "Start a stopped Kubernetes cluster"
2931
)
3032

3133
@Option(name: .long, help: "Cluster name (default: \(K8sHelper.defaultName))")
3234
var name: String = K8sHelper.defaultName
3335

34-
func run() async throws {
36+
public func run() async throws {
3537
LoggingSystem.bootstrap { _ in StderrLogHandler() }
3638
let log = Logger(label: K8sHelper.pluginName)
3739

Sources/ContainerK8s/Commands/K8sWriteConfig.swift

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import Foundation
2121
import Logging
2222
import SystemPackage
2323

24-
struct K8sWriteConfig: AsyncParsableCommand {
25-
static let configuration = CommandConfiguration(
24+
public struct K8sWriteConfig: AsyncParsableCommand {
25+
public init() {}
26+
27+
public static let configuration = CommandConfiguration(
2628
commandName: "write-config",
2729
abstract: "Write the cluster context to a Kubernetes configuration file"
2830
)
@@ -33,7 +35,7 @@ struct K8sWriteConfig: AsyncParsableCommand {
3335
@Option(name: .long, help: "Path to the kubeconfig file to write or append to (default: ~/.kube/config)")
3436
var kubeconfig: String?
3537

36-
func run() async throws {
38+
public func run() async throws {
3739
LoggingSystem.bootstrap { _ in StderrLogHandler() }
3840
let log = Logger(label: K8sHelper.pluginName)
3941

File renamed without changes.

Tests/IntegrationTests/K8s/TestK8sLoadImageSerial.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ struct TestK8sLoadImageSerial {
7474
let name = "k8s-\(f.testID)"
7575
f.addCleanup { _ = try? f.run(["k8s", "delete", "--name", name]) }
7676

77+
try f.restoreWarmupImage(.kindestNodeV1_35_5)
7778
print("[k8s-load] k8s create --name \(name)")
7879
let result = try f.run(["k8s", "create", "--name", name])
7980
print("[k8s-load] k8s create exit=\(result.status)")
@@ -85,7 +86,7 @@ struct TestK8sLoadImageSerial {
8586
try result.check()
8687

8788
print("[k8s-load] pulling \(Self.testImage)")
88-
try f.doPull(Self.testImage)
89+
try f.restoreWarmupImage(.alpine320)
8990

9091
print("[k8s-load] k8s load-image --name \(name) \(Self.testImage)")
9192
let loadResult = try f.run(["k8s", "load-image", "--name", name, Self.testImage])

Tests/IntegrationTests/K8s/TestK8sNetworkingSerial.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ struct TestK8sNetworkingSerial {
9595
let name = "k8s-\(f.testID)"
9696
f.addCleanup { _ = try? f.run(["k8s", "delete", "--name", name]) }
9797

98+
try f.restoreWarmupImage(.kindestNodeV1_35_5)
9899
print("[k8s-net] k8s create --name \(name)")
99100
let result = try f.run(["k8s", "create", "--name", name])
100101
print("[k8s-net] k8s create exit=\(result.status)")
@@ -106,7 +107,7 @@ struct TestK8sNetworkingSerial {
106107
try result.check()
107108

108109
print("[k8s-net] pulling \(Self.testImage)")
109-
try f.doPull(Self.testImage)
110+
try f.restoreWarmupImage(.alpine320)
110111

111112
print("[k8s-net] k8s load-image --name \(name) \(Self.testImage)")
112113
let loadResult = try f.run(["k8s", "load-image", "--name", name, Self.testImage])
@@ -143,6 +144,7 @@ struct TestK8sNetworkingSerial {
143144
let name = "k8s-\(f.testID)"
144145
f.addCleanup { _ = try? f.run(["k8s", "delete", "--name", name]) }
145146

147+
try f.restoreWarmupImage(.kindestNodeV1_35_5)
146148
print("[k8s-net] k8s create --name \(name)")
147149
let result = try f.run(["k8s", "create", "--name", name])
148150
print("[k8s-net] k8s create exit=\(result.status)")
@@ -153,7 +155,7 @@ struct TestK8sNetworkingSerial {
153155
try result.check()
154156

155157
print("[k8s-net] pulling \(Self.testImage)")
156-
try f.doPull(Self.testImage)
158+
try f.restoreWarmupImage(.alpine320)
157159

158160
print("[k8s-net] k8s load-image --name \(name) \(Self.testImage)")
159161
let loadResult = try f.run(["k8s", "load-image", "--name", name, Self.testImage])

Tests/IntegrationTests/K8s/TestK8sRunSerial.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ struct TestK8sRunSerial {
6060
let name = "k8s-\(f.testID)"
6161
f.addCleanup { _ = try? f.run(["k8s", "delete", "--name", name]) }
6262

63+
try f.restoreWarmupImage(.kindestNodeV1_35_5)
6364
print("[k8s-run] k8s create --name \(name)")
6465
let result = try f.run(["k8s", "create", "--name", name])
6566
print("[k8s-run] k8s create exit=\(result.status)")
@@ -94,6 +95,7 @@ struct TestK8sRunSerial {
9495
f.addCleanup { _ = try? f.run(["k8s", "delete", "--name", name1]) }
9596
f.addCleanup { _ = try? f.run(["k8s", "delete", "--name", name2]) }
9697

98+
try f.restoreWarmupImage(.kindestNodeV1_35_5)
9799
print("[k8s-run] k8s create --name \(name1)")
98100
let result1 = try f.run(["k8s", "create", "--name", name1])
99101
print("[k8s-run] k8s create exit=\(result1.status)")

0 commit comments

Comments
 (0)