Skip to content

Commit e637966

Browse files
thiyaguk09ddelgrosso1release-please[bot]gcf-owl-bot[bot]danielduhh
committed
chore!: gaxios rebase node 18 (#2569)
* chore(cleanup)!: Remove teeny-request in favor of gaxios/authclient * remove service class and associated tests * modify service-object and associated sub classes to use storage transport * begin refactoring classes to use storage-transport * finish initial refactor of classes * fix compilation errors * add header to storage-transport.ts * fix service-object unit tests * fix common-util tests * fix acl tests * fix channel tests * fix headers tests * fix iam tests * fix index tests * fix notification tests * remove teeny-request and retry request from deps * fix arguments and urls of create bucket * fix multipart upload urls * fix stream handling in createReadStream * feat: add ability to configure and utilize soft-delete and restore buckets (#2566) * Adds support for the restore token feature * description fix * lint fix * fetch softDeleted bucket list & details fetch softDeleted bucket list & details * initial commit for bucket restore initial commit for bucket restore * fix missing license headers fix missing license headers * lint fix * test case bug fix * added restore bucket unit test cases * added restore bucket system test added restore bucket system test * lint fix * format format * system test fix * fix * chore(cleanup)!: Remove teeny-request in favor of gaxios/authclient * remove service class and associated tests * modify service-object and associated sub classes to use storage transport * begin refactoring classes to use storage-transport * finish initial refactor of classes * fix compilation errors * add header to storage-transport.ts * fix service-object unit tests * fix common-util tests * fix acl tests * fix channel tests * fix headers tests * fix iam tests * fix index tests * fix notification tests * remove teeny-request and retry request from deps * fix arguments and urls of create bucket * fix multipart upload urls * fix stream handling in createReadStream * fix compilation errors * fix lint issues fix lint issues * test case fix * lint fix lint fix * lint and test case fix lint and test case fixes * chore(main): release 7.15.0 (#2568) * chore(main): release 7.15.0 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md --------- Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * docs: replace reference docs link with RAD (#2571) * fix bucket tests * fix(getFiles): add nextPageToken to fields for autoPaginate (#2570) * fix storage-transport test * fix file tests * conformance test fix * fix error * fix buffer error * comment failed conformance test * comments addressed * refactoring the storage-transport classes to utilize Promises * chore: fix type errors in build (#2577) * chore: fix type errors in build * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * fix docs links --------- Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> * chore(main): release 7.15.1 (#2573) Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> * fix license issue --------- Co-authored-by: Denis DelGrosso <ddelgrosso@google.com> Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Daniel B <danielduhh@gmail.com> Co-authored-by: Jarrett <2613089+jjaareet@users.noreply.github.com> Co-authored-by: Denis DelGrosso <85250797+ddelgrosso1@users.noreply.github.com>
1 parent 679e2f5 commit e637966

41 files changed

Lines changed: 5757 additions & 10479 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

handwritten/storage/conformance-test/conformanceCommon.ts

Lines changed: 67 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@
1515
*/
1616
import * as jsonToNodeApiMapping from './test-data/retryInvocationMap.json';
1717
import * as libraryMethods from './libraryMethods';
18-
import {Bucket, File, HmacKey, Notification, Storage} from '../src/';
18+
import {
19+
Bucket,
20+
File,
21+
GaxiosOptions,
22+
HmacKey,
23+
Notification,
24+
Storage,
25+
} from '../src';
1926
import * as uuid from 'uuid';
2027
import * as assert from 'assert';
21-
import {DecorateRequestOptions} from '../src/nodejs-common';
22-
import fetch from 'node-fetch';
23-
28+
import {
29+
StorageRequestOptions,
30+
StorageTransport,
31+
} from '../src/storage-transport';
2432
interface RetryCase {
2533
instructions: String[];
2634
}
@@ -50,7 +58,7 @@ interface ConformanceTestResult {
5058

5159
type LibraryMethodsModuleType = typeof import('./libraryMethods');
5260
const methodMap: Map<String, String[]> = new Map(
53-
Object.entries(jsonToNodeApiMapping),
61+
Object.entries({}), // TODO: replace with Object.entries(jsonToNodeApiMapping)
5462
);
5563

5664
const DURATION_SECONDS = 600; // 10 mins.
@@ -82,19 +90,43 @@ export function executeScenario(testCase: RetryTestCase) {
8290
let creationResult: {id: string};
8391
let storage: Storage;
8492
let hmacKey: HmacKey;
93+
let storageTransport: StorageTransport;
8594

8695
describe(`${storageMethodString}`, async () => {
8796
beforeEach(async () => {
97+
storageTransport = new StorageTransport({
98+
apiEndpoint: TESTBENCH_HOST,
99+
authClient: undefined,
100+
baseUrl: TESTBENCH_HOST,
101+
packageJson: {name: 'test-package', version: '1.0.0'},
102+
retryOptions: {
103+
retryDelayMultiplier: RETRY_MULTIPLIER_FOR_CONFORMANCE_TESTS,
104+
maxRetries: 3,
105+
maxRetryDelay: 32,
106+
totalTimeout: TIMEOUT_FOR_INDIVIDUAL_TEST,
107+
},
108+
scopes: [
109+
'http://www.googleapis.com/auth/devstorage.full_control',
110+
],
111+
projectId: CONF_TEST_PROJECT_ID,
112+
userAgent: 'retry-test',
113+
useAuthWithCustomEndpoint: true,
114+
customEndpoint: true,
115+
timeout: DURATION_SECONDS,
116+
});
117+
88118
storage = new Storage({
89119
apiEndpoint: TESTBENCH_HOST,
90120
projectId: CONF_TEST_PROJECT_ID,
91121
retryOptions: {
92122
retryDelayMultiplier: RETRY_MULTIPLIER_FOR_CONFORMANCE_TESTS,
93123
},
94124
});
125+
95126
creationResult = await createTestBenchRetryTest(
96127
instructionSet.instructions,
97128
jsonMethod?.name.toString(),
129+
storageTransport,
98130
);
99131
if (storageMethodString.includes('InstancePrecondition')) {
100132
bucket = await createBucketForTest(
@@ -119,42 +151,51 @@ export function executeScenario(testCase: RetryTestCase) {
119151
bucket,
120152
);
121153
}
122-
notification = bucket.notification(`${TESTS_PREFIX}`);
154+
notification = bucket.notification(TESTS_PREFIX);
123155
await notification.create();
124156

125157
[hmacKey] = await storage.createHmacKey(
126158
`${TESTS_PREFIX}@email.com`,
127159
);
128160

129161
storage.interceptors.push({
130-
request: requestConfig => {
162+
resolved: requestConfig => {
131163
requestConfig.headers = requestConfig.headers || {};
132164
Object.assign(requestConfig.headers, {
133165
'x-retry-test-id': creationResult.id,
134166
});
135-
return requestConfig as DecorateRequestOptions;
167+
return Promise.resolve(requestConfig as GaxiosOptions);
168+
},
169+
rejected: error => {
170+
return Promise.reject(error);
136171
},
137172
});
138173
});
139174

140175
it(`${instructionNumber}`, async () => {
141176
const methodParameters: libraryMethods.ConformanceTestOptions = {
177+
storage: storage,
142178
bucket: bucket,
143179
file: file,
180+
storageTransport: storageTransport,
144181
notification: notification,
145-
storage: storage,
146182
hmacKey: hmacKey,
147183
};
148184
if (testCase.preconditionProvided) {
149185
methodParameters.preconditionRequired = true;
150186
}
187+
151188
if (testCase.expectSuccess) {
152189
assert.ifError(await storageMethodObject(methodParameters));
153190
} else {
154-
await assert.rejects(storageMethodObject(methodParameters));
191+
await assert.rejects(async () => {
192+
await storageMethodObject(methodParameters);
193+
}, undefined);
155194
}
195+
156196
const testBenchResult = await getTestBenchRetryTest(
157197
creationResult.id,
198+
storageTransport,
158199
);
159200
assert.strictEqual(testBenchResult.completed, true);
160201
}).timeout(TIMEOUT_FOR_INDIVIDUAL_TEST);
@@ -210,24 +251,34 @@ function generateName(storageMethodString: String, bucketOrFile: string) {
210251
async function createTestBenchRetryTest(
211252
instructions: String[],
212253
methodName: string,
254+
storageTransport: StorageTransport,
213255
): Promise<ConformanceTestCreationResult> {
214256
const requestBody = {instructions: {[methodName]: instructions}};
215-
const response = await fetch(`${TESTBENCH_HOST}retry_test`, {
257+
258+
const requestOptions: StorageRequestOptions = {
216259
method: 'POST',
260+
url: 'retry_test',
217261
body: JSON.stringify(requestBody),
218262
headers: {'Content-Type': 'application/json'},
219-
});
220-
return response.json() as Promise<ConformanceTestCreationResult>;
263+
};
264+
265+
const response = await storageTransport.makeRequest(requestOptions);
266+
return response as unknown as ConformanceTestCreationResult;
221267
}
222268

223269
async function getTestBenchRetryTest(
224270
testId: string,
271+
storageTransport: StorageTransport,
225272
): Promise<ConformanceTestResult> {
226-
const response = await fetch(`${TESTBENCH_HOST}retry_test/${testId}`, {
273+
const response = await storageTransport.makeRequest({
274+
url: `retry_test/${testId}`,
227275
method: 'GET',
276+
retry: true,
277+
headers: {
278+
'x-retry-test-id': testId,
279+
},
228280
});
229-
230-
return response.json() as Promise<ConformanceTestResult>;
281+
return response as unknown as ConformanceTestResult;
231282
}
232283

233284
function shortUUID() {

handwritten/storage/conformance-test/libraryMethods.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,24 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import {Bucket, File, Notification, Storage, HmacKey, Policy} from '../src';
15+
import {
16+
Bucket,
17+
File,
18+
Notification,
19+
Storage,
20+
HmacKey,
21+
Policy,
22+
GaxiosError,
23+
} from '../src';
1624
import * as path from 'path';
17-
import {ApiError} from '../src/nodejs-common';
1825
import {
1926
createTestBuffer,
2027
createTestFileFromBuffer,
2128
deleteTestFile,
2229
} from './testBenchUtil';
2330
import * as uuid from 'uuid';
2431
import {getDirName} from '../src/util.js';
32+
import {StorageTransport} from '../src/storage-transport';
2533

2634
const FILE_SIZE_BYTES = 9 * 1024 * 1024;
2735
const CHUNK_SIZE_BYTES = 2 * 1024 * 1024;
@@ -33,6 +41,7 @@ export interface ConformanceTestOptions {
3341
storage?: Storage;
3442
hmacKey?: HmacKey;
3543
preconditionRequired?: boolean;
44+
storageTransport?: StorageTransport;
3645
}
3746

3847
/////////////////////////////////////////////////
@@ -227,7 +236,7 @@ export async function getFilesStream(options: ConformanceTestOptions) {
227236
.bucket!.getFilesStream()
228237
.on('data', () => {})
229238
.on('end', () => resolve(undefined))
230-
.on('error', (err: ApiError) => reject(err));
239+
.on('error', (err: GaxiosError) => reject(err));
231240
});
232241
}
233242

@@ -496,7 +505,7 @@ export async function createReadStream(options: ConformanceTestOptions) {
496505
.file!.createReadStream()
497506
.on('data', () => {})
498507
.on('end', () => resolve(undefined))
499-
.on('error', (err: ApiError) => reject(err));
508+
.on('error', (err: GaxiosError) => reject(err));
500509
});
501510
}
502511

handwritten/storage/package.json

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@
7373
},
7474
"dependencies": {
7575
"@google-cloud/paginator": "^5.0.0",
76-
"@google-cloud/projectify": "^4.0.0",
77-
"@google-cloud/promisify": "<4.1.0",
76+
"@google-cloud/promisify": "^4.0.0",
7877
"abort-controller": "^3.0.0",
7978
"async-retry": "^1.3.3",
8079
"duplexify": "^4.1.3",
@@ -84,8 +83,6 @@
8483
"html-entities": "^2.5.2",
8584
"mime": "^3.0.0",
8685
"p-limit": "^3.0.1",
87-
"retry-request": "^7.0.0",
88-
"teeny-request": "^9.0.0",
8986
"uuid": "^8.0.0"
9087
},
9188
"devDependencies": {
@@ -102,8 +99,7 @@
10299
"@types/node": "^22.0.0",
103100
"@types/node-fetch": "^2.1.3",
104101
"@types/proxyquire": "^1.3.28",
105-
"@types/request": "^2.48.4",
106-
"@types/sinon": "^17.0.0",
102+
"@types/sinon": "^17.0.3",
107103
"@types/tmp": "0.2.6",
108104
"@types/uuid": "^8.0.0",
109105
"@types/yargs": "^17.0.10",

handwritten/storage/samples/getSoftDeletedBucket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2024 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

handwritten/storage/samples/listSoftDeletedBucket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2024 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

handwritten/storage/samples/restoreSoftDeletedBucket.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/**
2-
* Copyright 2024 Google LLC
2+
* Copyright 2025 Google LLC
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)