Skip to content

Commit

Permalink
Merge pull request api7#2 from api7/nic/run-e2e
Browse files Browse the repository at this point in the history
chore: prepare api7 backend for e2e test
  • Loading branch information
oil-oil authored Feb 4, 2024
2 parents 964b5cf + 4dd94a9 commit bde556f
Show file tree
Hide file tree
Showing 5 changed files with 125 additions and 0 deletions.
10 changes: 10 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
default: help
help: ## Display this help
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
.PHONY: help

run-api7:
@docker login hkccr.ccs.tencentyun.com -u 100033089146 -p "{e>rw2[#EDAD" ## read only account
@docker compose -f ./e2e/api7/docker-compose.yaml up -d
@./e2e/api7/init.sh
.PHONY: run-api7
10 changes: 10 additions & 0 deletions e2e/api7/dashboard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server:
listen:
host: "0.0.0.0"
port: 7080

database:
dsn: "postgres://api7ee:changeme@postgresql:5432/api7ee"

prometheus:
addr: "http://prometheus:9090"
74 changes: 74 additions & 0 deletions e2e/api7/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
version: "3.6"

services:
prometheus:
image: bitnami/prometheus:2.44.0-debian-11-r7
hostname: prometheus
command:
- --config.file=/opt/bitnami/prometheus/conf/prometheus.yml
- --web.enable-remote-write-receiver
healthcheck:
test: ["CMD", "/opt/bitnami/prometheus/bin/promtool", "check", "healthy"]
interval: 10s
timeout: 10s
retries: 3
start_period: 10s
networks:
- api7

postgresql:
image: bitnami/postgresql:15.3.0-debian-11-r0
hostname: postgresql
user: root
ports:
- "5432:5432"
healthcheck:
test: ["CMD", "pg_isready", "-U", "api7ee"]
interval: 10s
timeout: 10s
retries: 3
start_period: 10s
environment:
POSTGRES_USER: api7ee
POSTGRES_PASSWORD: changeme
networks:
- api7

api7-ee-dashboard:
image: hkccr.ccs.tencentyun.com/api7-dev/api7-ee-3:dev
hostname: dashboard
restart: always
volumes:
- ./dashboard.yaml:/usr/local/api7/conf/conf.yaml:ro
entrypoint:
- /usr/local/api7/api7-ee-dashboard
- -c
- /usr/local/api7/conf/conf.yaml
ports:
- "7080:7080"
depends_on:
prometheus:
condition: service_healthy
networks:
- api7

api7-ee-dp-manager:
image: hkccr.ccs.tencentyun.com/api7-dev/api7-ee-dp-manager:dev
hostname: dp-manager
restart: always
volumes:
- ./dp-manager.yaml:/usr/local/api7/conf/conf.yaml:ro
command:
- /usr/local/api7/api7-ee-dp-manager
- -c
- /usr/local/api7/conf/conf.yaml
ports:
- "7900:7900"
networks:
- api7

networks:
api7:
driver: bridge
ipam:
driver: default
10 changes: 10 additions & 0 deletions e2e/api7/dp-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
server:
listen:
host: "0.0.0.0"
port: 7900

database:
dsn: "postgres://api7ee:changeme@postgresql:5432/api7ee"

prometheus:
addr: "http://prometheus:9090"
21 changes: 21 additions & 0 deletions e2e/api7/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env bash

set -o errexit
set -o nounset
set -o pipefail

while ! curl -m 1 --output /dev/null --silent --fail http://localhost:7080/healthz;
do
echo "Waiting dashboard ready..." && sleep 1;
done

curl --user admin:admin 'http://localhost:7080/api/license' \
-X 'PUT' \
-H 'Content-Type: application/json' \
--data-raw '{"data":"jEDPm798nC4jnemMZ_6gdxRn0dgxecVY-cRHD6Smuz0Hp_mtrsKJCO_xsLws-zcL_ON0LJFXmLfLAON84NjfhmuayyZ9-GdWSan2COqw0X1cdWDOfDxeJ55jmo5SlVmNufIxFv275pQGNLt7gwhRt6KEpDZLRaJRJx51IcXgCvYI46xoqJYm-CE2tk69HbnTUXM25pzVTaon7UKEmy4SWsXjN6X4dw6H39j_fHCtdBfDXrX9ppYORL1LvTf4jIe6BP9vubLutYTM7R3bk523-EbDuUAMVLzOjngKp3oGJ6IHS52Hue4a2POMiIn4JPHNussR-_VRSFK5Eomfs_MRlw\n"}' -s --output /dev/null

access_token=$(curl --user admin:admin 'http://localhost:7080/api/settings/tokens' \
-H 'Content-Type: application/json' \
--data-raw '{"expires_at":0,"name":"'$(uuidgen)'"}' -s | jq -r .value.token)

echo "access token: " $access_token

0 comments on commit bde556f

Please sign in to comment.