Skip to content

Commit d33b388

Browse files
committed
fix
1 parent 3e5025b commit d33b388

2 files changed

Lines changed: 8 additions & 25 deletions

File tree

libs/backend-apisix-standalone/e2e/cache.e2e-spec.ts

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
import { DifferV3 } from '@api7/adc-differ';
22
import * as ADCSDK from '@api7/adc-sdk';
33
import axios from 'axios';
4-
import { lastValueFrom } from 'rxjs';
54

65
import { BackendAPISIXStandalone } from '../src';
76
import {
87
config as configCache,
98
rawConfig as rawConfigCache,
109
} from '../src/cache';
1110
import { server, token } from './support/constants';
12-
import {
13-
createEvent,
14-
deleteEvent,
15-
dumpConfiguration,
16-
refreshDumpCache,
17-
restartAPISIX,
18-
syncEvents,
19-
updateEvent,
20-
} from './support/utils';
11+
import { dumpConfiguration, restartAPISIX, syncEvents } from './support/utils';
2112

2213
describe('Cache - Single APISIX', () => {
2314
let backend: BackendAPISIXStandalone;
@@ -43,7 +34,7 @@ describe('Cache - Single APISIX', () => {
4334
expect(rawConfigCache).toBeDefined();
4435
expect(rawConfigCache.size).toEqual(0);
4536

46-
await expect(lastValueFrom(backend.dump())).resolves.not.toThrow();
37+
await expect(dumpConfiguration(backend)).resolves.not.toThrow();
4738

4839
expect(configCache.size).toEqual(1);
4940
expect(rawConfigCache.size).toEqual(1);
@@ -59,7 +50,7 @@ describe('Cache - Single APISIX', () => {
5950
let apiCall = 0;
6051
const sub = backend.on('AXIOS_DEBUG', () => apiCall++);
6152

62-
await expect(lastValueFrom(backend.dump())).resolves.not.toThrow();
53+
await expect(dumpConfiguration(backend)).resolves.not.toThrow();
6354
expect(apiCall).toEqual(0);
6455

6556
sub.unsubscribe();
@@ -85,7 +76,7 @@ describe('Cache - Single APISIX', () => {
8576
} as ADCSDK.Configuration;
8677
const now = new Date();
8778
it('update config', async () => {
88-
const oldConfig = await lastValueFrom(backend.dump());
79+
const oldConfig = await dumpConfiguration(backend);
8980
const events = DifferV3.diff(config, oldConfig);
9081
expect(events).toHaveLength(1 + 1 + 2); // service * 1 + route * 1 + consumer * 2
9182
expect(

libs/backend-apisix-standalone/e2e/support/utils.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -95,18 +95,10 @@ export const overrideEventResourceId = (
9595
return event;
9696
};
9797

98-
// This backend needs to use the data from the dump to assist in generating new data for the sync,
99-
// the cache is in the backend, so just wait for the dump to complete.
100-
export const refreshDumpCache = (backend: BackendAPISIX) =>
101-
lastValueFrom(
102-
backend.dump().pipe(
103-
toArray(),
104-
//tap(() => console.log(backend.__TEST_ONLY.GET_LAST_DUMP())),
105-
),
106-
);
107-
108-
export const sortResult = <T>(result: Array<T>, field: string) =>
109-
structuredClone(result).sort((a, b) => a[field].localeCompare(b[field]));
98+
export const sortResult = <T extends Record<string, string>>(
99+
result: Array<T>,
100+
field: string,
101+
) => structuredClone(result).sort((a, b) => a[field].localeCompare(b[field]));
110102

111103
export const wait = (ms: number) =>
112104
new Promise((resolve) => setTimeout(resolve, ms));

0 commit comments

Comments
 (0)