Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
b2e12e7
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
7760a7d
fix(storage): resolve system test failures after Gaxios & Node 18 mig…
thiyaguk09 May 7, 2026
d07f358
fix(storage): resolve Gaxios transport issues in conformance tests
thiyaguk09 May 12, 2026
edd2687
chore: remove system test
thiyaguk09 May 12, 2026
65f9f33
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
1ae557f
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
faf7509
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 May 14, 2026
bd33380
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
cc411a0
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
c5643d0
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 May 14, 2026
128bf0a
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
9010041
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
f1bceb6
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 May 15, 2026
7b6d68b
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
0e8f067
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
1c9ca6c
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 May 18, 2026
a2cd00b
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
72c17d7
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
c4b1b66
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 May 19, 2026
8eb2d72
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
eacb087
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
865e21c
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 May 21, 2026
683b3f4
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
0c58a9a
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
32bcc64
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 May 25, 2026
5f55b76
fix(storage): update storage conformance tests to correctly access re…
thiyaguk09 May 26, 2026
b5c81a1
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
fe44861
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
a461869
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 May 26, 2026
7c3ee50
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
0a4f5ac
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
04cc041
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 May 27, 2026
ef7c4d4
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
e3288e3
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
4f2c0a4
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 1, 2026
eb547c4
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
1fba172
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
5949286
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 2, 2026
fafab27
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
d4b912f
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
27d472d
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 3, 2026
c5be999
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
c0a6220
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
5f7973c
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 4, 2026
4865c5d
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
747d276
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
0f2652b
test: add bytes method to mock Gaxios response in acl and headers tests
thiyaguk09 Jun 5, 2026
697426d
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 5, 2026
a82723e
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
e366cc2
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
ffd2057
test: add bytes method to mock Gaxios response in acl and headers tests
thiyaguk09 Jun 5, 2026
6afa84a
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 12, 2026
8a0e737
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
4f69ca3
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
2d55123
test: add bytes method to mock Gaxios response in acl and headers tests
thiyaguk09 Jun 5, 2026
f99ed4f
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 15, 2026
17ffbe5
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
3b19434
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
7d5c5ac
test: add bytes method to mock Gaxios response in acl and headers tests
thiyaguk09 Jun 5, 2026
6418ed2
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 17, 2026
9379a79
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
2c0e9c8
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
e4c95b8
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 18, 2026
fb221c3
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
696a337
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
db015d3
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 19, 2026
efaaf4b
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
fe055f7
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
113e1b4
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 22, 2026
e03e122
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
7218474
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
d4ee55c
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
9271939
lint fix
thiyaguk09 Jun 23, 2026
6d9bbae
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 23, 2026
2af8521
chore: upgrade storage testbench image tag to v0.63.0
thiyaguk09 Jun 23, 2026
de6b408
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
20fcb11
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
9519ae8
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
1819fe4
lint fix
thiyaguk09 Jun 23, 2026
f0b6196
Merge remote-tracking branch 'upstream/storage-node-18' into node18/c…
thiyaguk09 Jun 23, 2026
85c50e2
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
0979efb
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
ba27a8f
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
948d035
lint fix
thiyaguk09 Jun 23, 2026
232b2b5
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jun 24, 2026
fc44591
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
a81e28d
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
018f71e
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
43fc1e8
lint fix
thiyaguk09 Jun 23, 2026
ebf0ff1
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jun 25, 2026
1946ca8
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
bae6491
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
aeb3a02
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
3217d07
lint fix
thiyaguk09 Jun 23, 2026
e1acda6
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jun 26, 2026
6723f3e
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
43fc14b
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
3f1dcdf
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
0d373cf
lint fix
thiyaguk09 Jun 23, 2026
11433a8
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jun 29, 2026
0a993d6
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
4f16b2e
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
dae5c48
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
b1a54b0
lint fix
thiyaguk09 Jun 23, 2026
60ae0aa
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 1, 2026
de16592
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
82a2239
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
74e6d6b
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
f41a664
lint fix
thiyaguk09 Jun 23, 2026
8ad8d15
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 3, 2026
111aa89
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
eaf8c63
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
a5aac31
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
b4ac2f3
lint fix
thiyaguk09 Jun 23, 2026
f45f9c1
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 7, 2026
20e15b0
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
c9e4407
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
01223bc
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
72b5e10
lint fix
thiyaguk09 Jun 23, 2026
e274f9a
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 8, 2026
b0498ea
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
40f27b2
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
4b31465
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
191e96c
lint fix
thiyaguk09 Jun 23, 2026
68ad817
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 9, 2026
38849e1
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
2e8a5c9
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
929c38d
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
560a61b
lint fix
thiyaguk09 Jun 23, 2026
f3b4035
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 21, 2026
2161bde
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
b52e1f7
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
58ec490
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
99d0a21
lint fix
thiyaguk09 Jun 23, 2026
6098b8b
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 22, 2026
487c6e3
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
7920b7e
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
a31e5be
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
d8af687
lint fix
thiyaguk09 Jun 23, 2026
ce05106
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 23, 2026
e8fd1e0
refactor: replace retry proxy with gaxios interceptors in conformance…
thiyaguk09 Jul 23, 2026
dbd46bc
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
7e8f9ec
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
ad50970
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
ae0485b
lint fix
thiyaguk09 Jun 23, 2026
221d513
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 24, 2026
6ea2aee
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
321d91d
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
48db3ca
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
2686699
lint fix
thiyaguk09 Jun 23, 2026
de253fe
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 27, 2026
106c994
fix(storage): Invocation ID is not retained on multipart upload retri…
thiyaguk09 Jul 28, 2026
bebe7f1
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
8975172
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
b984e82
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
58ef9bf
lint fix
thiyaguk09 Jun 23, 2026
b16d16a
fix(storage): Invocation ID is not retained on multipart upload retri…
thiyaguk09 Jul 28, 2026
8e7342d
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 28, 2026
9aaaed0
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 28, 2026
678f64c
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
676e767
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
fd0a8fc
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
c6cbede
lint fix
thiyaguk09 Jun 23, 2026
374f80d
fix(storage): Invocation ID is not retained on multipart upload retri…
thiyaguk09 Jul 28, 2026
2e627f9
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 28, 2026
4937d6c
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
6ba890f
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
2ad86cc
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
4f26b73
lint fix
thiyaguk09 Jun 23, 2026
7b78138
fix(storage): Invocation ID is not retained on multipart upload retri…
thiyaguk09 Jul 28, 2026
f271b7b
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 29, 2026
9875e06
fix(storage): standardize URL formatting and enhance transport retry
thiyaguk09 May 7, 2026
7ec256e
refactor(storage): remove Service.ts and migrate logic to StorageTran…
thiyaguk09 May 14, 2026
690b5a1
fix(storage): resolve transport and retry issues (#8235)
thiyaguk09 Jun 23, 2026
4e72213
lint fix
thiyaguk09 Jun 23, 2026
81b96dc
fix(storage): Invocation ID is not retained on multipart upload retri…
thiyaguk09 Jul 28, 2026
2147897
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 30, 2026
9ad4b8a
Merge branch 'storage-node-18' into node18/conformance-test
thiyaguk09 Jul 31, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
272 changes: 155 additions & 117 deletions handwritten/storage/conformance-test/conformanceCommon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,19 @@
*/
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import * as jsonToNodeApiMapping from './test-data/retryInvocationMap.json';
import * as libraryMethods from './libraryMethods';
import {
Bucket,
File,
GaxiosOptions,
GaxiosOptionsPrepared,
HmacKey,
Notification,
Storage,
} from '../src';
import * as libraryMethods from './libraryMethods.js';
import {Bucket, File, Gaxios, HmacKey, Notification, Storage} from '../src';
import * as gaxios from 'gaxios';
import * as crypto from 'crypto';
import * as assert from 'assert';
import {
StorageRequestOptions,
StorageTransport,
} from '../src/storage-transport';
StorageTransportCallback,
} from '../src/storage-transport.js';
import {getDirName} from '../src/util.js';
import path from 'path';
import {GoogleAuth} from 'google-auth-library';
interface RetryCase {
instructions: String[];
}
Expand Down Expand Up @@ -60,7 +57,7 @@ interface ConformanceTestResult {

type LibraryMethodsModuleType = typeof import('./libraryMethods');
const methodMap: Map<String, String[]> = new Map(
Object.entries({}), // TODO: replace with Object.entries(jsonToNodeApiMapping)
Object.entries(jsonToNodeApiMapping),
);

const DURATION_SECONDS = 600; // 10 mins.
Expand All @@ -70,6 +67,23 @@ const TESTBENCH_HOST =
const CONF_TEST_PROJECT_ID = 'my-project-id';
const TIMEOUT_FOR_INDIVIDUAL_TEST = 20000;
const RETRY_MULTIPLIER_FOR_CONFORMANCE_TESTS = 0.01;
const SERVICE_ACCOUNT = path.join(
getDirName(),
'../../../conformance-test/fixtures/signing-service-account.json',
);

const authClient = new GoogleAuth({
keyFilename: SERVICE_ACCOUNT,
scopes: ['https://www.googleapis.com/auth/devstorage.full_control'],
}).fromJSON(require(SERVICE_ACCOUNT));

authClient.getAccessToken = async () => ({token: 'unauthenticated-test-token'});
authClient.request = async opts => {
if (typeof (opts as any).adapter === 'function') {
return (opts as any).adapter(opts);
}
return (gaxios as any).instance.request(opts);
};

export function executeScenario(testCase: RetryTestCase) {
for (
Expand All @@ -89,16 +103,20 @@ export function executeScenario(testCase: RetryTestCase) {
let bucket: Bucket;
let file: File;
let notification: Notification;
let creationResult: {id: string};
let creationResult: ConformanceTestCreationResult;
let storage: Storage;
let hmacKey: HmacKey;
let storageTransport: StorageTransport;

describe(`${storageMethodString}`, async () => {
beforeEach(async () => {
storageTransport = new StorageTransport({
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(gaxios as any)?.instance?.interceptors?.request?.clear();

const rawTransport = new StorageTransport({
apiEndpoint: TESTBENCH_HOST,
authClient: undefined,
authClient: authClient,
keyFilename: SERVICE_ACCOUNT,
baseUrl: TESTBENCH_HOST,
packageJson: {name: 'test-package', version: '1.0.0'},
retryOptions: {
Expand All @@ -117,173 +135,193 @@ export function executeScenario(testCase: RetryTestCase) {
timeout: DURATION_SECONDS,
});

creationResult = await createTestBenchRetryTest(
instructionSet.instructions,
jsonMethod?.name.toString(),
rawTransport,
);

storage = new Storage({
apiEndpoint: TESTBENCH_HOST,
projectId: CONF_TEST_PROJECT_ID,
keyFilename: SERVICE_ACCOUNT,
authClient: authClient,
retryOptions: {
retryDelayMultiplier: RETRY_MULTIPLIER_FOR_CONFORMANCE_TESTS,
},
});

creationResult = await createTestBenchRetryTest(
instructionSet.instructions,
jsonMethod?.name.toString(),
storageTransport,
bucket = await createBucketForTest(
storage,
testCase.preconditionProvided &&
!storageMethodString.includes('combine'),
storageMethodString,
);
if (storageMethodString.includes('InstancePrecondition')) {
bucket = await createBucketForTest(
storage,
testCase.preconditionProvided,
storageMethodString,
);
file = await createFileForTest(
testCase.preconditionProvided,
storageMethodString,
bucket,
);
} else {
bucket = await createBucketForTest(
storage,
false,
storageMethodString,
);
file = await createFileForTest(
false,
storageMethodString,
bucket,
);
file = await createFileForTest(
testCase.preconditionProvided,
storageMethodString,
bucket,
);
if (
storageMethodString !== 'createNotification' &&
storageMethodString !== 'notificationCreate'
) {
notification = bucket.notification(TESTS_PREFIX);
await notification.create();
}
notification = bucket.notification(TESTS_PREFIX);
await notification.create();

[hmacKey] = await storage.createHmacKey(
`${TESTS_PREFIX}@email.com`,
);
if (
storageMethodString === 'deleteHMAC' ||
storageMethodString === 'getHMAC' ||
storageMethodString === 'getMetadataHMAC' ||
storageMethodString === 'setMetadataHMAC'
) {
[hmacKey] = await storage.createHmacKey(
`${TESTS_PREFIX}@email.com`,
);
}

storage.interceptors.push({
resolved: (
requestConfig: GaxiosOptionsPrepared,
): Promise<GaxiosOptionsPrepared> => {
const config = requestConfig as GaxiosOptions;
config.headers = config.headers || {};
Object.assign(config.headers, {
'x-retry-test-id': creationResult.id,
});
return Promise.resolve(config as GaxiosOptionsPrepared);
},
rejected: error => {
return Promise.reject(error);
},
});
storageTransport = storage.storageTransport;
});

it(`${instructionNumber}`, async () => {
const methodParameters: libraryMethods.ConformanceTestOptions = {
storage: storage,
bucket: bucket,
file: file,
storageTransport: storageTransport,
notification: notification,
hmacKey: hmacKey,
storage,
bucket,
file,
storageTransport,
notification,
hmacKey,
projectId: CONF_TEST_PROJECT_ID,
preconditionRequired: testCase.preconditionProvided,
};

const injectHeader = (reqOpts: any) => {
const url = reqOpts.url?.toString() || '';
if (url.includes('retry_test') || !creationResult?.id) {
return reqOpts;
}
reqOpts.headers = reqOpts.headers || {};
if (typeof reqOpts.headers.set === 'function') {
reqOpts.headers.set('x-retry-test-id', creationResult.id);
}
try {
reqOpts.headers['x-retry-test-id'] = creationResult.id;
} catch (e) {}
return reqOpts;
};
if (testCase.preconditionProvided) {
methodParameters.preconditionRequired = true;
}

if (testCase.expectSuccess) {
assert.ifError(await storageMethodObject(methodParameters));
} else {
await assert.rejects(async () => {
const interceptor = {
resolved: injectHeader,
request: injectHeader,
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(storage.storageTransport as any)?.gaxiosInstance?.interceptors?.request?.clear();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(gaxios as any)?.instance?.interceptors?.request?.clear();

// eslint-disable-next-line @typescript-eslint/no-explicit-any
(storage.storageTransport as any).gaxiosInstance.interceptors.request.add(interceptor);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(gaxios as any).instance.interceptors.request.add(interceptor);

try {
if (testCase.expectSuccess) {
await storageMethodObject(methodParameters);
}, undefined);
const testBenchResult = await getTestBenchRetryTest(
creationResult.id,
storageTransport,
);
assert.strictEqual(testBenchResult.completed, true);
} else {
await assert.rejects(async () => {
await storageMethodObject(methodParameters);
}, undefined);
}
} finally {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(storage.storageTransport as any)?.gaxiosInstance?.interceptors?.request?.clear();
// eslint-disable-next-line @typescript-eslint/no-explicit-any
(gaxios as any)?.instance?.interceptors?.request?.clear();
}

const testBenchResult = await getTestBenchRetryTest(
creationResult.id,
storageTransport,
);
assert.strictEqual(testBenchResult.completed, true);
}).timeout(TIMEOUT_FOR_INDIVIDUAL_TEST);
});
});
});
}
}



async function createBucketForTest(
storage: Storage,
preconditionShouldBeOnInstance: boolean,
storageMethodString: String,
withPrecondition: boolean,
method: String,
) {
const name = generateName(storageMethodString, 'bucket');
const bucket = storage.bucket(name);
await bucket.create();
const bucket = storage.bucket(generateName(method, 'bucket'));
const [metadata] = await bucket.create();
await bucket.setRetentionPeriod(DURATION_SECONDS);

if (preconditionShouldBeOnInstance) {
if (withPrecondition) {
return new Bucket(storage, bucket.name, {
preconditionOpts: {
ifMetagenerationMatch: 2,
ifMetagenerationMatch: metadata.metageneration,
},
});
}
return bucket;
}

async function createFileForTest(
preconditionShouldBeOnInstance: boolean,
storageMethodString: String,
withPrecondition: boolean,
method: String,
bucket: Bucket,
) {
const name = generateName(storageMethodString, 'file');
const file = bucket.file(name);
await file.save(name);
if (preconditionShouldBeOnInstance) {
const file = bucket.file(generateName(method, 'file'));
if (method === 'deleteBucket') {
return file;
}
await file.save('test-content');
if (withPrecondition) {
const [metadata] = await file.getMetadata();
return new File(bucket, file.name, {
preconditionOpts: {
ifMetagenerationMatch: file.metadata.metageneration,
ifGenerationMatch: file.metadata.generation,
ifMetagenerationMatch: metadata.metageneration,
ifGenerationMatch: metadata.generation,
},
});
}
return file;
}

function generateName(storageMethodString: String, bucketOrFile: string) {
return `${TESTS_PREFIX}${storageMethodString.toLowerCase()}${bucketOrFile}.${shortUUID()}`;
}

async function createTestBenchRetryTest(
instructions: String[],
methodName: string,
storageTransport: StorageTransport,
transport: StorageTransport,
): Promise<ConformanceTestCreationResult> {
const requestBody = {instructions: {[methodName]: instructions}};

const requestOptions: StorageRequestOptions = {
const response = await transport.makeRequest({
method: 'POST',
url: 'retry_test',
body: JSON.stringify(requestBody),
body: JSON.stringify({instructions: {[methodName]: instructions}}),
headers: {'Content-Type': 'application/json'},
};

const response = await storageTransport.makeRequest(requestOptions);
return response as unknown as ConformanceTestCreationResult;
});
return response.data as ConformanceTestCreationResult;
}

async function getTestBenchRetryTest(
testId: string,
storageTransport: StorageTransport,
transport: StorageTransport,
): Promise<ConformanceTestResult> {
const response = await storageTransport.makeRequest({
const response = await transport.makeRequest({
url: `retry_test/${testId}`,
method: 'GET',
retry: true,
headers: {
'x-retry-test-id': testId,
},
headers: {'x-retry-test-id': testId},
});
return response as unknown as ConformanceTestResult;
return response.data as ConformanceTestResult;
}

function generateName(method: String, type: string) {
return `${TESTS_PREFIX}${method.toLowerCase()}${type}.${shortUUID()}`;
}

function shortUUID() {
Expand Down
Loading
Loading