perf: 支持京东云dns申请证书

This commit is contained in:
xiaojunnuo
2025-04-02 23:13:55 +08:00
parent 8145808c43
commit 04d79f9117
280 changed files with 421914 additions and 51 deletions
@@ -0,0 +1,122 @@
var MONITOR = require('../../src/services/monitor')
var config = require('config')
var global = config.get('global')
var expect = require('chai').expect
describe('JDCloud.MONITOR', function () {
var monitor = new MONITOR({
credentials: {
accessKeyId: global.accessKeyId,
secretAccessKey: global.secretAccessKey
},
version: {
monitor: 'v1'
},
regionId: 'cn-north-1'
})
it('describeMetrics', function () {
return monitor.describeMetrics({
serviceCode: 'vm',
})
.then(function (data) {
console.log(data)
})
})
it('describeMetricData', function () {
return monitor.describeMetricData({
serviceCode: 'vm',
resourceId: 'i-p1jskbki8',
metric: 'cpu_util',
timeInterval: '1h'
}, 'cn-north-1')
.then(function (data) {
console.log(data)
})
})
it('createAlarm', function () {
return monitor.createAlarm({
createAlarmSpec: {
serviceCode: 'vm',
resourceIds: ['i-p1jskbki8'],
metric: 'cpu_util',
period: 2,
calculation: 'max',
operation: '==',
threshold: 100.0,
times: 1
},
clientToken: 'dsf4safd6hjsfssdf567jaf'
}, 'cn-north-1')
.then(function (data) {
console.log(data)
})
})
it('updateAlarm', function () {
return monitor.updateAlarm({
alarmId: '265945',
serviceCode: 'vm',
resourceIds: ['i-p1jskbki8'],
metric: 'cpu_util',
period: 2,
calculation: 'max',
operation: '==',
threshold: 99.0,
times: 1
}, 'cn-north-1')
.then(function (data) {
console.log(data)
})
})
it('disableAlarm', function () {
return monitor.disableAlarm({
alarmId: '265945',
}, 'cn-north-1')
.then(function (data) {
console.log(data)
})
})
it('enableAlarm', function () {
return monitor.enableAlarm({
alarmId: '265945',
}, 'cn-north-1')
.then(function (data) {
console.log(data)
})
})
it('describeAlarmsByID', function () {
return monitor.describeAlarmsByID({
alarmId: '265945',
}, 'cn-north-1')
.then(function (data) {
console.log(data)
})
})
it('describeAlarms', function () {
return monitor.describeAlarms({
pageNumber: 1,
pageSize: 50
}, 'cn-north-1')
.then(function (data) {
console.log(data)
})
})
it('deleteAlarms', function () {
return monitor.deleteAlarms({
ids: '265945',
}, 'cn-north-1')
.then(function (data) {
console.log(data)
})
})
})
@@ -0,0 +1,33 @@
var NC = require('../../src/services/nativecontainer')
var config = require('config')
var global = config.get('global')
describe('JDCloud.NC', function () {
var nc = new NATIVECONTAINER({
credentials: {
accessKeyId: global.accessKeyId,
secretAccessKey: global.secretAccessKey
},
endpoint: {
host: 'nativecontainer.internal.cn-north-1.jdcloud-api.com', //指定非默认Endpoint
protocol: 'http' //设置使用HTTP而不是HTTPSvpc专用域名不支持HTTPS
},
'x-extra-header': { //指定额外header
"x-jdcloud-security-token" : "xxx", //要调用开启了MFA操作保护的接口需要传递
"x-jdcloud-content-sha256" : "xxx", //body过大,希望用此value替代对body进行哈希的过程
"MyOwn" : "xxx"
},
version: {
nativecontainer: 'v1'
}
})
// var nc = new NC();
describe('describeContainers', function () {
it('should be able to get nc list', function () {
return nc.describeContainers({
filters: [
{name: 'containerId', values: ['c-rxjwzysxu', 'c-73woiy7iz']}
],
}, 'cn-north-1')
})
})
})
@@ -0,0 +1,61 @@
var OSS = require('../../src/services/oss')
var config = require('config')
var global = config.get('global')
var expect = require('chai').expect
describe('JDCloud.OSS', function () {
var oss = new OSS({
credentials: {
accessKeyId: global.accessKeyId,
secretAccessKey: global.secretAccessKey
},
version: {
oss: 'v1'
},
basePath : '/v1', //默认要设为空""
})
describe('listBucket', function () {
it('should be able to get bucket list', function () {
return oss.listBuckets({
},'cn-east-1')
.then(function (data) {
console.log(data)
})
})
})
describe('putBucket', function () {
it('should be able to put bucket', function () {
return oss.putBucket({
bucketname : "apitest"
},'cn-east-1')
.then(function (data) {
console.log(data)
})
})
})
describe('headBucket', function () {
it('should be able to get head', function () {
return oss.headBucket({
bucketname : "apitest"
},'cn-east-1')
.then(function (data) {
console.log(data)
})
})
})
describe('deleteBucket', function () {
it('should be able to get head', function () {
return oss.deleteBucket({
bucketname : "apitest"
},'cn-east-1')
.then(function (data) {
console.log(data)
})
})
})
})
@@ -0,0 +1,70 @@
var VM = require('../../src/services/vm')
var config = require('config')
var global = config.get('global')
var expect = require('chai').expect
describe('JDCloud.VM', function () {
var vm = new VM({
credentials: {
accessKeyId: global.accessKeyId,
secretAccessKey: global.secretAccessKey
},
regionId: 'cn-north-1',
version: {
vm: 'v1'
}
})
it('describeInstances', function () {
console.log("========DescribeInstances=======");
return vm.describeInstances({
filters: [{ name: "name" , values:[ "i-6za0ovr24v",
"i-rj5ve7jegu",
"i-rj5ve7jegu1",
"i-rj5ve7jegu2",
"i-rj5ve7jegu3",
"i-rj5ve7jegu4",
"i-rj5ve7jegdu"] ,operator: "eq"}]
}, 'cn-north-1')
.then(function (data) {
console.log(data)
})
})
describe('should create and delete a instance', function () {
var instanceId = null
it('createInstances', function () {
return vm
.createInstances({
instanceSpec: {
instanceType: 'g.s1.micro',
az: 'cn-north-1a',
imageId: '9d44a0f-88c1-451a-8971-f1f769073b6c',
name: 'node-sdk-test',
elasticIp: { bandwidthMbps: 2, provider: 'BGP' },
primaryNetworkInterface: {
networkInterface: {
subnetId: 'subnet-3dm3k30gh',
az: 'cn-north-1a'
}
},
systemDisk: { diskCategory: 'local' },
description: 'sdk'
},
maxCount: 1
}, 'cn-north-1')
.then(function (data) {
// instanceIds = data.data.instanceIds
// return expec(instanceIds[0]).to.not.be.empty
})
})
it('deleteInstance', function () {
if (instanceId) {
return vm.deleteInstance({
instanceId: instanceId
})
} else {
this.skip()
}
})
})
})