-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(integration): integration test dsl with test servers (#4)
- Loading branch information
1 parent
f00c073
commit 6b4b7f7
Showing
18 changed files
with
7,019 additions
and
5,746 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
...tchers/service/to-recieve-http-request.ts → ...tchers/service/to-receive-http-request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 8 additions & 5 deletions
13
packages/expect-opentelemetry/src/matchers/service/to-send-http-request.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
packages/expect-opentelemetry/src/options.js → packages/expect-opentelemetry/src/options.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
let defaultOptionsValue = { timeout: 500 }; | ||
|
||
export const setDefaultOptions = (options) => { | ||
export const setDefaultOptions = (options: any) => { | ||
defaultOptionsValue = options; | ||
}; | ||
|
||
export const getDefaultOptions = () => { | ||
return defaultOptionsValue; | ||
}; | ||
|
||
export const defaultOptions = (options) => ({ | ||
export const defaultOptions = (options: any) => ({ | ||
...getDefaultOptions(), | ||
...options, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { opentelemetry } from '../../../../proto'; | ||
|
||
export class Service { | ||
constructor( | ||
public readonly name: string, | ||
public readonly spans: opentelemetry.proto.trace.v1.ISpan[], | ||
) {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import axios from 'axios'; | ||
import { trace } from './trace'; | ||
import { traces } from './trace'; | ||
|
||
jest.setTimeout(30000); | ||
|
||
describe('trace', () => { | ||
it('should see orders-service calling emails-service', async () => { | ||
const sequence = await trace(async () => | ||
axios.post('http://localhost:3000/orders/create'), | ||
); | ||
expect(1).toBe(1); | ||
// expect(sequence.service('orders-service')) | ||
// .toCall('emails-service') | ||
// .withHttpBody({}); | ||
const sequence = await traces(async () => { | ||
await axios.post('http://localhost:3000/orders/create'); | ||
}); | ||
|
||
expect(sequence.service('orders-service')).toSendHttpRequest(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,36 @@ | ||
import axios from 'axios'; | ||
import { setTimeout } from 'timers/promises'; | ||
import { Service } from './resources/service'; | ||
import { opentelemetry } from '../../../proto'; | ||
|
||
export async function trace(fn: () => Promise<void>) { | ||
export async function traces(fn: () => Promise<void>) { | ||
await setTimeout(5000); | ||
await fn(); | ||
await setTimeout(20000); | ||
const t = new Trace(); | ||
await t.getTraces(); | ||
await t.init(); | ||
return t; | ||
} | ||
|
||
export class Trace { | ||
async getTraces() { | ||
await setTimeout(2000); | ||
return axios.get('http://localhost:4123/v1/traces'); | ||
private tracesData: opentelemetry.proto.trace.v1.ITracesData | undefined; | ||
|
||
async init() { | ||
const response = (await axios.get('http://localhost:4123/v1/traces')).data; | ||
|
||
this.tracesData = opentelemetry.proto.trace.v1.TracesData.decode(response); | ||
} | ||
|
||
service(name: string): Service { | ||
const serviceResourceSpans = this.tracesData?.resourceSpans?.find((rs) => | ||
rs.resource?.attributes?.find( | ||
(a) => a.key === 'service.name' && a.value?.stringValue === name, | ||
), | ||
); | ||
|
||
const serviceSpans = | ||
serviceResourceSpans?.scopeSpans?.flatMap((ss) => ss.spans || []) || []; | ||
|
||
return new Service(name, serviceSpans); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.