Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions .github/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Configuration for Release Drafter: https://github.com/toolmantim/release-drafter
name-template: 'v$NEXT_PATCH_VERSION 🌈'
tag-template: 'v$NEXT_PATCH_VERSION'
version-template: $MAJOR.$MINOR.$PATCH
# Emoji reference: https://gitmoji.carloscuesta.me/
categories:
- title: '🚀 Features'
labels:
- 'feature'
- 'enhancement'
- 'kind/feature'
- title: '🐛 Bug Fixes'
labels:
- 'fix'
- 'bugfix'
- 'bug'
- 'regression'
- 'kind/bug'
- title: 📝 Documentation updates
labels:
- documentation
- 'kind/doc'
- title: 👻 Maintenance
labels:
- chore
- dependencies
- 'kind/chore'
- 'kind/dep'
- title: 🚦 Tests
labels:
- test
- tests
exclude-labels:
- reverted
- no-changelog
- skip-changelog
- invalid
autolabeler:
- label: 'documentation'
title:
- '/docs:/i'
- label: 'chore'
title:
- '/chore:/i'
- label: 'bug'
title:
- '/fix:/i'
- label: 'enhancement'
title:
- '/feat:/i'
change-template: '* $TITLE (#$NUMBER) @$AUTHOR'
template: |
## What’s Changed

$CHANGES

## Thanks to
$CONTRIBUTORS
48 changes: 48 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Build

on:
- pull_request

jobs:
Test:
runs-on: ubuntu-20.04
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
- uses: actions/[email protected]
- name: Unit Test
run: |
make test

Build:
runs-on: ubuntu-20.04
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
- uses: actions/[email protected]
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: '~> v2'
args: release --clean --snapshot

BuildImage:
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
- name: Image
run: make build-image

RunE2E:
runs-on: ubuntu-20.04
steps:
- uses: actions/[email protected]
- name: Run e2e
run: |
sudo curl -L https://github.com/docker/compose/releases/download/v2.23.0/docker-compose-linux-x86_64 -o /usr/local/bin/docker-compose
sudo chmod u+x /usr/local/bin/docker-compose
make run-e2e
14 changes: 14 additions & 0 deletions .github/workflows/release-drafter.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Release Drafter

on:
push:
branches:
- master

jobs:
UpdateReleaseDraft:
runs-on: ubuntu-20.04
steps:
- uses: release-drafter/release-drafter@v5
env:
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
100 changes: 100 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
name: Release

on:
push:
tags:
- '*'
branches:
- master

env:
REGISTRY: ghcr.io
REGISTRY_DOCKERHUB: docker.io
IMAGE_NAME: ${{ github.repository }}

jobs:
Test:
runs-on: ubuntu-20.04
steps:
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
- uses: actions/[email protected]
- name: Unit Test
run: |
make test

goreleaser:
runs-on: ubuntu-20.04
if: github.ref != 'refs/heads/master'
steps:
- name: Checkout
uses: actions/[email protected]
with:
fetch-tags: true
fetch-depth: 0
- name: Set output
id: vars
run: echo "tag=$(git describe --tags)" >> $GITHUB_OUTPUT
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: 1.22.x
- name: Image Registry Login
run: |
docker login --username linuxsuren --password ${{secrets.DOCKER_HUB_PUBLISH_SECRETS}}
docker login ${{ env.REGISTRY }}/linuxsuren --username linuxsuren --password ${{secrets.GH_PUBLISH_SECRETS}}
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v6
with:
version: '~> v2'
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GH_PUBLISH_SECRETS }}
- name: Upload via oras
run: |
export TAG=${{ steps.vars.outputs.tag }}
cd dist
oras push ${{ env.REGISTRY_DOCKERHUB }}/linuxsuren/atest-ext-store-orm:${TAG#v} */*
oras push ${{ env.REGISTRY }}/linuxsuren/atest-ext-store-orm:${TAG#v} */*

image:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/[email protected]
- name: Setup Docker buildx
uses: docker/setup-buildx-action@79abd3f86f79a9d68a23c75a09a9a85889262adf
- name: Log into registry ${{ env.REGISTRY }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GH_PUBLISH_SECRETS }}
- name: Log into registry ${{ env.REGISTRY_DOCKERHUB }}
if: github.event_name != 'pull_request'
uses: docker/login-action@28218f9b04b4f3f62068d7b6ce6ca5b26e35336c
with:
registry: ${{ env.REGISTRY_DOCKERHUB }}
username: linuxsuren
password: ${{ secrets.DOCKER_HUB_PUBLISH_SECRETS }}
- name: Extract Docker metadata
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
${{ env.REGISTRY_DOCKERHUB }}/${{ env.IMAGE_NAME }}
- name: Build and push Docker image
id: build-and-push
uses: docker/build-push-action@ac9327eae2b366085ac7f6a2d02df8aa8ead720a
with:
context: .
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ COPY . .

RUN GOPROXY=${GOPROXY} go mod download
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -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-store-iotdb .
-X github.com/linuxsuren/api-testing/pkg/version.date=$(date +%Y-%m-%d)" -o atest-store-iotdb .

FROM ${BASE_IMAGE}

LABEL org.opencontainers.image.source=https://github.com/LinuxSuRen/atest-ext-store-orm
LABEL org.opencontainers.image.description="ORM database Store Extension of the API Testing."
LABEL org.opencontainers.image.source=https://github.com/LinuxSuRen/atest-ext-store-iotdb
LABEL org.opencontainers.image.description="IoTDB database Store Extension of the API Testing."

COPY --from=builder /workspace/atest-store-iotdb /usr/local/bin/atest-store-iotdb

Expand Down
15 changes: 15 additions & 0 deletions README-zh.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# atest-ext-store-iotdb

这个项目是 [atest](https://github.com/linuxsuren/api-testing) 框架的一个存储插件。它为操作 IoTDB(时序数据库)提供了支持,用户可以通过 Web UI 的方式轻松操作数据库,包括查询、插入和管理时序数据。

## 功能

- 与 `api-testing` 框架无缝集成。
- 提供操作 IoTDB 的 Web UI。
- 支持查询和管理时序数据。
- 简化 IoTDB 用户的数据库操作。

## 截图

![image](https://github.com/user-attachments/assets/e36c4cfd-5a2f-4999-a1fc-2a44bf6c221e)
![image](https://github.com/user-attachments/assets/90a78156-55aa-4877-a442-0832c217dbfb)
15 changes: 15 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# atest-ext-store-iotdb

This project is a storage plugin for the [atest](https://github.com/linuxsuren/api-testing) framework. It provides support for interacting with the IoTDB (Time Series Database) through a web UI. With this plugin, users can easily operate the IoTDB database, including querying, inserting, and managing time-series data.

## Features

- Seamless integration with the `api-testing` framework.
- Web UI for interacting with IoTDB.
- Support for querying and managing time-series data.
- Simplifies database operations for IoTDB users.

## Screenshots

![image](https://github.com/user-attachments/assets/e36c4cfd-5a2f-4999-a1fc-2a44bf6c221e)
![image](https://github.com/user-attachments/assets/90a78156-55aa-4877-a442-0832c217dbfb)
2 changes: 1 addition & 1 deletion e2e/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ FROM ghcr.io/linuxsuren/api-testing:master

WORKDIR /workspace
COPY . .
COPY --from=ext /usr/local/bin/atest-store-orm /usr/local/bin/atest-store-orm
COPY --from=ext /usr/local/bin/atest-store-iotdb /usr/local/bin/atest-store-iotdb

CMD [ "/workspace/entrypoint.sh" ]
4 changes: 2 additions & 2 deletions e2e/testing-data-query.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,6 @@ items:
X-Store-Name: "{{.param.store}}"
body: |
{
"sql": "",
"sql": "show databases",
"key": ""
}
}
Binary file removed nvim-linux-x86_64.tar.gz
Binary file not shown.
6 changes: 4 additions & 2 deletions pkg/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,8 +208,10 @@ func TestConvertToDBHistoryTestResult(t *testing.T) {
})
}

var now = time.Now().UTC()
var nowString = now.Format("2006-01-02T15:04:05.999999999")
var (
now = time.Now().UTC()
nowString = now.Format("2006-01-02T15:04:05.999999999")
)

func TestConvertToRemoteHistoryTestResult(t *testing.T) {
assert.Equal(t, &server.HistoryTestResult{
Expand Down
38 changes: 6 additions & 32 deletions pkg/data_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,21 @@ package pkg
import (
"context"
"fmt"
"github.com/apache/iotdb-client-go/client"
"log"
"reflect"
"sort"
"strings"
"time"

"github.com/apache/iotdb-client-go/client"

"github.com/linuxsuren/api-testing/pkg/server"
)

func (s *dbserver) Query(ctx context.Context, query *server.DataQuery) (result *server.DataQueryResult, err error) {
var db *client.SessionPool
var dbQuery DataQuery
if dbQuery, err = s.getClientWithDatabase(ctx, query.Key); err != nil {
if dbQuery, err = s.getClientWithDatabase(ctx); err != nil {
return
}

Expand Down Expand Up @@ -81,15 +82,14 @@ func (s *dbserver) Query(ctx context.Context, query *server.DataQuery) (result *

func sqlQuery(_ context.Context, sql string, sessionPool *client.SessionPool) (result *server.DataQueryResult, err error) {
var session client.Session
var timeout int64 = 1000
if session, err = sessionPool.GetSession(); err != nil {
return
}
defer sessionPool.PutBack(session)

var sessionDataSet *client.SessionDataSet
fmt.Println("query sql", sql)
if sessionDataSet, err = session.ExecuteQueryStatement(sql, &timeout); err != nil {
if sessionDataSet, err = session.ExecuteStatement(sql); err != nil {
return
}

Expand All @@ -100,29 +100,7 @@ func sqlQuery(_ context.Context, sql string, sessionPool *client.SessionPool) (r
}

columns := sessionDataSet.GetColumnNames()
fmt.Println("columns", columns)
count := 0
for next, nextErr := sessionDataSet.Next(); next; {
count++
if count > 10 {
break
}
if nextErr != nil {
err = nextErr
return
}
// Create a slice of interface{}'s to represent each column,
// and a second slice to contain pointers to each item in the columns slice.
columnsData := make([]interface{}, len(columns))
columnsPointers := make([]interface{}, len(columns))
for i := range columnsData {
columnsPointers[i] = &columnsData[i]
}

// Scan the result into the column pointers...

fmt.Println("get data")

for next, nextErr := sessionDataSet.Next(); next && nextErr == nil; next, nextErr = sessionDataSet.Next() {
// Create our map, and retrieve the value for each column from the pointers slice,
// storing it in the map with the name of the column as the key.
for _, colName := range columns {
Expand All @@ -139,12 +117,8 @@ func sqlQuery(_ context.Context, sql string, sessionPool *client.SessionPool) (r
break
}
}
if val == nil {
continue
}

rowData.Key = colName
fmt.Println(colName)
switch v := val.(type) {
case []byte:
rowData.Value = string(v)
Expand Down Expand Up @@ -239,7 +213,7 @@ func (q *commonDataQuery) GetTables(ctx context.Context, currentDatabase string)
for _, table := range tableResult.Items {
for _, item := range table.GetData() {
if item.Key == fmt.Sprintf("Tables_in_%s", currentDatabase) || item.Key == "table_name" ||
item.Key == "Tables" || item.Key == "tablename" {
item.Key == "Tables" || item.Key == "tablename" || item.Key == "Timeseries" || item.Key == "ChildPaths" {
var found bool
for _, name := range tables {
if name == item.Value {
Expand Down
Loading
Loading