feat(infra): add external redis (#3639)
This commit is contained in:
@@ -1,9 +1,10 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
|
||||
import { createHomarrContainer } from "./shared/create-homarr-container";
|
||||
import { createRedisContainer } from "./shared/redis-container";
|
||||
|
||||
describe("Health checks", () => {
|
||||
test("ready and live should return 200 OK", async () => {
|
||||
test("ready and live should return 200 OK with normal image and no extra configuration", async () => {
|
||||
// Arrange
|
||||
const homarrContainer = await createHomarrContainer().start();
|
||||
|
||||
@@ -15,4 +16,31 @@ describe("Health checks", () => {
|
||||
expect(readyResponse.status).toBe(200);
|
||||
expect(liveResponse.status).toBe(200);
|
||||
}, 20_000);
|
||||
|
||||
test("ready and live should return 200 OK with external redis", async () => {
|
||||
// Arrange
|
||||
const redisContainer = await createRedisContainer().start();
|
||||
const homarrContainer = await createHomarrContainer({
|
||||
environment: {
|
||||
REDIS_IS_EXTERNAL: "true",
|
||||
REDIS_HOST: "host.docker.internal",
|
||||
REDIS_PORT: redisContainer.getMappedPort(6379).toString(),
|
||||
REDIS_PASSWORD: redisContainer.getPassword(),
|
||||
},
|
||||
}).start();
|
||||
|
||||
// Act
|
||||
const readyResponse = await fetch(`http://localhost:${homarrContainer.getMappedPort(7575)}/api/health/ready`);
|
||||
const liveResponse = await fetch(`http://localhost:${homarrContainer.getMappedPort(7575)}/api/health/live`);
|
||||
|
||||
// Assert
|
||||
expect(
|
||||
readyResponse.status,
|
||||
`Expected ready to return OK statusCode=${readyResponse.status} content=${await readyResponse.text()}`,
|
||||
).toBe(200);
|
||||
expect(
|
||||
liveResponse.status,
|
||||
`Expected live to return OK statusCode=${liveResponse.status} content=${await liveResponse.text()}`,
|
||||
).toBe(200);
|
||||
}, 20_000);
|
||||
});
|
||||
|
||||
5
e2e/shared/redis-container.ts
Normal file
5
e2e/shared/redis-container.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import { RedisContainer } from "@testcontainers/redis";
|
||||
|
||||
export const createRedisContainer = () => {
|
||||
return new RedisContainer("redis:latest").withPassword("homarr");
|
||||
};
|
||||
Reference in New Issue
Block a user