-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinteg-test.mjs
73 lines (55 loc) · 1.94 KB
/
integ-test.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import validate_backend from '@phorbas/store/esm/node/validate_backend.mjs'
import bkc_with_minio from '@phorbas/store/esm/node/minio.mjs'
import bkc_with_level from '@phorbas/store/esm/node/level.mjs'
const Minio = require('minio')
const proxy_agent = require('proxy-agent')
const AWS = require('aws-sdk')
const levelup = require('levelup')
const s3leveldown = require('s3leveldown')
const encodingdown = require('encoding-down')
const accessKeyId = 'AKIAIOSFODNN7EXAMPLE'
const secretAccessKey = 'wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY'
validate_backend('minio', async ()=> {
const minio = new Minio.Client({
endPoint: 'minio', port: 9000, useSSL: false,
accessKey: accessKeyId, secretKey: secretAccessKey })
if (process.env.http_proxy) {
minio.setRequestOptions({
agent: proxy_agent(process.env.http_proxy)
})
}
const bucket = 'phorbas-test'
if (! await minio.bucketExists(bucket))
await minio.makeBucket(bucket, 'us-east-1')
return bkc_with_minio(minio, {bucket}) })
validate_backend('s3 with levelup(s3leveldown())', async ()=> {
const s3_awssdk = new AWS.S3({
endpoint: 'http://minio:9000',
s3ForcePathStyle: true,
accessKeyId, secretAccessKey })
await s3_awssdk.createBucket({Bucket: 'phorbas-s3leveldown'})
.promise()
.catch(err => {
if (err.statusCode !== 409)
throw err
})
return bkc_with_level(
levelup(
s3leveldown('phorbas-s3leveldown', s3_awssdk)))
})
validate_backend('s3 with levelup(encodingdown(s3leveldown()))', async ()=> {
const s3_awssdk = new AWS.S3({
endpoint: 'http://minio:9000',
s3ForcePathStyle: true,
accessKeyId, secretAccessKey })
await s3_awssdk.createBucket({Bucket: 'phorbas-encdown-s3leveldown'})
.promise()
.catch(err => {
if (err.statusCode !== 409)
throw err
})
return bkc_with_level(
levelup(
encodingdown(
s3leveldown('phorbas-encdown-s3leveldown', s3_awssdk))))
})