Skip to content

Commit ae73969

Browse files
committed
Setup fixed credentials for dryrun mode
1 parent ab76ddb commit ae73969

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

plugins/node/opentelemetry-instrumentation-aws-sdk/test/bedrock-runtime.test.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
* otherwise a real request is made and the response is recorded.
2424
* To re-record all responses, set the NOCK_BACK_MODE environment variable
2525
* to 'update' - when recording responses, valid AWS credentials for
26-
* accessing bedrock are also required.
26+
* accessing bedrock are also required. To record for new tests while
27+
* keeping existing recordings, set NOCK_BACK_MODE to 'record'.
2728
*/
2829

2930
import {
@@ -39,6 +40,7 @@ import {
3940
ConversationRole,
4041
InvokeModelCommand,
4142
} from '@aws-sdk/client-bedrock-runtime';
43+
import { AwsCredentialIdentity } from '@aws-sdk/types';
4244
import * as path from 'path';
4345
import { Definition, back as nockBack } from 'nock';
4446

@@ -77,13 +79,17 @@ const sanitizeRecordings = (scopes: Definition[]) => {
7779
};
7880

7981
describe('Bedrock', () => {
80-
const client = new BedrockRuntimeClient({ region });
81-
8282
nockBack.fixtures = path.join(__dirname, 'mock-responses');
83-
if (!process.env.NOCK_BACK_MODE) {
84-
nockBack.setMode('record');
83+
let credentials: AwsCredentialIdentity | undefined;
84+
if (nockBack.currentMode === 'dryrun') {
85+
credentials = {
86+
accessKeyId: 'testing',
87+
secretAccessKey: 'testing',
88+
};
8589
}
8690

91+
const client = new BedrockRuntimeClient({ region, credentials });
92+
8793
let nockDone: () => void;
8894
beforeEach(async function () {
8995
const filename = `${this.currentTest

0 commit comments

Comments
 (0)