Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ describe("health check utils", () => {
expect(hasHealthCheckConfig(inspectResult)).toBe(true);
});

it("should detect Podman image health check config from HealthCheck field", () => {
const inspectResult = {
HealthCheck: {
Test: ["CMD-SHELL", "test -f /tmp/ready"],
},
} as unknown as ImageInspectInfo;

expect(hasHealthCheckConfig(inspectResult)).toBe(true);
});

it("should ignore disabled health check config", () => {
const inspectResult = {
Config: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@ type HealthCheckInspectInfo = ContainerInspectInfo | ImageInspectInfo;
type InspectWithHealthCheckConfig = {
Config?: {
Healthcheck?: HealthConfig;
HealthCheck?: HealthConfig;
};
ContainerConfig?: {
Healthcheck?: HealthConfig;
HealthCheck?: HealthConfig;
};
Healthcheck?: HealthConfig;
HealthCheck?: HealthConfig;
};
type InspectWithHealthCheckState = {
State: ContainerInspectInfo["State"] & {
Expand Down Expand Up @@ -64,8 +67,11 @@ export const getHealthCheckConfig = (inspectResult: HealthCheckInspectInfo): Hea

return (
inspectWithHealthCheckConfig.Config?.Healthcheck ??
inspectWithHealthCheckConfig.Config?.HealthCheck ??
inspectWithHealthCheckConfig.ContainerConfig?.Healthcheck ??
inspectWithHealthCheckConfig.Healthcheck
inspectWithHealthCheckConfig.ContainerConfig?.HealthCheck ??
inspectWithHealthCheckConfig.Healthcheck ??
inspectWithHealthCheckConfig.HealthCheck
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,13 @@ const imageInspectResultWithHealthCheck = (): ImageInspectInfo =>
},
}) as unknown as ImageInspectInfo;

const imageInspectResultWithPodmanHealthCheck = (): ImageInspectInfo =>
({
HealthCheck: {
Test: ["CMD-SHELL", "test -f /tmp/ready"],
},
}) as unknown as ImageInspectInfo;

const client = (imageInspectResult: ImageInspectInfo): ContainerRuntimeClient =>
({
image: {
Expand Down Expand Up @@ -146,6 +153,16 @@ describe("wait strategy selector", () => {
).resolves.toBeInstanceOf(HealthCheckWaitStrategy);
});

it("should select Podman image healthcheck when container inspect omits healthcheck config", async () => {
await expect(
selectWaitStrategy({
client: client(imageInspectResultWithPodmanHealthCheck()),
inspectResult: containerInspectResult(),
imageNames: ["image:latest"],
})
).resolves.toBeInstanceOf(HealthCheckWaitStrategy);
});

it("should select listening ports when image inspect fails", async () => {
await expect(
selectWaitStrategy({
Expand Down
Loading