Skip to content

Commit 916ce85

Browse files
authored
feat: add a new extension: mongodb (#278)
* feat: support to jump to a specific version address * feat: add a new extension: mongodb * disable the git e2e test due to unstable * fix the code style isseus --------- Co-authored-by: rick <[email protected]>
1 parent 649b0d8 commit 916ce85

23 files changed

+1377
-42
lines changed

.gitpod.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
# See https://www.gitpod.io/docs/configure/workspaces
1+
22
tasks:
33
- init: make init-env install-precheck
44
before: IMG_TOOL=docker GOPROXY= make build-ext copy-ext build-image
55
command: cd console/atest-ui/ && npm i
66

77
ports:
88
- port: 5713 # console interactive port
9+
10+
vscode:
11+
extensions:
12+
- golang.goteractive port

.remarkrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
listItemIndent=one

CONTRIBUTION.md

+6-1
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ docker run -p 12800:12800 -p 9412:9412 \
5050
-e SW_STORAGE=banyandb \
5151
-e SW_STORAGE_BANYANDB_HOST=192.168.1.98 \
5252
docker.io/apache/skywalking-oap-server
53-
```
53+
```
54+
55+
## FAQ
56+
57+
* Got sum missing match error of go.
58+
* Run command: `go clean -modcache && go mod tidy`

Dockerfile

+9-7
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ COPY --from=ui /workspace/dist/assets/*.css cmd/data/index.css
3636

3737
COPY --from=sk /usr/local/bin/skywalking-go-agent /usr/local/bin/skywalking-go-agent
3838

39-
RUN GOPROXY=${GOPROXY} go mod download
40-
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -toolexec="skywalking-go-agent" -a -ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=${VERSION}\
39+
# RUN GOPROXY=${GOPROXY} go mod download
40+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -toolexec="skywalking-go-agent" -a -ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=${VERSION}\
4141
-X github.com/linuxsuren/api-testing/pkg/version.date=$(date +%Y-%m-%d)" -o atest .
42-
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-collector extensions/collector/main.go
43-
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-store-orm extensions/store-orm/main.go
44-
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-store-s3 extensions/store-s3/main.go
45-
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-store-etcd extensions/store-etcd/main.go
46-
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -toolexec="skywalking-go-agent" -a -ldflags "-w -s" -o atest-store-git extensions/store-git/main.go
42+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-collector extensions/collector/main.go
43+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-store-orm extensions/store-orm/main.go
44+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-store-s3 extensions/store-s3/main.go
45+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-store-etcd extensions/store-etcd/main.go
46+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-store-mongodb extensions/store-mongodb/main.go
47+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -toolexec="skywalking-go-agent" -a -ldflags "-w -s" -o atest-store-git extensions/store-git/main.go
4748

4849
FROM docker.io/library/ubuntu:23.04
4950

@@ -64,6 +65,7 @@ COPY --from=builder /workspace/atest-store-orm /usr/local/bin/atest-store-orm
6465
COPY --from=builder /workspace/atest-store-s3 /usr/local/bin/atest-store-s3
6566
COPY --from=builder /workspace/atest-store-etcd /usr/local/bin/atest-store-etcd
6667
COPY --from=builder /workspace/atest-store-git /usr/local/bin/atest-store-git
68+
COPY --from=builder /workspace/atest-store-mongodb /usr/local/bin/atest-store-mongodb
6769
COPY --from=builder /workspace/LICENSE /LICENSE
6870
COPY --from=builder /workspace/README.md /README.md
6971

Makefile

+5-1
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@ APP_VERSION?=v0.0.13
99
HELM_REPO?=docker.io/linuxsuren
1010

1111
fmt:
12+
go mod tidy
1213
go fmt ./...
1314
cd extensions/store-etcd && go mod tidy && go fmt ./...
1415
cd extensions/store-git && go mod tidy && go fmt ./...
1516
cd extensions/store-orm && go mod tidy && go fmt ./...
1617
cd extensions/store-s3 && go mod tidy && go fmt ./...
18+
cd extensions/store-mongodb && go mod tidy && go fmt ./...
1719
build:
1820
mkdir -p bin
1921
rm -rf bin/atest
2022
CGO_ENABLED=0 go build ${TOOLEXEC} -a ${BUILD_FLAG} -o bin/${BINARY} main.go
21-
build-ext: build-ext-git build-ext-orm build-ext-s3 build-ext-etcd
23+
build-ext: build-ext-git build-ext-orm build-ext-s3 build-ext-etcd build-ext-mongodb
2224
build-ext-git:
2325
CGO_ENABLED=0 go build -ldflags "-w -s" -o bin/atest-store-git extensions/store-git/main.go
2426
build-ext-orm:
@@ -27,6 +29,8 @@ build-ext-etcd:
2729
CGO_ENABLED=0 go build -ldflags "-w -s" -o bin/atest-store-etcd extensions/store-etcd/main.go
2830
build-ext-s3:
2931
CGO_ENABLED=0 go build -ldflags "-w -s" -o bin/atest-store-s3 extensions/store-s3/main.go
32+
build-ext-mongodb:
33+
CGO_ENABLED=0 go build -ldflags "-w -s" -o bin/atest-store-mongodb extensions/store-mongodb/main.go
3034
build-ui:
3135
cd console/atest-ui && npm i && npm run build-only
3236
embed-ui:

console/atest-ui/src/App.vue

+15-1
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,22 @@ const suiteKinds = [{
293293
}]
294294
295295
const appVersion = ref('')
296+
const appVersionLink = ref('https://github.com/LinuxSuRen/api-testing')
296297
API.GetVersion((d) => {
297298
appVersion.value = d.message
299+
const version = d.message.match('^v\\d*.\\d*.\\d*')
300+
const dirtyVersion = d.message.match('^v\\d*.\\d*.\\d*-\\d*-g')
301+
302+
if (!version && !dirtyVersion) {
303+
return
304+
}
305+
306+
console.log(dirtyVersion)
307+
if (dirtyVersion && dirtyVersion.length > 0) {
308+
appVersionLink.value = appVersionLink.value + '/commit/' + d.message.replace(dirtyVersion[0], '')
309+
} else if (version && version.length > 0) {
310+
appVersionLink.value = appVersionLink.value + '/releases/tag/' + version[0]
311+
}
298312
})
299313
</script>
300314

@@ -363,7 +377,7 @@ API.GetVersion((d) => {
363377
</el-container>
364378
</el-main>
365379
<div style="position: absolute; bottom: 0px; right: 10px;">
366-
<a href="https://github.com/LinuxSuRen/api-testing" target="_blank" rel="noopener">{{appVersion}}</a>
380+
<a :href=appVersionLink target="_blank" rel="noopener">{{appVersion}}</a>
367381
</div>
368382
<TemplateFunctions/>
369383
</el-container>

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

+6-2
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,15 @@ interface Store {
5050
properties: Pair[]
5151
}
5252
53+
const storesLoading = ref(false)
5354
function loadStores() {
55+
storesLoading.value = true
5456
API.GetStores((e) => {
5557
stores.value = e.data
5658
}, (e) => {
5759
ElMessage.error('Oops, ' + e)
60+
}, () => {
61+
storesLoading.value = false
5862
})
5963
}
6064
loadStores()
@@ -148,7 +152,7 @@ const submitForm = async (formEl: FormInstance | undefined) => {
148152
function storeVerify(formEl: FormInstance | undefined) {
149153
if (!formEl) return
150154
151-
API.VerifyStore(setStoreForm.name, (e) => {
155+
API.VerifyStore(storeForm.name, (e) => {
152156
if (e.ready) {
153157
ElMessage({
154158
message: 'Verified!',
@@ -180,7 +184,7 @@ function updateKeys() {
180184
<el-button type="primary" @click="addStore" :icon="Edit">{{t('button.new')}}</el-button>
181185
<el-button type="primary" @click="loadStores">{{t('button.refresh')}}</el-button>
182186
</div>
183-
<el-table :data="stores" style="width: 100%">
187+
<el-table :data="stores" style="width: 100%" v-loading=storesLoading>
184188
<el-table-column :label="t('field.name')" width="180">
185189
<template #default="scope">
186190
<el-input v-model="scope.row.name" placeholder="Name"/>

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

+19-18
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ interface AppVersion {
3636
message: string
3737
}
3838

39-
function GetVersion(callback: (v: AppVersion) => {}) {
39+
function GetVersion(callback: (v: AppVersion) => void) {
4040
const requestOptions = {
4141
method: 'POST',
4242
}
@@ -90,7 +90,7 @@ function UpdateTestSuite(suite: any,
9090
}
9191

9292
function GetTestSuite(name: string, callback: () => {},
93-
errHandle: (e: any) => {}) {
93+
errHandle: (e: any) => void) {
9494
const store = Cache.GetCurrentStore()
9595
const requestOptions = {
9696
method: 'POST',
@@ -107,7 +107,7 @@ function GetTestSuite(name: string, callback: () => {},
107107
}
108108

109109
function DeleteTestSuite(name: string,
110-
callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
110+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
111111
const requestOptions = {
112112
method: 'POST',
113113
headers: {
@@ -123,7 +123,7 @@ function DeleteTestSuite(name: string,
123123
}
124124

125125
function ConvertTestSuite(suiteName: string, genertor: string,
126-
callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
126+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
127127
const requestOptions = {
128128
method: 'POST',
129129
headers: {
@@ -163,7 +163,7 @@ interface TestCase {
163163
}
164164

165165
function CreateTestCase(testcase: TestCase,
166-
callback: () => {}, errHandle?: (e: any) => {} | null) {
166+
callback: () => {}, errHandle?: (e: any) => void | null) {
167167
const requestOptions = {
168168
method: 'POST',
169169
headers: {
@@ -187,7 +187,7 @@ function CreateTestCase(testcase: TestCase,
187187
}
188188

189189
function UpdateTestCase(testcase: any,
190-
callback: () => {}, errHandle?: (e: any) => {} | null) {
190+
callback: () => {}, errHandle?: (e: any) => void | null) {
191191
const requestOptions = {
192192
method: 'POST',
193193
headers: {
@@ -201,7 +201,7 @@ function UpdateTestCase(testcase: any,
201201
}
202202

203203
function GetTestCase(req: TestCase,
204-
callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
204+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
205205
const requestOptions = {
206206
method: 'POST',
207207
headers: {
@@ -218,7 +218,7 @@ function GetTestCase(req: TestCase,
218218
}
219219

220220
function ListTestCase(suite: string, store: string,
221-
callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
221+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
222222
const requestOptions = {
223223
method: 'POST',
224224
headers: {
@@ -234,7 +234,7 @@ function ListTestCase(suite: string, store: string,
234234
}
235235

236236
function DeleteTestCase(testcase: TestCase,
237-
callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
237+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
238238
const requestOptions = {
239239
method: 'POST',
240240
headers: {
@@ -256,7 +256,7 @@ interface RunTestCaseRequest {
256256
}
257257

258258
function RunTestCase(request: RunTestCaseRequest,
259-
callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
259+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
260260
const requestOptions = {
261261
method: 'POST',
262262
headers: {
@@ -280,7 +280,7 @@ interface GenerateRequest {
280280
}
281281

282282
function GenerateCode(request: GenerateRequest,
283-
callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
283+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
284284
const requestOptions = {
285285
method: 'POST',
286286
headers: {
@@ -297,14 +297,14 @@ function GenerateCode(request: GenerateRequest,
297297
.then(callback).catch(errHandle)
298298
}
299299

300-
function ListCodeGenerator(callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
300+
function ListCodeGenerator(callback: (d: any) => void, errHandle?: (e: any) => void | null) {
301301
fetch('/server.Runner/ListCodeGenerator', {
302302
method: 'POST'
303303
}).then(DefaultResponseProcess)
304304
.then(callback).catch(errHandle)
305305
}
306306

307-
function PopularHeaders(callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
307+
function PopularHeaders(callback: (d: any) => void, errHandle?: (e: any) => void | null) {
308308
const requestOptions = {
309309
method: 'POST',
310310
headers: {
@@ -316,17 +316,18 @@ function PopularHeaders(callback: (d: any) => {}, errHandle?: (e: any) => {} | n
316316
.then(callback).catch(errHandle)
317317
}
318318

319-
function GetStores(callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
319+
function GetStores(callback: (d: any) => void,
320+
errHandle?: (e: any) => void | null, final?: () => void | null) {
320321
const requestOptions = {
321322
method: 'POST',
322323
}
323324
fetch('/server.Runner/GetStores', requestOptions)
324-
.then(DefaultResponseProcess)
325-
.then(callback).catch(errHandle)
325+
.then(DefaultResponseProcess)
326+
.then(callback).catch(errHandle).finally(final)
326327
}
327328

328329
function DeleteStore(name: string,
329-
callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
330+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
330331
const requestOptions = {
331332
method: 'POST',
332333
body: JSON.stringify({
@@ -339,7 +340,7 @@ function DeleteStore(name: string,
339340
}
340341

341342
function VerifyStore(name: string,
342-
callback: (d: any) => {}, errHandle?: (e: any) => {} | null) {
343+
callback: (d: any) => void, errHandle?: (e: any) => void | null) {
343344
const requestOptions = {
344345
method: 'POST',
345346
body: JSON.stringify({

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

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ export function SupportedExtensions() {
1717
{
1818
value: 'atest-store-etcd',
1919
key: 'atest-store-etcd'
20+
},
21+
{
22+
value: 'atest-store-mongodb',
23+
key: 'atest-store-mongodb'
2024
}
2125
] as Pair[]
2226
}

docs/README.md

+20-2
Original file line numberDiff line numberDiff line change
@@ -160,9 +160,10 @@ There are multiple storage backends supported. See the status from the list:
160160
|---|---|
161161
| Local Storage | Ready |
162162
| S3 | Ready |
163-
| ORM DataBase | Developing |
163+
| ORM DataBase | Ready |
164164
| Git Repository | Ready |
165-
| Etcd DataBase | Ready |
165+
| Etcd | Ready |
166+
| MongoDB | Devloping |
166167

167168
### Local Storage
168169
Local storage is the built-in solution. You can run it with the following command:
@@ -271,6 +272,23 @@ Have a look at the expected configuration below:
271272
insecure: false # whether to use insecure
272273
```
273274
275+
### MongoDB Storage
276+
You can use a MongoDB as the storage backend.
277+
278+
Have a look at the expected configuration below:
279+
280+
```yaml
281+
- name: mongodb
282+
url: 172.11.0.13:27017 # address of the mongodb
283+
username: linuxsuren
284+
password: linuxsuren
285+
kind:
286+
name: atest-store-mongodb # the extension binary file name
287+
properties: # optional properties for specific features
288+
database: testing # the database name
289+
collection: atest # the collection name
290+
```
291+
274292
## Secret Server
275293
You can put sensitive information into a secret server. For example, [Vault](https://www.github.com/hashicorp/vault).
276294

e2e/compose.yaml

+14
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ services:
1313
condition: service_healthy
1414
mariadb:
1515
condition: service_healthy
16+
mongo:
17+
condition: service_healthy
1618
# postgres:
1719
# condition: service_healthy
1820
# clickhouse:
@@ -23,6 +25,7 @@ services:
2325
- etcd
2426
- mysql
2527
- mariadb
28+
- mongo
2629
# - minio
2730
# - postgres
2831
# - clickhouse
@@ -68,6 +71,17 @@ services:
6871
MINIO_ROOT_PASSWORD: root
6972
MINIO_SERVER_HOST: minio
7073
MINIO_DEFAULT_BUCKETS: bucket
74+
mongo:
75+
image: mongo
76+
healthcheck:
77+
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/27017"]
78+
interval: 3s
79+
timeout: 60s
80+
retries: 10
81+
start_period: 3s
82+
environment:
83+
MONGO_INITDB_ROOT_USERNAME: root
84+
MONGO_INITDB_ROOT_PASSWORD: root
7185
# postgres:
7286
# image: postgres:16.0
7387
# environment:

0 commit comments

Comments
 (0)