Skip to content

Commit cac3cd0

Browse files
authored
fix(cynosdb): close wan error (#173)
* fix(cynosdb): wan status judgement for open/close * test(cynosdb): remove normal db test
1 parent 3e5b7a6 commit cac3cd0

File tree

2 files changed

+45
-40
lines changed

2 files changed

+45
-40
lines changed

__tests__/cynosdb.test.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -41,45 +41,45 @@ describe('Cynosdb', () => {
4141
expect(res.length).toBe(6);
4242
});
4343

44-
test('[NORMAL] deploy', async () => {
45-
const res = await client.deploy(inputs);
46-
expect(res).toEqual({
47-
dbMode: 'NORMAL',
48-
region: inputs.region,
49-
region: inputs.region,
50-
zone: inputs.zone,
51-
vpcConfig: inputs.vpcConfig,
52-
instanceCount: 2,
53-
adminPassword: expect.stringMatching(pwdReg),
54-
clusterId: expect.stringContaining('cynosdbmysql-'),
55-
connection: {
56-
ip: expect.any(String),
57-
port: 3306,
58-
readList: [
59-
{
60-
ip: expect.any(String),
61-
port: 3306,
62-
},
63-
],
64-
},
65-
});
66-
67-
({ clusterId } = res);
68-
});
69-
70-
test('[NORMAL] remove', async () => {
71-
await sleep(300);
72-
const res = await client.remove({ clusterId });
73-
74-
const detail = await getClusterDetail(client.capi, clusterId);
75-
expect(res).toEqual(true);
76-
expect(detail.Status).toBe('isolated');
77-
});
78-
test('[NORMAL] offline', async () => {
79-
await sleep(300);
80-
const res = await offlineCluster(client.capi, clusterId);
81-
expect(res).toBeUndefined();
82-
});
44+
// test('[NORMAL] deploy', async () => {
45+
// const res = await client.deploy(inputs);
46+
// expect(res).toEqual({
47+
// dbMode: 'NORMAL',
48+
// region: inputs.region,
49+
// region: inputs.region,
50+
// zone: inputs.zone,
51+
// vpcConfig: inputs.vpcConfig,
52+
// instanceCount: 2,
53+
// adminPassword: expect.stringMatching(pwdReg),
54+
// clusterId: expect.stringContaining('cynosdbmysql-'),
55+
// connection: {
56+
// ip: expect.any(String),
57+
// port: 3306,
58+
// readList: [
59+
// {
60+
// ip: expect.any(String),
61+
// port: 3306,
62+
// },
63+
// ],
64+
// },
65+
// });
66+
67+
// ({ clusterId } = res);
68+
// });
69+
70+
// test('[NORMAL] remove', async () => {
71+
// await sleep(300);
72+
// const res = await client.remove({ clusterId });
73+
74+
// const detail = await getClusterDetail(client.capi, clusterId);
75+
// expect(res).toEqual(true);
76+
// expect(detail.Status).toBe('isolated');
77+
// });
78+
// test('[NORMAL] offline', async () => {
79+
// await sleep(300);
80+
// const res = await offlineCluster(client.capi, clusterId);
81+
// expect(res).toBeUndefined();
82+
// });
8383

8484
test('[SERVERLESS] deploy', async () => {
8585
inputs.dbMode = 'SERVERLESS';

src/modules/cynosdb/utils.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,9 @@ async function getClusterGrpsInfo(capi, clusterId) {
251251

252252
async function openPublicAccess(capi, clusterId) {
253253
const gprInfo = await getClusterGrpsInfo(capi, clusterId);
254+
if (gprInfo.WanStatus === 'open') {
255+
return gprInfo;
256+
}
254257

255258
console.log(`Start opening public access to cluster ${clusterId}`);
256259
await OpenWan(capi, {
@@ -269,7 +272,9 @@ async function openPublicAccess(capi, clusterId) {
269272

270273
async function closePublicAccess(capi, clusterId) {
271274
const gprInfo = await getClusterGrpsInfo(capi, clusterId);
272-
275+
if (gprInfo.WanStatus !== 'open') {
276+
return gprInfo;
277+
}
273278
console.log(`Start closing public access to cluster ${clusterId}`);
274279
await CloseWan(capi, {
275280
InstanceGrpId: gprInfo.InstanceGrpId,

0 commit comments

Comments
 (0)