Skip to content

Commit

Permalink
test: add timeout e2e
Browse files Browse the repository at this point in the history
  • Loading branch information
bzp2010 committed Oct 17, 2024
1 parent f754b74 commit 1cca8f6
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions libs/backend-api7/e2e/resources/route.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
import * as ADCSDK from '@api7/adc-sdk';

import { BackendAPI7 } from '../../src';
import {
createEvent,
deleteEvent,
dumpConfiguration,
syncEvents,
} from '../support/utils';

describe('Route E2E', () => {
let backend: BackendAPI7;

beforeAll(() => {
backend = new BackendAPI7({
server: process.env.SERVER,
token: process.env.TOKEN,
tlsSkipVerify: true,
gatewayGroup: 'default',
});
});

describe('Timeout', () => {
const serviceName = 'test';
const service = {
name: serviceName,
upstream: {
scheme: 'https',
nodes: [
{
host: 'httpbin.org',
port: 443,
weight: 100,
},
],
},
path_prefix: '/test',
strip_path_prefix: true,
} as ADCSDK.Service;
const route1Name = 'route1';
const route1 = {
name: route1Name,
uris: ['/route1'],
timeout: {
connect: 111,
send: 222,
read: 333,
},
} as ADCSDK.Route;

it('Create resources', async () =>
syncEvents(backend, [
createEvent(ADCSDK.ResourceType.SERVICE, serviceName, service),
createEvent(ADCSDK.ResourceType.ROUTE, route1Name, route1, serviceName),
]));

it('Dump', async () => {
const result = (await dumpConfiguration(backend)) as ADCSDK.Configuration;
expect(result.services).toHaveLength(1);
expect(result.services[0]).toMatchObject(service);
expect(result.services[0].routes).toHaveLength(1);
expect(result.services[0].routes[0]).toMatchObject(route1);
});

it('Delete', async () =>
syncEvents(backend, [
deleteEvent(ADCSDK.ResourceType.SERVICE, serviceName),
]));

it('Dump again (service should not exist)', async () => {
const result = (await dumpConfiguration(backend)) as ADCSDK.Configuration;
expect(result.services).toHaveLength(0);
});
});
});

0 comments on commit 1cca8f6

Please sign in to comment.