From 968c16dc64c751b829c7eab589a7dc2817e47f15 Mon Sep 17 00:00:00 2001 From: lihuacai Date: Sat, 29 Apr 2023 19:27:13 +0800 Subject: [PATCH] chore(makefile,dockerfile,docker-compose): add makefile, support fast up with no build, features todo list add makefile, support fast up with no build, up , down, etc... readme add features todo list, usage manual --- Dockerfile | 7 ++-- Makefile | 68 +++++++++++++++++++++++++++++++++++ README.md | 47 +++++++++++++++++++++++- docker-compose-for-fastup.yml | 11 ++++++ docker-compose.yml | 10 ++++-- 5 files changed, 134 insertions(+), 9 deletions(-) create mode 100644 Makefile create mode 100644 docker-compose-for-fastup.yml diff --git a/Dockerfile b/Dockerfile index a74535d..8477c12 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,14 +18,11 @@ RUN wget https://archive.apache.org/dist/jmeter/binaries/apache-jmeter-${JMETER_ rm apache-jmeter-${JMETER_VERSION}.tgz && \ chmod +x ${JMETER_HOME}/bin/jmeter -# 设置pip源为清华源 -RUN mkdir -p /root/.pip && \ - echo "[global]" > /root/.pip/pip.conf && \ - echo "index-url = https://pypi.tuna.tsinghua.edu.cn/simple" >> /root/.pip/pip.conf +ARG PIP_INDEX_URL="https://pypi.org/simple" # 安装项目依赖 COPY requirements.txt /app/requirements.txt -RUN pip install -r /app/requirements.txt +RUN pip install -r /app/requirements.txt -i ${PIP_INDEX_URL} # 设置工作目录 WORKDIR /app diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..fcf1aac --- /dev/null +++ b/Makefile @@ -0,0 +1,68 @@ + +compose-file := docker-compose.yml + +ifdef COMPOSE_FILE + compose-file := $(COMPOSE_FILE) +endif + +cmd = docker-compose -f $(compose-file) + +image_tag ?= latest + + +tag := $(tag) + +service := $(word 1,$(MAKECMDGOALS)) + +.PHONY: fastup +fastup: + export TAG=$(image_tag); docker-compose -f docker-compose-for-fastup.yml up -d --build --remove-orphans + +.PHONY: up +up: + $(cmd) up -d --build --remove-orphans + +.PHONY: up-no-build +up-no-build: + $(cmd) up -d --remove-orphans + +.PHONY: up-tag +up-tag: + export TAG=$(tag); $(cmd) up -d --build --remove-orphans + + +.PHONY: down +down: + $(cmd) down + +.PHONY: build +build: + # build latest + $(cmd) build + +git-tag: + git checkout $(tag) + +.PHONY: build-tag +build-tag:git-tag + export TAG=$(tag); $(cmd) build + +.PHONY: config +config: + $(cmd) config + +.PHONY: ps +ps: + $(cmd) ps + +.PHONY: logs +logs: + $(cmd) logs -f fastapi_jmx + +.PHONY: restart +restart: + $(cmd) restart $(service) + +.PHONY: exec +exec: + $(cmd) exec $(service) /bin/bash diff --git a/README.md b/README.md index 40069ca..91b641f 100644 --- a/README.md +++ b/README.md @@ -2,4 +2,49 @@ Jmeter-Toolkit 是一个专门为 JMeter 测试管理而设计的强大工具集。 通过使用 FastAPI 和 Docker 构建,为用户提供了一个简洁、高效且可扩展的解决方案。 Jmeter-Toolkit 支持 JMX 文件的上传、执行、查看JMX、查看JTL以及HTML报告生成。 -使您能够轻松地完成 JMeter 测试的整个流程。 + +- [x] **jmx文件上传** +- [x] **jmx文件执行** +- [x] **jmx文件查看** +- [x] **jtl文件查看** +- [x] **html报告生成** +- [ ] **合并jmx上传执行查看报告** +- [ ] **jtl文件上传** +- [ ] **jmx文件下载** +- [ ] **jtl文件下载** +- [ ] **jmx文件编辑** +- [ ] **jmx文件参数化** +- [ ] **前端界面化管理** +- [ ] **支持Jmeter插件** +- [ ] **分布式执行** +- [ ] **使用数据库管理文件** + +# 快速启动 +## 1. 安装 Docker +请参考 [Docker 官方文档](https://docs.docker.com/engine/install/) 安装 Docker。 + +## 2. 安装 Docker Compose +请参考 [Docker Compose 官方文档](https://docs.docker.com/compose/install/) 安装 Docker Compose。 +注意:本项目 Docker Compose 仅支持 1.x 版本。 +如果你的 Docker Compose 版本为 2.x,请参考 [Docker Compose 2.x 官方文档](https://docs.docker.com/compose/cli-command/)。 + +## 3. 启动 Jmeter-Toolkit +### 3.1 不构建,直接拉取远程镜像快速启动 +```shell +make +``` + +### 3.2 构建本地镜像并且启动 +```shell +make up +``` + + +## 4. 访问 Jmeter-Toolkit +http://localhost:18000/docs + + +# 使用步骤 +## 1. 上传 JMX 文件 +## 2. 执行 JMX 文件 +## 3. 生成 HTML 报告 \ No newline at end of file diff --git a/docker-compose-for-fastup.yml b/docker-compose-for-fastup.yml new file mode 100644 index 0000000..9fe1e53 --- /dev/null +++ b/docker-compose-for-fastup.yml @@ -0,0 +1,11 @@ +version: "3" + +services: + fastapi_jmx: + image: rikasai/jmeter-toolkit:${TAG:-latest} + ports: + - "18000:8000" + volumes: + - ./jmx_files:/app/jmx_files + - ./jtl_files:/app/jtl_files + diff --git a/docker-compose.yml b/docker-compose.yml index 6b48b44..0f7481f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,9 +1,13 @@ -version: "3" +version: "3.8" services: fastapi_jmx: - build: . - image: fastapi_jmx:latest + image: jmeter-toolkit:latest + build: + context: . + dockerfile: Dockerfile + args: + PIP_INDEX_URL: ${PIP_INDEX_URL:-https://pypi.tuna.tsinghua.edu.cn/simple} ports: - "18000:8000" volumes: