Skip to content

Commit cb2ba4f

Browse files
cleanup tests
ISSUE: CLDSRVCLT-2
1 parent 5be9d7b commit cb2ba4f

File tree

8 files changed

+51
-58
lines changed

8 files changed

+51
-58
lines changed

tests/testApis.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ describe('CloudServer API Tests', () => {
5050
});
5151

5252
it('should test GetSingleObject', async () => {
53-
// S3VAULT=mem S3METADATA=scality S3DATA=mem
5453
const getInput: GetObjectInput = {
5554
Bucket: testConfig.bucketName,
5655
Key: testConfig.objectKey,
@@ -76,7 +75,6 @@ describe('CloudServer API Tests', () => {
7675
});
7776

7877
it('should test BatchDelete', async () => {
79-
// S3VAULT=mem S3METADATA=scality S3DATA=mem
8078
const locations: BatchDeleteLocation[] = [
8179
{
8280
dataStoreName: "mem",

tests/testErrorHandling.test.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ describe('CloudServer test error handling', () => {
1616
});
1717

1818
it('should test xml parsing', async () => {
19-
// Run CloudServer with : S3VAULT=mem S3METADATA=mem S3DATA=mem REMOTE_MANAGEMENT_DISABLE=true yarn start
20-
// Needs to tamper with Cloudserver response manually to return an html error..
2119
try {
2220
const getInput: GetObjectInput = {
2321
Bucket: testConfig.bucketName,
@@ -35,6 +33,7 @@ describe('CloudServer test error handling', () => {
3533

3634
it.skip('should test html parsing', async () => {
3735
// Run CloudServer with : S3VAULT=mem S3METADATA=mem S3DATA=mem REMOTE_MANAGEMENT_DISABLE=true yarn start
36+
// Needs to tamper with Cloudserver response manually to return an html error
3837
try {
3938
const deleteInput: MultipleBackendDeleteObjectInput = {
4039
Bucket: 'testConfig.bucketName',

tests/testIndexesApis.test.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ describe('CloudServer Indexes API Tests', () => {
1818
});
1919

2020
it('should test PutBucketIndexes', async () => {
21-
// S3VAULT=mem S3METADATA=mongodb S3DATA=mem
2221
const indexData = JSON.stringify([
2322
{
2423
name: "testIndex1",
@@ -38,7 +37,6 @@ describe('CloudServer Indexes API Tests', () => {
3837
});
3938

4039
it('should test GetBucketIndexes', async () => {
41-
// S3VAULT=mem S3METADATA=mongodb S3DATA=mem
4240
const getBucketIndexesInput: GetBucketIndexesInput = {
4341
Bucket: testConfig.bucketName,
4442
};

tests/testLifecycleApis.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ describe('CloudServer Lifecycle API Tests', () => {
2020
});
2121

2222
it('should test ListLifecycleCurrents', async () => {
23-
// Run Cloudserver with : S3VAULT=mem S3METADATA=mongodb S3DATA=mem REMOTE_MANAGEMENT_DISABLE=true yarn start
2423
const listInput: ListLifecycleCurrentsInput = {
2524
Bucket: testConfig.bucketName,
2625
MaxKeys: 1,

tests/testMetadataApis.test.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ describe('CloudServer Metadata API Tests', () => {
1818
});
1919

2020
it('should test GetMetadata API', async () => {
21-
// Run Cloudserver with : S3VAULT=mem S3METADATA=mongodb S3DATA=mem REMOTE_MANAGEMENT_DISABLE=true yarn start
2221
const getMetadataInput: GetMetadataInput = {
2322
Bucket: testConfig.bucketName,
2423
Key: testConfig.objectKey,
@@ -29,14 +28,14 @@ describe('CloudServer Metadata API Tests', () => {
2928
});
3029

3130
it('should test PutMetadata API', async () => {
32-
// S3VAULT=mem S3METADATA=scality S3DATA=mem
3331
const metadataObj = {
3432
"content-length": 1000,
3533
"content-type": "text/plain",
3634
"x-amz-meta-custom": "test-valuee",
3735
"last-modified": new Date().toISOString(),
3836
"etag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
39-
"x-amz-version-id": "null"
37+
"x-amz-version-id": "null",
38+
"replicationInfo": {}
4039
};
4140

4241
const metadataString = JSON.stringify(metadataObj);
@@ -55,7 +54,6 @@ describe('CloudServer Metadata API Tests', () => {
5554

5655

5756
it('should test GetBucketMetadata API', async () => {
58-
// S3VAULT=mem S3METADATA=scality S3DATA=mem
5957
const getBucketMetadataInput: GetBucketMetadataInput = {
6058
Bucket: testConfig.bucketName,
6159
};

tests/testMultipleBackendApis.test.ts

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -136,55 +136,55 @@ describe('CloudServer Multiple Backend API Tests', () => {
136136
assert.strictEqual(headResult.$metadata.httpStatusCode, 200);
137137
});
138138

139-
it('should test MultipleBackendPutTaggingObject API', async () => {
140-
try {
141-
const tagData = new TextEncoder().encode(JSON.stringify({
142-
TagSet: [
143-
{ Key: 'Environment', Value: 'Test' },
144-
{ Key: 'Project', Value: 'Cloudserver' }
145-
]
146-
}));
147-
const putTaggingInput: MultipleBackendPutObjectTaggingInput = {
148-
Bucket: testConfig.bucketName,
149-
Key: testConfig.objectKey,
150-
StorageClass: 'us-east-1',
151-
StorageType: 'file',
152-
Tags: JSON.stringify({
153-
'Environment': 'Test',
154-
'Project': 'Cloudserver'
155-
}),
156-
Body: tagData,
157-
DataStoreVersionId: 'v1',
158-
SourceBucket: "aBucket",
159-
ReplicationEndpointSite: "aVal"
160-
};
161-
const putTaggingCommand = new MultipleBackendPutObjectTaggingCommand(putTaggingInput);
162-
const putTaggingResult = await client.send(putTaggingCommand);
163-
console.log('MultipleBackendPutObjectTagging succeeded!', putTaggingResult);
164-
} catch (err: any) {
165-
console.log('MultipleBackendPutObjectTagging failed:', err);
166-
}
139+
it.skip('should test MultipleBackendPutTaggingObject API', async () => {
140+
// Skipped : it's not straightforward to make this test work,
141+
// cloudserver crashes on requests (dataClient.objectTagging is not a function)
142+
// probably missing some extra setup
143+
const tagData = new TextEncoder().encode(JSON.stringify({
144+
TagSet: [
145+
{ Key: 'Environment', Value: 'Test' },
146+
{ Key: 'Project', Value: 'Cloudserver' }
147+
]
148+
}));
149+
const putTaggingInput: MultipleBackendPutObjectTaggingInput = {
150+
Bucket: testConfig.bucketName,
151+
Key: testConfig.objectKey,
152+
StorageClass: 'us-east-1',
153+
StorageType: 'file',
154+
Tags: JSON.stringify({
155+
'Environment': 'Test',
156+
'Project': 'Cloudserver'
157+
}),
158+
Body: tagData,
159+
DataStoreVersionId: 'v1',
160+
SourceBucket: "aBucket",
161+
ReplicationEndpointSite: "aVal"
162+
};
163+
const putTaggingCommand = new MultipleBackendPutObjectTaggingCommand(putTaggingInput);
164+
const putTaggingResult = await client.send(putTaggingCommand);
165+
assert.strictEqual(putTaggingResult.$metadata.httpStatusCode, 200);
167166
});
168167

169-
it('should test MultipleBackendDeleteObjectTagging API', async () => {
170-
try {
171-
const deleteTaggingInput: MultipleBackendDeleteObjectTaggingInput = {
172-
Bucket: testConfig.bucketName,
173-
Key: testConfig.objectKey,
174-
StorageClass: 'us-east-1',
175-
StorageType: 'file',
176-
// Body: new Uint8Array(0)
177-
};
178-
179-
const deleteTaggingCommand = new MultipleBackendDeleteObjectTaggingCommand(deleteTaggingInput);
180-
const deleteTaggingResult = await client.send(deleteTaggingCommand);
181-
console.log('MultipleBackendDeleteObjectTagging succeeded!', deleteTaggingResult);
182-
} catch (err: any) {
183-
console.log('MultipleBackendDeleteObjectTagging failed:', err);
184-
}
168+
it.skip('should test MultipleBackendDeleteObjectTagging API', async () => {
169+
// Skipped : it's not straightforward to make this test work,
170+
// cloudserver crashes on requests (dataClient.objectTagging is not a function)
171+
// probably missing some extra setup
172+
const deleteTaggingInput: MultipleBackendDeleteObjectTaggingInput = {
173+
Bucket: testConfig.bucketName,
174+
Key: testConfig.objectKey,
175+
StorageClass: 'us-east-1',
176+
StorageType: 'file',
177+
// Body: new Uint8Array(0)
178+
};
179+
180+
const deleteTaggingCommand = new MultipleBackendDeleteObjectTaggingCommand(deleteTaggingInput);
181+
const deleteTaggingResult = await client.send(deleteTaggingCommand);
182+
assert.strictEqual(deleteTaggingResult.$metadata.httpStatusCode, 200);
185183
});
186184

187-
it('should test MultipleBackendMPU API', async () => {
185+
it.skip('should test MultipleBackendMPU API', async () => {
186+
// Skipped : it's not straightforward to make this test work,
187+
// cloudserver crashes on requests, probably missing some extra setup
188188
const initiateMPUInput: MultipleBackendInitiateMPUInput = {
189189
Bucket: testConfig.bucketName,
190190
Key: `${testConfig.objectKey}-mpu`,

tests/testRaftApis.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ describe('CloudServer Raft API Tests', () => {
107107
logRes.log.on('data', (record: any) => {
108108
logStats.nbLogRecordsRead += 1;
109109
if (record.entries) {
110-
record.entries.forEach((entry: any) => {
110+
record.entries.forEach((_entry: any) => {
111111
logStats.nbLogEntriesRead += 1;
112112
});
113113
}

tests/testSetup.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import https from 'https';
2+
import assert from 'assert';
23
import { CloudserverClient, CloudserverClientConfig } from '../src/index';
34
import { S3Client, PutObjectCommand, CreateBucketCommand, PutBucketVersioningCommand } from '@aws-sdk/client-s3';
45
import { AwsCredentialIdentity, AwsCredentialIdentityProvider } from '@aws-sdk/types';
@@ -71,7 +72,7 @@ async function initBucketForTests() {
7172
});
7273
await s3client.send(putObjectCommand);
7374
} catch (error: any) {
74-
console.log('S3 operation failed:', error);
75+
assert.fail(`Failed to initialize bucket for tests: ${error}`);
7576
}
7677
}
7778

0 commit comments

Comments
 (0)