Skip to content

Commit 6c9ab38

Browse files
authored
Merge pull request #661 from LinuxSuRen/feat/elasticsearch
feat: add elasticsearch extension support
1 parent 9d3e7ad commit 6c9ab38

File tree

6 files changed

+37
-26
lines changed

6 files changed

+37
-26
lines changed

console/atest-ui/src/components/Button.vue

Whitespace-only changes.

console/atest-ui/src/views/DataManager.vue

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,17 @@ watch(store, (s) => {
3434
return
3535
}
3636
})
37-
queryDataMeta.value.currentDatabase = ''
38-
sqlQuery.value = ''
37+
38+
switch (kind.value) {
39+
case 'atest-store-elasticsearch':
40+
case 'atest-store-etcd':
41+
sqlQuery.value = '*'
42+
break
43+
default:
44+
queryDataMeta.value.currentDatabase = ''
45+
sqlQuery.value = ''
46+
}
47+
3948
executeQuery()
4049
})
4150
@@ -63,13 +72,22 @@ const describeTable = (data: QueryData) => {
6372
case 'atest-store-cassandra':
6473
sqlQuery.value = `@describeTable_${queryDataMeta.value.currentDatabase}:${data.label}`
6574
break
75+
break
6676
default:
6777
sqlQuery.value = `@describeTable_${data.label}`
6878
}
6979
executeQuery()
7080
}
7181
const queryTables = () => {
72-
sqlQuery.value = ``
82+
switch (kind.value) {
83+
case 'atest-store-elasticsearch':
84+
if (sqlQuery.value === '') {
85+
sqlQuery.value = '*'
86+
}
87+
break
88+
default:
89+
sqlQuery.value = ``
90+
}
7391
executeQuery()
7492
}
7593
watch(kind, (k) => {
@@ -84,6 +102,9 @@ watch(kind, (k) => {
84102
case 'atest-store-redis':
85103
queryTip.value = 'Enter key'
86104
break;
105+
case 'atest-store-elasticsearch':
106+
queryTip.value = 'field:value OR field:other'
107+
break;
87108
}
88109
})
89110
@@ -153,19 +174,14 @@ const executeQuery = async () => {
153174
return executeWithQuery(sqlQuery.value)
154175
}
155176
const executeWithQuery = async (sql: string) => {
156-
switch (kind.value) {
157-
case 'atest-store-etcd':
158-
sqlQuery.value = '*'
159-
break;
160-
}
161-
162177
let success = false
163178
try {
164179
const data = await API.DataQueryAsync(store.value, kind.value, queryDataMeta.value.currentDatabase, sql);
165180
switch (kind.value) {
166181
case 'atest-store-orm':
167182
case 'atest-store-cassandra':
168183
case 'atest-store-iotdb':
184+
case 'atest-store-elasticsearch':
169185
ormDataHandler(data)
170186
success = true
171187
break;
@@ -196,7 +212,7 @@ const executeWithQuery = async (sql: string) => {
196212
<template>
197213
<div>
198214
<el-container style="height: calc(100vh - 50px);">
199-
<el-aside v-if="kind === 'atest-store-orm' || kind === 'atest-store-iotdb' || kind === 'atest-store-cassandra'">
215+
<el-aside v-if="kind === 'atest-store-orm' || kind === 'atest-store-iotdb' || kind === 'atest-store-cassandra' || kind === 'atest-store-elasticsearch'">
200216
<el-scrollbar>
201217
<el-select v-model="queryDataMeta.currentDatabase" placeholder="Select database"
202218
@change="queryTables" filterable>

console/atest-ui/src/views/__test__/store.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import { SupportedExtension, SupportedExtensions } from "../store";
1919
describe("SupportedExtensions", () => {
2020
test('length check', () => {
2121
const extensions = SupportedExtensions()
22-
expect(extensions.length).toBe(8)
22+
expect(extensions.length).toBe(9)
2323
})
2424

2525
for (const extension of SupportedExtensions()) {

console/atest-ui/src/views/net.ts

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -785,21 +785,10 @@ interface QueryObject {
785785
key: string
786786
}
787787
var DataQueryAsync = (store: string, kind: string, currentDatabase: string, query: string) => {
788-
const queryObj = {} as QueryObject;
789-
switch (kind) {
790-
case 'atest-store-orm':
791-
case 'atest-store-cassandra':
792-
case 'atest-store-iotdb':
793-
queryObj['sql'] = query;
794-
queryObj['key'] = currentDatabase;
795-
break;
796-
case 'atest-store-etcd':
797-
queryObj['key'] = query;
798-
break;
799-
case 'atest-store-redis':
800-
queryObj['key'] = query;
801-
break;
802-
}
788+
const queryObj = {
789+
'key': currentDatabase,
790+
'sql': query,
791+
} as QueryObject;
803792
const requestOptions = {
804793
method: 'POST',
805794
headers: {

console/atest-ui/src/views/store.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@ const storeExtensions = [
115115
defaultValue: 'atest'
116116
}],
117117
link: 'https://github.com/LinuxSuRen/atest-ext-store-mongodb'
118+
},
119+
{
120+
name: 'atest-store-elasticsearch',
121+
params: [],
122+
link: 'https://github.com/LinuxSuRen/atest-ext-store-elasticsearch'
118123
}
119124
] as Store[]
120125

extensions/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ Ports in extensions:
1010
| Store | [redis](https://github.com/LinuxSuRen/atest-ext-store-redis) | |
1111
| Store | [iotdb](https://github.com/LinuxSuRen/atest-ext-store-iotdb) | |
1212
| Store | [Cassandra](https://github.com/LinuxSuRen/atest-ext-store-cassandra) | |
13+
| Store | [Elasticsearch](https://github.com/LinuxSuRen/atest-ext-store-elasticsearch) | |
1314
| Monitor | [docker-monitor](https://github.com/LinuxSuRen/atest-ext-monitor-docker) | |
1415
| Agent | [collector](https://github.com/LinuxSuRen/atest-ext-collector) | |
1516
| Secret | [Vault](https://github.com/LinuxSuRen/api-testing-vault-extension) | |

0 commit comments

Comments
 (0)