Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
GaryGoh committed Mar 23, 2024
1 parent d52d837 commit c663c9e
Show file tree
Hide file tree
Showing 10 changed files with 70 additions and 2 deletions.
24 changes: 24 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# 使用单阶段构建,因为我们已经有了本地的k6二进制文件

# 基础镜像
FROM alpine:latest

# 安装必要的依赖
RUN apk add --no-cache ca-certificates

# 复制本地的k6 tar文件到镜像中
COPY k6-v0.49.0-linux-amd64.tar.gz /tmp/k6.tar.gz

# 解压k6 tar文件,并将k6二进制文件移动到/usr/bin
RUN tar -xzf /tmp/k6.tar.gz -C /tmp \
&& mv /tmp/k6-v0.49.0-linux-amd64/k6 /usr/bin/k6 \
&& rm -rf /tmp/k6-v0.49.0-linux-amd64 /tmp/k6.tar.gz

# 验证k6安装
RUN k6 version

# 将你的测试脚本复制到镜像中
COPY tests/simple.js /logstore-loggen-simple.js

# 为你的镜像设置默认的运行命令
ENTRYPOINT ["k6", "run", "/logstore-loggen-simple.js"]
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ The total amount of different streams is defined by the carthesian product of al
Additionally, `xk6-logstore` also supports custom labels that can be used instead
of the built-in labels.

See [examples/custom-labels.js](examples/custom-labels.js) for a full example with custom labels.
See [examples/custom-labels.js](tests/custom-labels.js) for a full example with custom labels.

## Metrics

Expand Down Expand Up @@ -308,4 +308,4 @@ export default () => {
./k6 run examples/simple.js
```

You can find more examples in the [examples/](./examples) folder.
You can find more examples in the [examples/](./tests) folder.
24 changes: 24 additions & 0 deletions deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: logstore-tester
spec:
replicas: 1
selector:
matchLabels:
app: logstore-tester
template:
metadata:
labels:
app: logstore-tester
spec:
containers:
- name: logstore-tester
image: garygao90/logstore-tester:latest
# image: registry.cn-hangzhou.aliyuncs.com/insightmon/logstore-tester:v1.0.0

args: ["--vus", "10", "--duration", "1h"]
# 根据需要添加环境变量
env:
- name: LOGSTORE_URL
value: "http://logstore-write:3100/logstore/api/v1/push"
Binary file added k6-v0.49.0-linux-amd64.tar.gz
Binary file not shown.
20 changes: 20 additions & 0 deletions schduler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: logstore-tester
spec:
# schedule: "0 */4 * * *" # 每 4 小时运行一次
schedule: "*/1 * * * *" # 每分钟运行一次
jobTemplate:
spec:
template:
spec:
containers:
- name: logstore-tester
image: registry.cn-hangzhou.aliyuncs.com/insightmon/logstore-tester:latest
args: ["--vus", "10", "--duration", "1h"]
# 环境变量
env:
- name: LOGSTORE_URL
value: "http://logstore-write:3100/logstore/api/v1/push"
restartPolicy: OnFailure
File renamed without changes.
Empty file added tests/logstore-loggen-simple.js
Empty file.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit c663c9e

Please sign in to comment.