Skip to content

Commit 231a0b7

Browse files
authored
add lucence query support (#1)
* add lucence query support * update e2e * support wildcard query * add readme file * support to show the store size --------- Co-authored-by: Rick <[email protected]>
1 parent 62ae8e4 commit 231a0b7

10 files changed

+246
-215
lines changed

Dockerfile

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
ARG GO_BUILDER=docker.io/library/golang:1.22
2+
ARG BASE_IMAGE=docker.io/library/alpine:3.12
3+
4+
FROM ${GO_BUILDER} AS builder
5+
6+
ARG VERSION
7+
ARG GOPROXY
8+
WORKDIR /workspace
9+
COPY . .
10+
11+
RUN GOPROXY=${GOPROXY} go mod download
12+
RUN GOPROXY=${GOPROXY} CGO_ENABLED=0 go build -ldflags "-w -s -X github.com/linuxsuren/api-testing/pkg/version.version=${VERSION}\
13+
-X github.com/linuxsuren/api-testing/pkg/version.date=$(date +%Y-%m-%d)" -o atest-store-elasticsearch .
14+
15+
FROM ${BASE_IMAGE}
16+
17+
LABEL org.opencontainers.image.source=https://github.com/LinuxSuRen/atest-ext-store-elasticsearch
18+
LABEL org.opencontainers.image.description="Elasticsearch Store Extension of the API Testing."
19+
20+
COPY --from=builder /workspace/atest-store-elasticsearch /usr/local/bin/atest-store-elasticsearch
21+
22+
CMD [ "atest-store-elasticsearch" ]

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# atest-ext-store-elasticsearch
2+
3+
This project is a storage plugin for the [atest](https://github.com/linuxsuren/api-testing) framework. It provides support for interacting with [Elasticsearch](https://www.elastic.co/elasticsearch) through a web UI. With this plugin, users can easily query the data.
4+
5+
## Features
6+
7+
- Seamless integration with the `api-testing` framework.
8+
- Web UI for interacting with Elasticsearch.
9+
- Lucence query

e2e/compose.yaml

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,16 @@ services:
2525
- GOPROXY=${GOPROXY}
2626

2727
elasticsearch:
28-
image: ghcr.io/linuxsuren/apache/elasticsearch:1.3.2-standalone
28+
image: ghcr.io/linuxsuren/library/elasticsearch:8.17.4
2929
environment:
30-
POSTGRES_USER: root
31-
POSTGRES_PASSWORD: root
32-
POSTGRES_DB: atest
30+
- discovery.type=single-node
31+
- ELASTIC_PASSWORD=root
3332
healthcheck:
34-
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/6667"]
33+
test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9200"]
3534
interval: 3s
3635
timeout: 30s
37-
retries: 10
36+
retries: 60
3837
ports:
39-
- 6667
38+
- 9200
4039
volumes:
4140
cache:

e2e/entrypoint.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ mkdir -p /var/data
88
echo "start to run server"
99
nohup atest server&
1010

11-
kind=elasticsearch target=elasticsearch driver=elasticsearch atest run -p testing-data-query.yaml
11+
kind=elasticsearch target=https://elasticsearch:9200 atest run -p testing-data-query.yaml
1212

1313
cat /root/.config/atest/stores.yaml

e2e/testing-data-query.yaml

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,29 +19,14 @@ items:
1919
{
2020
"name": "{{.param.store}}",
2121
"url": "{{env "target"}}",
22-
"username": "{{default "root" (env "username")}}",
22+
"username": "{{default "elastic" (env "username")}}",
2323
"password": "{{default "root" (env "password")}}",
2424
"kind": {
2525
"name": "atest-store-{{env "kind"}}"
2626
},
2727
"properties": [{
28-
"key": "driver",
29-
"value": "{{default "mysql" (env "driver")}}"
30-
}, {
3128
"key": "database",
3229
"value": "{{default "atest" (env "dbname")}}"
33-
}, {
34-
"key": "bucket",
35-
"value": "bucket"
36-
}, {
37-
"key": "region",
38-
"value": "cn"
39-
}, {
40-
"key": "disablessl",
41-
"value": "true"
42-
}, {
43-
"key": "targetPath",
44-
"value": "api-testing"
4530
}]
4631
}
4732
- name: query
@@ -55,19 +40,6 @@ items:
5540
X-Store-Name: "{{.param.store}}"
5641
body: |
5742
{
58-
"sql": "show databases",
43+
"sql": "*",
5944
"key": ""
6045
}
61-
- name: invalidSQL
62-
request:
63-
api: /data/query
64-
method: POST
65-
header:
66-
X-Store-Name: "{{.param.store}}"
67-
body: |
68-
{
69-
"sql": "select1 * from table",
70-
"key": ""
71-
}
72-
expect:
73-
statusCode: 500

elas.go

Lines changed: 0 additions & 159 deletions
This file was deleted.

go.mod

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ toolchain go1.23.8
66

77
require (
88
github.com/apache/iotdb-client-go v1.3.3
9-
github.com/linuxsuren/api-testing v0.0.19
9+
github.com/linuxsuren/api-testing v0.0.20-0.20250331081733-9d3e7ad6d47b
1010
github.com/spf13/cobra v1.9.1
1111
google.golang.org/protobuf v1.36.6
1212
)
@@ -21,6 +21,9 @@ require (
2121
github.com/blang/semver/v4 v4.0.0 // indirect
2222
github.com/bufbuild/protocompile v0.6.0 // indirect
2323
github.com/cespare/xxhash/v2 v2.2.0 // indirect
24+
github.com/cucumber/gherkin-go/v19 v19.0.3 // indirect
25+
github.com/cucumber/godog v0.12.6 // indirect
26+
github.com/cucumber/messages-go/v16 v16.0.1 // indirect
2427
github.com/davecgh/go-spew v1.1.1 // indirect
2528
github.com/evanphx/json-patch v0.5.2 // indirect
2629
github.com/expr-lang/expr v1.15.6 // indirect
@@ -31,15 +34,22 @@ require (
3134
github.com/go-openapi/jsonreference v0.21.0 // indirect
3235
github.com/go-openapi/spec v0.21.0 // indirect
3336
github.com/go-openapi/swag v0.23.0 // indirect
37+
github.com/gofrs/uuid v4.2.0+incompatible // indirect
3438
github.com/golang/protobuf v1.5.4 // indirect
3539
github.com/google/uuid v1.6.0 // indirect
3640
github.com/gorilla/mux v1.8.1 // indirect
3741
github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // indirect
42+
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
43+
github.com/hashicorp/go-memdb v1.3.2 // indirect
44+
github.com/hashicorp/golang-lru v0.5.4 // indirect
3845
github.com/huandu/xstrings v1.4.0 // indirect
46+
github.com/iancoleman/orderedmap v0.3.0 // indirect
3947
github.com/imdario/mergo v0.3.16 // indirect
48+
github.com/invopop/jsonschema v0.7.0 // indirect
4049
github.com/jhump/protoreflect v1.15.3 // indirect
4150
github.com/josharian/intern v1.0.0 // indirect
4251
github.com/linuxsuren/go-fake-runtime v0.0.4 // indirect
52+
github.com/linuxsuren/go-service v0.0.0-20231225060426-efabcd3a5161 // indirect
4353
github.com/linuxsuren/oauth-hub v0.0.0-20240809060240-e78c21b5d8d4 // indirect
4454
github.com/linuxsuren/unstructured v0.0.1 // indirect
4555
github.com/mailru/easyjson v0.7.7 // indirect

0 commit comments

Comments
 (0)