From adc4b2754a21c61fd6d475c9f1d8ada6792fe395 Mon Sep 17 00:00:00 2001 From: rick <1450685+LinuxSuRen@users.noreply.github.com> Date: Fri, 17 Nov 2023 15:01:31 +0800 Subject: [PATCH 1/4] feat: support to jump to a specific version address --- console/atest-ui/src/App.vue | 15 ++++++++++++++- console/atest-ui/src/views/net.ts | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/console/atest-ui/src/App.vue b/console/atest-ui/src/App.vue index ddf38e0a..f4168c25 100644 --- a/console/atest-ui/src/App.vue +++ b/console/atest-ui/src/App.vue @@ -293,8 +293,21 @@ const suiteKinds = [{ }] const appVersion = ref('') +const appVersionLink = ref('https://github.com/LinuxSuRen/api-testing') API.GetVersion((d) => { appVersion.value = d.message + const version = d.message.match('^v\\d*.\\d*.\\d*') + const dirtyVersion = d.message.match('^v\\d*.\\d*.\\d*-g') + + if (!version && !dirtyVersion) { + return + } + + if (dirtyVersion && dirtyVersion.length > 0) { + appVersionLink.value = appVersionLink.value + '/commit/' + d.message.replace(dirtyVersion[0], '') + } else { + appVersionLink.value = appVersionLink.value + '/releases/tag/' + version[0] + } }) @@ -363,7 +376,7 @@ API.GetVersion((d) => {
- {{appVersion}} + {{appVersion}}
diff --git a/console/atest-ui/src/views/net.ts b/console/atest-ui/src/views/net.ts index 9a93f9d4..36c2ef8a 100644 --- a/console/atest-ui/src/views/net.ts +++ b/console/atest-ui/src/views/net.ts @@ -36,7 +36,7 @@ interface AppVersion { message: string } -function GetVersion(callback: (v: AppVersion) => {}) { +function GetVersion(callback: (v: AppVersion) => void) { const requestOptions = { method: 'POST', } From adba7106f9837f5a4c6ab4645d07077ec4db476a Mon Sep 17 00:00:00 2001 From: rick Date: Fri, 17 Nov 2023 09:45:17 +0000 Subject: [PATCH 2/4] feat: add a new extension: mongodb --- .gitpod.yml | 6 +- CONTRIBUTION.md | 7 +- Dockerfile | 16 +- Makefile | 6 +- console/atest-ui/src/App.vue | 5 +- console/atest-ui/src/views/StoreManager.vue | 8 +- console/atest-ui/src/views/net.ts | 35 +- console/atest-ui/src/views/store.ts | 4 + docs/README.md | 22 +- e2e/compose.yaml | 14 + e2e/entrypoint.sh | 1 + extensions/README.md | 1 + extensions/store-mongodb/cmd/root.go | 54 ++ extensions/store-mongodb/go.mod | 104 +++ extensions/store-mongodb/go.sum | 687 ++++++++++++++++++++ extensions/store-mongodb/main.go | 38 ++ extensions/store-mongodb/pkg/client.go | 68 ++ extensions/store-mongodb/pkg/server.go | 283 ++++++++ extensions/store-orm/main.go | 25 + go.mod | 2 +- go.work | 3 +- go.work.sum | 2 + 22 files changed, 1356 insertions(+), 35 deletions(-) create mode 100644 extensions/store-mongodb/cmd/root.go create mode 100644 extensions/store-mongodb/go.mod create mode 100644 extensions/store-mongodb/go.sum create mode 100644 extensions/store-mongodb/main.go create mode 100644 extensions/store-mongodb/pkg/client.go create mode 100644 extensions/store-mongodb/pkg/server.go diff --git a/.gitpod.yml b/.gitpod.yml index b68fa054..4e85e60f 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -1,4 +1,4 @@ -# See https://www.gitpod.io/docs/configure/workspaces + tasks: - init: make init-env install-precheck before: IMG_TOOL=docker GOPROXY= make build-ext copy-ext build-image @@ -6,3 +6,7 @@ tasks: ports: - port: 5713 # console interactive port + +vscode: + extensions: + - golang.goteractive port diff --git a/CONTRIBUTION.md b/CONTRIBUTION.md index a15e4bdc..643af4de 100644 --- a/CONTRIBUTION.md +++ b/CONTRIBUTION.md @@ -50,4 +50,9 @@ docker run -p 12800:12800 -p 9412:9412 \ -e SW_STORAGE=banyandb \ -e SW_STORAGE_BANYANDB_HOST=192.168.1.98 \ docker.io/apache/skywalking-oap-server -``` \ No newline at end of file +``` + +## FAQ + +* Got sum missing match error of go. + * Run command: `go clean -modcache && go mod tidy` diff --git a/Dockerfile b/Dockerfile index 7208acf6..c8f3dfb1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,14 +36,15 @@ COPY --from=ui /workspace/dist/assets/*.css cmd/data/index.css COPY --from=sk /usr/local/bin/skywalking-go-agent /usr/local/bin/skywalking-go-agent -RUN GOPROXY=${GOPROXY} go mod download -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}\ +# RUN GOPROXY=${GOPROXY} go mod download +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}\ -X github.com/linuxsuren/api-testing/pkg/version.date=$(date +%Y-%m-%d)" -o atest . -RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-collector extensions/collector/main.go -RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-store-orm extensions/store-orm/main.go -RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-store-s3 extensions/store-s3/main.go -RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s" -o atest-store-etcd extensions/store-etcd/main.go -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 +RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-collector extensions/collector/main.go +RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-store-orm extensions/store-orm/main.go +RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-store-s3 extensions/store-s3/main.go +RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-store-etcd extensions/store-etcd/main.go +RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -v -ldflags "-w -s" -o atest-store-mongodb extensions/store-mongodb/main.go +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 FROM docker.io/library/ubuntu:23.04 @@ -64,6 +65,7 @@ COPY --from=builder /workspace/atest-store-orm /usr/local/bin/atest-store-orm COPY --from=builder /workspace/atest-store-s3 /usr/local/bin/atest-store-s3 COPY --from=builder /workspace/atest-store-etcd /usr/local/bin/atest-store-etcd COPY --from=builder /workspace/atest-store-git /usr/local/bin/atest-store-git +COPY --from=builder /workspace/atest-store-mongodb /usr/local/bin/atest-store-mongodb COPY --from=builder /workspace/LICENSE /LICENSE COPY --from=builder /workspace/README.md /README.md diff --git a/Makefile b/Makefile index bd8b7916..737d1d00 100644 --- a/Makefile +++ b/Makefile @@ -9,16 +9,18 @@ APP_VERSION?=v0.0.13 HELM_REPO?=docker.io/linuxsuren fmt: + go mod tidy go fmt ./... cd extensions/store-etcd && go mod tidy && go fmt ./... cd extensions/store-git && go mod tidy && go fmt ./... cd extensions/store-orm && go mod tidy && go fmt ./... cd extensions/store-s3 && go mod tidy && go fmt ./... + cd extensions/store-mongodb && go mod tidy && go fmt ./... build: mkdir -p bin rm -rf bin/atest CGO_ENABLED=0 go build ${TOOLEXEC} -a ${BUILD_FLAG} -o bin/${BINARY} main.go -build-ext: build-ext-git build-ext-orm build-ext-s3 build-ext-etcd +build-ext: build-ext-git build-ext-orm build-ext-s3 build-ext-etcd build-ext-mongodb build-ext-git: CGO_ENABLED=0 go build -ldflags "-w -s" -o bin/atest-store-git extensions/store-git/main.go build-ext-orm: @@ -27,6 +29,8 @@ build-ext-etcd: CGO_ENABLED=0 go build -ldflags "-w -s" -o bin/atest-store-etcd extensions/store-etcd/main.go build-ext-s3: CGO_ENABLED=0 go build -ldflags "-w -s" -o bin/atest-store-s3 extensions/store-s3/main.go +build-ext-mongodb: + CGO_ENABLED=0 go build -ldflags "-w -s" -o bin/atest-store-mongodb extensions/store-mongodb/main.go build-ui: cd console/atest-ui && npm i && npm run build-only embed-ui: diff --git a/console/atest-ui/src/App.vue b/console/atest-ui/src/App.vue index f4168c25..7a953981 100644 --- a/console/atest-ui/src/App.vue +++ b/console/atest-ui/src/App.vue @@ -297,15 +297,16 @@ const appVersionLink = ref('https://github.com/LinuxSuRen/api-testing') API.GetVersion((d) => { appVersion.value = d.message const version = d.message.match('^v\\d*.\\d*.\\d*') - const dirtyVersion = d.message.match('^v\\d*.\\d*.\\d*-g') + const dirtyVersion = d.message.match('^v\\d*.\\d*.\\d*-\\d*-g') if (!version && !dirtyVersion) { return } + console.log(dirtyVersion) if (dirtyVersion && dirtyVersion.length > 0) { appVersionLink.value = appVersionLink.value + '/commit/' + d.message.replace(dirtyVersion[0], '') - } else { + } else if (version && version.length > 0) { appVersionLink.value = appVersionLink.value + '/releases/tag/' + version[0] } }) diff --git a/console/atest-ui/src/views/StoreManager.vue b/console/atest-ui/src/views/StoreManager.vue index 089c955b..da7820f4 100644 --- a/console/atest-ui/src/views/StoreManager.vue +++ b/console/atest-ui/src/views/StoreManager.vue @@ -50,11 +50,15 @@ interface Store { properties: Pair[] } +const storesLoading = ref(false) function loadStores() { + storesLoading.value = true API.GetStores((e) => { stores.value = e.data }, (e) => { ElMessage.error('Oops, ' + e) + }, () => { + storesLoading.value = false }) } loadStores() @@ -148,7 +152,7 @@ const submitForm = async (formEl: FormInstance | undefined) => { function storeVerify(formEl: FormInstance | undefined) { if (!formEl) return - API.VerifyStore(setStoreForm.name, (e) => { + API.VerifyStore(storeForm.name, (e) => { if (e.ready) { ElMessage({ message: 'Verified!', @@ -180,7 +184,7 @@ function updateKeys() { {{t('button.new')}} {{t('button.refresh')}} - +