Skip to content

Commit ce2bdfe

Browse files
committed
chore: [AB#17441] remove automated health checks against endpoints for cigarette license
1 parent 9e50617 commit ce2bdfe

File tree

3 files changed

+3
-60
lines changed

3 files changed

+3
-60
lines changed

api/src/functions/express/app.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -540,9 +540,8 @@ app.use(
540540
["webservice/formation", formationHealthCheckClient],
541541
["tax-clearance", taxClearanceHealthCheckClient],
542542
["xray-registration", xrayRegistrationHealthCheckClient],
543-
// TODO: The following need CloudWatch metrics
544-
["cigarette-license", cigaretteLicenseHealthCheckClient],
545-
["cigarette-email-client", cigaretteLicenseEmailClient.health],
543+
["cigarette-license", cigaretteLicenseHealthCheckClient], // This endpoint is not being hit by the HealthCheck Lambda
544+
["cigarette-email-client", cigaretteLicenseEmailClient.health], // This endpoint is not being hit by the HealthCheck Lambda
546545
["messaging-service", messagingServiceClient.health],
547546
["tax-filing-client", taxFilingClient.health],
548547
]),

api/src/libs/healthCheck.test.ts

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { runHealthChecks } from "@libs/healthCheck";
22
import { DummyLogWriter } from "@libs/logWriter";
3-
import { CONFIG_VARS, getConfigValue } from "@libs/ssmUtils";
43
import axios from "axios";
54

65
jest.mock("axios");
@@ -10,18 +9,9 @@ jest.mock("@libs/ssmUtils", () => ({
109
getConfigValue: jest.fn(),
1110
}));
1211

13-
const mockGetConfigValue = getConfigValue as jest.MockedFunction<typeof getConfigValue>;
14-
1512
describe("healthCheck", () => {
1613
const logger = DummyLogWriter;
1714

18-
beforeEach(() => {
19-
mockGetConfigValue.mockImplementation(async (paramName: CONFIG_VARS) => {
20-
if (paramName === "FEATURE_CIGARETTE_LICENSE") return "true";
21-
return "false";
22-
});
23-
});
24-
2515
it("returns an object with pass statuses if success is true", async () => {
2616
mockAxios.get.mockResolvedValue({ data: { success: true } });
2717
expect(await runHealthChecks(logger)).toStrictEqual({
@@ -34,8 +24,6 @@ describe("healthCheck", () => {
3424
webserviceFormation: "PASS",
3525
taxClearance: "PASS",
3626
xrayRegistration: "PASS",
37-
cigaretteLicense: "PASS",
38-
cigaretteEmailClient: "PASS",
3927
taxFilingClient: "PASS",
4028
});
4129
});
@@ -52,8 +40,6 @@ describe("healthCheck", () => {
5240
webserviceFormation: "FAIL",
5341
taxClearance: "FAIL",
5442
xrayRegistration: "FAIL",
55-
cigaretteLicense: "FAIL",
56-
cigaretteEmailClient: "FAIL",
5743
taxFilingClient: "FAIL",
5844
});
5945
});
@@ -70,27 +56,7 @@ describe("healthCheck", () => {
7056
webserviceFormation: "ERROR",
7157
taxClearance: "ERROR",
7258
xrayRegistration: "ERROR",
73-
cigaretteLicense: "ERROR",
74-
cigaretteEmailClient: "ERROR",
7559
taxFilingClient: "ERROR",
7660
});
7761
});
78-
79-
describe("flagged health checks", () => {
80-
it("includes cigarette health checks when feature flag is on", async () => {
81-
const result = await runHealthChecks(logger);
82-
expect(Object.keys(result)).toContain("cigaretteLicense");
83-
expect(Object.keys(result)).toContain("cigaretteEmailClient");
84-
});
85-
86-
it("excludes cigarette health checks when feature flag is off", async () => {
87-
mockGetConfigValue.mockImplementation(async () => {
88-
return "false";
89-
});
90-
91-
const result = await runHealthChecks(logger);
92-
expect(Object.keys(result)).not.toContain("cigaretteLicense");
93-
expect(Object.keys(result)).not.toContain("cigaretteEmailClient");
94-
});
95-
});
9662
});

api/src/libs/healthCheck.ts

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { CloudWatchClient, PutMetricDataCommand } from "@aws-sdk/client-cloudwatch";
22
import { LogWriterType } from "@libs/logWriter";
3-
import { getConfigValue } from "@libs/ssmUtils";
43
import axios, { AxiosError, AxiosResponse } from "axios";
54

65
type Status = "PASS" | "FAIL" | "ERROR";
@@ -21,20 +20,6 @@ const healthCheckEndPoints: Record<string, string> = {
2120
taxFilingClient: "tax-filing-client",
2221
};
2322

24-
const addFlaggedHealthChecks = (
25-
endpoints: Record<string, string>,
26-
flagValues: { cigarette: boolean },
27-
): Record<string, string> => {
28-
if (flagValues.cigarette) {
29-
return {
30-
...endpoints,
31-
cigaretteEmailClient: "cigarette-email-client",
32-
cigaretteLicense: "cigarette-license",
33-
};
34-
}
35-
return endpoints;
36-
};
37-
3823
const healthCheck = async (type: string, url: string, logger: LogWriterType): Promise<Status> => {
3924
const fullUrl = `${url}/health/${type}`;
4025

@@ -95,14 +80,7 @@ export const runHealthChecks = async (logger: LogWriterType): Promise<StatusResu
9580
throw new Error("API URL is undefined");
9681
}
9782

98-
const isCigaretteLicenseEnabled =
99-
(await getConfigValue("FEATURE_CIGARETTE_LICENSE", logger)) === "true";
100-
101-
const endpoints = addFlaggedHealthChecks(healthCheckEndPoints, {
102-
cigarette: isCigaretteLicenseEnabled,
103-
});
104-
105-
const entries = Object.entries(endpoints).map(([type, endpoint]) =>
83+
const entries = Object.entries(healthCheckEndPoints).map(([type, endpoint]) =>
10684
healthCheck(endpoint ?? "", url, logger).then((result) => [type, result] as const),
10785
);
10886

0 commit comments

Comments
 (0)