This is an automated email from the ASF dual-hosted git repository. hanahmily pushed a commit to branch test-traffic-gen in repository https://gitbox.apache.org/repos/asf/skywalking-banyandb.git
commit 3b170f0508bf4e781f8fe96c4d5faf3a9e9d300d Author: Gao Hongtao <[email protected]> AuthorDate: Tue Jul 5 00:50:42 2022 +0000 Add traffic generator Signed-off-by: Gao Hongtao <[email protected]> --- .../event/banyandb/docker-compose.yml => .air.toml | 37 +++----- .gitignore => .dockerignore | 27 +----- .gitignore | 1 + banyand/Dockerfile | 33 ++++++- banyand/Makefile | 3 - banyand/liaison/http/server.go | 42 +++++++-- bydbctl/Dockerfile | 5 +- bydbctl/Makefile | 1 - scripts/build/base.mk | 1 - scripts/build/build.mk | 6 +- scripts/build/docker.mk | 4 +- .../docker-compose => docker}/base-compose.yml | 30 ++---- .../e2e-v2/cases/event/banyandb/docker-compose.yml | 2 - test/e2e-v2/script/docker-compose/base-compose.yml | 100 +++----------------- .gitignore => test/stress/Makefile | 39 +++----- test/stress/docker-compose.yaml | 105 +++++++++++++++++++++ test/stress/env | 31 ++++++ test/stress/env.dev | 31 ++++++ test/stress/log4j2.xml | 34 +++++++ test/stress/scripts/consumer.js | 29 ++++++ 20 files changed, 352 insertions(+), 209 deletions(-) diff --git a/test/e2e-v2/cases/event/banyandb/docker-compose.yml b/.air.toml similarity index 56% copy from test/e2e-v2/cases/event/banyandb/docker-compose.yml copy to .air.toml index 551c406..1536468 100644 --- a/test/e2e-v2/cases/event/banyandb/docker-compose.yml +++ b/.air.toml @@ -13,28 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -version: '3.8' +# Config file for [Air](https://github.com/cosmtrek/air) in TOML format -services: - banyandb: - extends: - file: ../../../script/docker-compose/base-compose.yml - service: banyandb - networks: - - e2e +# Working directory +# . or absolute path, please note that the directories following must be under root. +root = "." +tmp_dir = "tmp" - oap: - extends: - file: ../../../script/docker-compose/base-compose.yml - service: oap - environment: - SW_STORAGE: banyandb - depends_on: - banyandb: - condition: service_healthy - ports: - - 11800 - - 12800 - -networks: - e2e: +[build] +# Just plain old shell command. You could use `make` as well. +cmd = "go build -gcflags='all=-N -l' -buildvcs=false -o ./tmp/main ./banyand/cmd/server" +# Binary file yields from `cmd`. +bin = "tmp/main" +# Customize binary. +full_bin = "dlv exec --accept-multiclient --log --headless --continue --listen :2345 --api-version 2 ./tmp/main standalone" +# Watch these filename extensions. +include_ext = ["go"] diff --git a/.gitignore b/.dockerignore similarity index 75% copy from .gitignore copy to .dockerignore index 426298d..f52bea0 100644 --- a/.gitignore +++ b/.dockerignore @@ -15,34 +15,17 @@ # specific language governing permissions and limitations # under the License. -# Binaries for programs and plugins *.exe *.exe~ *.dll *.so *.dylib + bin include -/build +build target +test -# Test binary, build with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out - -# editor and IDE paraphernalia -.idea -*.swp -*.swo -*~ -.vscode - -.DS_Store -.env -.run - -# mock files -*mock.go -*mock_test.go +dist +*/node_modules diff --git a/.gitignore b/.gitignore index 426298d..32e3104 100644 --- a/.gitignore +++ b/.gitignore @@ -25,6 +25,7 @@ bin include /build target +/tmp # Test binary, build with `go test -c` *.test diff --git a/banyand/Dockerfile b/banyand/Dockerfile index ddfa360..a1baea8 100644 --- a/banyand/Dockerfile +++ b/banyand/Dockerfile @@ -14,16 +14,28 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG BASE_IMAGE -ARG CERT_IMAGE +FROM golang:1.18 AS dev +WORKDIR /app +ENV GOOS="linux" +ENV CGO_ENABLED=0 -FROM $BASE_IMAGE AS base +RUN go install github.com/cosmtrek/air@latest \ + && go install github.com/go-delve/delve/cmd/dlv@latest + +EXPOSE 8080 +EXPOSE 2345 + +ENTRYPOINT ["air"] + +FROM golang:1.18 AS base ENV GOPATH "/go" ENV GO111MODULE "on" WORKDIR /src COPY go.* ./ RUN go mod download +RUN GOBIN=/bin go install github.com/grpc-ecosystem/[email protected] \ + && chmod 755 /bin/grpc-health-probe FROM base AS builder @@ -31,7 +43,7 @@ RUN --mount=target=. \ --mount=type=cache,target=/root/.cache/go-build \ BUILD_DIR=/out make -C banyand all -FROM $CERT_IMAGE AS certs +FROM alpine:edge AS certs RUN apk add --no-cache ca-certificates RUN update-ca-certificates @@ -40,4 +52,17 @@ FROM busybox:stable-glibc COPY --from=builder /out/banyand-server /banyand-server COPY --from=certs /etc/ssl/certs /etc/ssl/certs +EXPOSE 17912 +EXPOSE 17913 + +ENTRYPOINT ["/banyand-server"] + +FROM busybox:stable-glibc AS test + +COPY --from=builder /out/banyand-server /banyand-server +COPY --from=base /bin/grpc-health-probe /grpc-health-probe + +EXPOSE 17912 +EXPOSE 17913 + ENTRYPOINT ["/banyand-server"] \ No newline at end of file diff --git a/banyand/Makefile b/banyand/Makefile index 38a98bb..e14e560 100644 --- a/banyand/Makefile +++ b/banyand/Makefile @@ -29,8 +29,5 @@ include ../scripts/build/build.mk include ../scripts/build/test.mk # TODO: remove this include ../scripts/build/lint-deprecated.mk - -DOCKER_BUILD_ARGS := --build-arg CERT_IMAGE=alpine:edge --build-arg BASE_IMAGE=golang:${go_version} - include ../scripts/build/docker.mk include ../scripts/build/help.mk diff --git a/banyand/liaison/http/server.go b/banyand/liaison/http/server.go index 700d951..f1737b7 100644 --- a/banyand/liaison/http/server.go +++ b/banyand/liaison/http/server.go @@ -27,10 +27,14 @@ import ( "github.com/go-chi/chi/v5" "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" + "go.uber.org/multierr" "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" - pb "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1" + database_v1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/database/v1" + measure_v1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/measure/v1" + property_v1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/property/v1" + stream_v1 "github.com/apache/skywalking-banyandb/api/proto/banyandb/stream/v1" "github.com/apache/skywalking-banyandb/pkg/logger" "github.com/apache/skywalking-banyandb/pkg/run" "github.com/apache/skywalking-banyandb/ui" @@ -50,11 +54,12 @@ func NewService() ServiceRepo { } type service struct { - listenAddr string - grpcAddr string - mux *chi.Mux - stopCh chan struct{} - l *logger.Logger + listenAddr string + grpcAddr string + mux *chi.Mux + stopCh chan struct{} + clientCloser context.CancelFunc + l *logger.Logger } func (p *service) FlagSet() *run.FlagSet { @@ -86,9 +91,27 @@ func (p *service) PreRun() error { p.mux.Mount("/", intercept404(fileServer, serveIndex)) gwMux := runtime.NewServeMux() - - err = pb.RegisterStreamRegistryServiceHandlerFromEndpoint(context.Background(), gwMux, p.grpcAddr, - []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}) + var ctx context.Context + ctx, p.clientCloser = context.WithCancel(context.Background()) + + err = multierr.Combine( + database_v1.RegisterStreamRegistryServiceHandlerFromEndpoint(ctx, gwMux, p.grpcAddr, + []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}), + database_v1.RegisterMeasureRegistryServiceHandlerFromEndpoint(ctx, gwMux, p.grpcAddr, + []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}), + database_v1.RegisterIndexRuleRegistryServiceHandlerFromEndpoint(ctx, gwMux, p.grpcAddr, + []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}), + database_v1.RegisterIndexRuleBindingRegistryServiceHandlerFromEndpoint(ctx, gwMux, p.grpcAddr, + []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}), + database_v1.RegisterGroupRegistryServiceHandlerFromEndpoint(ctx, gwMux, p.grpcAddr, + []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}), + stream_v1.RegisterStreamServiceHandlerFromEndpoint(ctx, gwMux, p.grpcAddr, + []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}), + measure_v1.RegisterMeasureServiceHandlerFromEndpoint(ctx, gwMux, p.grpcAddr, + []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}), + property_v1.RegisterPropertyServiceHandlerFromEndpoint(ctx, gwMux, p.grpcAddr, + []grpc.DialOption{grpc.WithTransportCredentials(insecure.NewCredentials())}), + ) if err != nil { return err } @@ -107,6 +130,7 @@ func (p *service) Serve() run.StopNotify { } func (p *service) GracefulStop() { + p.clientCloser() close(p.stopCh) } diff --git a/bydbctl/Dockerfile b/bydbctl/Dockerfile index b91d73a..c1eaf5c 100644 --- a/bydbctl/Dockerfile +++ b/bydbctl/Dockerfile @@ -14,10 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. -ARG BASE_IMAGE -ARG CERT_IMAGE - -FROM $BASE_IMAGE AS base +FROM golang:1.18 AS base ENV GOPATH "/go" ENV GO111MODULE "on" diff --git a/bydbctl/Makefile b/bydbctl/Makefile index afcabaf..dbfeff1 100644 --- a/bydbctl/Makefile +++ b/bydbctl/Makefile @@ -49,7 +49,6 @@ $(BUILDS): .PHONY: release release: $(BUILDS) -DOCKER_BUILD_ARGS := --build-arg BASE_IMAGE=golang:${go_version} include ../scripts/build/docker.mk include ../scripts/build/test.mk include ../scripts/build/lint.mk diff --git a/scripts/build/base.mk b/scripts/build/base.mk index 3f3c7cd..a0d3b2b 100644 --- a/scripts/build/base.mk +++ b/scripts/build/base.mk @@ -23,7 +23,6 @@ tool_bin := $(root_dir)/bin tool_include := "$(root_dir)/include" buf_version ?= v1.5.0 -go_version ?= 1.18 # Retrieve git versioning details so we can add to our binary assets VERSION_PATH := github.com/apache/skywalking-banyandb/pkg/version diff --git a/scripts/build/build.mk b/scripts/build/build.mk index ae3b786..13f1188 100644 --- a/scripts/build/build.mk +++ b/scripts/build/build.mk @@ -39,7 +39,7 @@ all: $(BINARIES) ## Build all the binaries $(BINARIES): $(NAME)-%: $(BUILD_DIR)/$(NAME)-% $(addprefix $(BUILD_DIR)/,$(BINARIES)): $(BUILD_DIR)/$(NAME)-%: @echo "Building binary" - go build -v --ldflags '${GO_LINK_VERSION}' -tags "$(BUILD_TAGS)" -o $@ github.com/apache/skywalking-banyandb/$(SOURCE_DIR)/cmd/$* + go build -v -buildvcs=false --ldflags '${GO_LINK_VERSION}' -tags "$(BUILD_TAGS)" -o $@ github.com/apache/skywalking-banyandb/$(SOURCE_DIR)/cmd/$* chmod +x $@ @echo "Done building $(NAME) $*" @@ -49,7 +49,7 @@ $(DEBUG_BINARIES): $(NAME)-%-debug: $(BUILD_DIR)/$(NAME)-%-debug $(addprefix $(BUILD_DIR)/,$(DEBUG_BINARIES)): $(BUILD_DIR)/$(NAME)-%-debug: @echo "Building debug binary" mkdir -p $(BUILD_DIR) - go build -v --ldflags '${GO_LINK_VERSION}' -tags "$(BUILD_TAGS)" -gcflags='all=-N -l' -o $@ github.com/apache/skywalking-banyandb/$(SOURCE_DIR)/cmd/$* + go build -v -buildvcs=false --ldflags '${GO_LINK_VERSION}' -tags "$(BUILD_TAGS)" -gcflags='all=-N -l' -o $@ github.com/apache/skywalking-banyandb/$(SOURCE_DIR)/cmd/$* chmod +x $@ @echo "Done building debug $(NAME) $*" @@ -57,6 +57,7 @@ $(STATIC_BINARIES): $(NAME)-%-static: $(BUILD_DIR)/$(NAME)-%-static $(addprefix $(BUILD_DIR)/,$(STATIC_BINARIES)): $(BUILD_DIR)/$(NAME)-%-static: @echo "Building static binary" CGO_ENABLED=0 GOOS=linux go build \ + -buildvcs=false \ -a --ldflags '${GO_LINK_VERSION} -extldflags "-static"' -tags "netgo $(BUILD_TAGS)" -installsuffix netgo \ -o $(BUILD_DIR)/$(NAME)-$*-static github.com/apache/skywalking-banyandb/$(SOURCE_DIR)/cmd/$* chmod +x $(BUILD_DIR)/$(NAME)-$*-static @@ -68,6 +69,7 @@ $(DEBUG_STATIC_BINARIES): $(NAME)-%-debug-static: $(BUILD_DIR)/$(NAME)-%-debug-s $(addprefix $(BUILD_DIR)/,$(DEBUG_STATIC_BINARIES)): $(BUILD_DIR)/$(NAME)-%-debug-static: @echo "Building debug static binary" CGO_ENABLED=0 GOOS=linux go build \ + -buildvcs=false \ -a --ldflags '${GO_LINK_VERSION} -extldflags "-static"' -tags "netgo $(BUILD_TAGS)" -gcflags='all=-N -l' -installsuffix netgo \ -o $(BUILD_DIR)/$(NAME)-$*-debug-static github.com/apache/skywalking-banyandb/$(SOURCE_DIR)/cmd/$* chmod +x $(BUILD_DIR)/$(NAME)-$*-debug-static diff --git a/scripts/build/docker.mk b/scripts/build/docker.mk index ead34c9..d34df40 100644 --- a/scripts/build/docker.mk +++ b/scripts/build/docker.mk @@ -29,8 +29,6 @@ TAG ?= latest IMG := $(HUB)/$(IMG_NAME):$(TAG) -DOCKER_BUILD_ARGS ?= "" - # Disable cache in CI environment ifeq (true,$(CI)) DOCKER_BUILD_ARGS := $(DOCKER_BUILD_ARGS) --no-cache --load @@ -39,7 +37,7 @@ endif .PHONY: docker docker: @echo "Build $(IMG)" - @time docker buildx build $(DOCKER_BUILD_ARGS) -t $(IMG) -f Dockerfile .. + time docker buildx build $(DOCKER_BUILD_ARGS) -t $(IMG) -f Dockerfile .. .PHONY: docker.push docker.push: diff --git a/test/e2e-v2/script/docker-compose/base-compose.yml b/test/docker/base-compose.yml similarity index 87% copy from test/e2e-v2/script/docker-compose/base-compose.yml copy to test/docker/base-compose.yml index dd665ea..1db2405 100644 --- a/test/e2e-v2/script/docker-compose/base-compose.yml +++ b/test/docker/base-compose.yml @@ -13,26 +13,19 @@ # See the License for the specific language governing permissions and # limitations under the License. -version: '2.1' - services: banyandb: - image: "apache/skywalking-banyandb:${TAG}" - networks: - - e2e expose: - 17912 - command: standalone --stream-root-path /tmp/stream-data --measure-root-path /tmp/measure-data + command: standalone healthcheck: - test: ["CMD", "sh", "-c", "nc -nz 127.0.0.1 17912"] + test: ["CMD", "/grpc-health-probe", "-addr=localhost:17912"] interval: 5s - timeout: 60s + timeout: 10s retries: 120 agent: image: "ghcr.io/apache/skywalking-java/skywalking-java:${SW_AGENT_JAVA_COMMIT}-java8" - networks: - - e2e command: cp -r /skywalking/agent/ /skywalking-java-agent/ volumes: - sw_agent:/skywalking-java-agent @@ -44,10 +37,6 @@ services: - 12800 - 10051 - 5005 - networks: - - e2e - volumes: - - ./../prepare/setup-oap/log4j2.xml:/skywalking/config/log4j2.xml environment: SW_CLUSTER_ZK_HOST_PORT: zk:2181 SW_STORAGE_ES_CLUSTER_NODES: es:9200 @@ -69,8 +58,6 @@ services: image: "ghcr.io/apache/skywalking/ui:${SW_OAP_COMMIT}" expose: - 8080 - networks: - - e2e environment: - SW_OAP_ADDRESS=http://oap:12800 @@ -78,8 +65,6 @@ services: image: "ghcr.io/apache/skywalking/e2e-service-provider:${SW_AGENT_E2E_SERVICE_PROVIDER_COMMIT}" volumes: - sw_agent:/sw-java-agent - networks: - - e2e expose: - 9090 - 5005 @@ -101,8 +86,6 @@ services: image: "ghcr.io/apache/skywalking/e2e-service-consumer:${SW_AGENT_E2E_SERVICE_PROVIDER_COMMIT}" volumes: - sw_agent:/sw-java-agent - networks: - - e2e expose: - 9092 - 5005 @@ -121,8 +104,11 @@ services: timeout: 60s retries: 120 -networks: - e2e: + traffic_loader: + image: grafana/k6:latest + ports: + - "6565:6565" + volumes: sw_agent: \ No newline at end of file diff --git a/test/e2e-v2/cases/event/banyandb/docker-compose.yml b/test/e2e-v2/cases/event/banyandb/docker-compose.yml index 551c406..aa3bb42 100644 --- a/test/e2e-v2/cases/event/banyandb/docker-compose.yml +++ b/test/e2e-v2/cases/event/banyandb/docker-compose.yml @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -version: '3.8' - services: banyandb: extends: diff --git a/test/e2e-v2/script/docker-compose/base-compose.yml b/test/e2e-v2/script/docker-compose/base-compose.yml index dd665ea..452c50c 100644 --- a/test/e2e-v2/script/docker-compose/base-compose.yml +++ b/test/e2e-v2/script/docker-compose/base-compose.yml @@ -17,112 +17,42 @@ version: '2.1' services: banyandb: + extends: + file: ../../docker/docker-compose/base-compose.yml + service: banyandb image: "apache/skywalking-banyandb:${TAG}" networks: - e2e - expose: - - 17912 - command: standalone --stream-root-path /tmp/stream-data --measure-root-path /tmp/measure-data - healthcheck: - test: ["CMD", "sh", "-c", "nc -nz 127.0.0.1 17912"] - interval: 5s - timeout: 60s - retries: 120 agent: - image: "ghcr.io/apache/skywalking-java/skywalking-java:${SW_AGENT_JAVA_COMMIT}-java8" + extends: + file: ../../docker/docker-compose/base-compose.yml + service: agent networks: - e2e - command: cp -r /skywalking/agent/ /skywalking-java-agent/ - volumes: - - sw_agent:/skywalking-java-agent oap: - image: "ghcr.io/apache/skywalking/oap:${SW_OAP_COMMIT}" - expose: - - 11800 - - 12800 - - 10051 - - 5005 + extends: + file: ../../docker/docker-compose/base-compose.yml + service: oap networks: - e2e volumes: - ./../prepare/setup-oap/log4j2.xml:/skywalking/config/log4j2.xml - environment: - SW_CLUSTER_ZK_HOST_PORT: zk:2181 - SW_STORAGE_ES_CLUSTER_NODES: es:9200 - SW_JDBC_URL: jdbc:mysql://mysql:3306/swtest - SW_STORAGE_INFLUXDB_URL: http://influxdb:8086 - SW_STORAGE_BANYANDB_HOST: banyandb - SW_STORAGE_IOTDB_HOST: iotdb - SW_STORAGE_IOTDB_SESSIONPOOL_SIZE: 2 - SW_CONFIG_ETCD_PERIOD: 1 - SW_CONFIG_ETCD_ENDPOINTS: http://etcd:2379 - SW_CLUSTER_ETCD_ENDPOINTS: http://etcd:2379 - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/11800"] - interval: 5s - timeout: 60s - retries: 120 - - ui: - image: "ghcr.io/apache/skywalking/ui:${SW_OAP_COMMIT}" - expose: - - 8080 - networks: - - e2e - environment: - - SW_OAP_ADDRESS=http://oap:12800 provider: - image: "ghcr.io/apache/skywalking/e2e-service-provider:${SW_AGENT_E2E_SERVICE_PROVIDER_COMMIT}" - volumes: - - sw_agent:/sw-java-agent + extends: + file: ../../docker/docker-compose/base-compose.yml + service: provider networks: - e2e - expose: - - 9090 - - 5005 - environment: - JAVA_TOOL_OPTIONS: -javaagent:/sw-java-agent/agent/skywalking-agent.jar - SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800 - SW_LOGGING_OUTPUT: CONSOLE - SW_AGENT_NAME: e2e-service-provider - SW_AGENT_INSTANCE_NAME: provider1 - SW_AGENT_COLLECTOR_GET_PROFILE_TASK_INTERVAL: 1 - SW_AGENT_COLLECTOR_GET_AGENT_DYNAMIC_CONFIG_INTERVAL: 1 - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9090"] - interval: 5s - timeout: 60s - retries: 120 consumer: - image: "ghcr.io/apache/skywalking/e2e-service-consumer:${SW_AGENT_E2E_SERVICE_PROVIDER_COMMIT}" - volumes: - - sw_agent:/sw-java-agent + extends: + file: ../../docker/docker-compose/base-compose.yml + service: consumer networks: - e2e - expose: - - 9092 - - 5005 - environment: - JAVA_TOOL_OPTIONS: -javaagent:/sw-java-agent/agent/skywalking-agent.jar - SW_AGENT_COLLECTOR_BACKEND_SERVICES: oap:11800 - SW_LOGGING_OUTPUT: CONSOLE - PROVIDER_URL: http://provider:9090 - SW_AGENT_NAME: e2e-service-consumer - SW_AGENT_INSTANCE_NAME: consumer1 - SW_AGENT_COLLECTOR_GET_PROFILE_TASK_INTERVAL: 1 - SW_AGENT_COLLECTOR_GET_AGENT_DYNAMIC_CONFIG_INTERVAL: 1 - healthcheck: - test: ["CMD", "bash", "-c", "cat < /dev/null > /dev/tcp/127.0.0.1/9092"] - interval: 5s - timeout: 60s - retries: 120 networks: e2e: - -volumes: - sw_agent: \ No newline at end of file diff --git a/.gitignore b/test/stress/Makefile similarity index 70% copy from .gitignore copy to test/stress/Makefile index 426298d..1a12f92 100644 --- a/.gitignore +++ b/test/stress/Makefile @@ -14,35 +14,18 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. +# -# Binaries for programs and plugins -*.exe -*.exe~ -*.dll -*.so -*.dylib -bin -include -/build -target - -# Test binary, build with `go test -c` -*.test - -# Output of the go coverage tool, specifically when used with LiteIDE -*.out +NAME := ui -# editor and IDE paraphernalia -.idea -*.swp -*.swo -*~ -.vscode +.PHONY: dev-up +dev-up: + DOCKER_BUILDKIT=1 docker compose --env-file ./env.dev up --build -.DS_Store -.env -.run +.PHONY: up +up: + DOCKER_BUILDKIT=1 docker compose --env-file ./env up --build -# mock files -*mock.go -*mock_test.go +.PHONY: down +down: + DOCKER_BUILDKIT=1 docker compose down diff --git a/test/stress/docker-compose.yaml b/test/stress/docker-compose.yaml new file mode 100644 index 0000000..ad92e1a --- /dev/null +++ b/test/stress/docker-compose.yaml @@ -0,0 +1,105 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +services: + banyandb: + extends: + file: ../docker/base-compose.yml + service: banyandb + build: + dockerfile: ./banyand/Dockerfile + context: ../.. + target: ${TARGET} + volumes: + - ../..:/app:rw,delegated + ports: + - 17913:17913 + networks: + - test + + oap: + extends: + file: ../docker/base-compose.yml + service: oap + environment: + SW_STORAGE: banyandb + ports: + - 12800 + volumes: + - ./log4j2.xml:/skywalking/config/log4j2.xml + networks: + - test + depends_on: + banyandb: + condition: service_healthy + + agent: + extends: + file: ../docker/base-compose.yml + service: agent + networks: + - test + + provider: + extends: + file: ../docker/base-compose.yml + service: provider + ports: + - 9090 + networks: + - test + depends_on: + oap: + condition: service_healthy + agent: + condition: service_completed_successfully + + consumer: + extends: + file: ../docker/base-compose.yml + service: consumer + ports: + - 9092 + networks: + - test + depends_on: + oap: + condition: service_healthy + provider: + condition: service_healthy + agent: + condition: service_completed_successfully + + traffic_loader: + extends: + file: ../docker/base-compose.yml + service: traffic_loader + command: run --duration 1h /scripts/consumer.js + volumes: + - ./scripts:/scripts + networks: + - test + depends_on: + oap: + condition: service_healthy + provider: + condition: service_healthy + consumer: + condition: service_healthy +networks: + test: + +volumes: + sw_agent: diff --git a/test/stress/env b/test/stress/env new file mode 100644 index 0000000..3571db7 --- /dev/null +++ b/test/stress/env @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SW_AGENT_JAVA_COMMIT=5bc1d1d1f1d9ce6a4f7fce20e8ecc330bccf47ec +SW_AGENT_E2E_SERVICE_PROVIDER_COMMIT=34a4553e23530e8255efe6f5a0adff9e69555d64 +SW_AGENT_SATELLITE_COMMIT=1987e1d566ac90f6b58a45fd9bfa27bf8faad635 +SW_AGENT_NGINX_LUA_COMMIT=c3cee4841798a147d83b96a10914d4ac0e11d0aa +SW_AGENT_NODEJS_COMMIT=2e7560518aff846befd4d6bc815fe5e38c704a11 +SW_AGENT_GO_COMMIT=4af380c2db6243106b0fc650b6003ce3b3eb82a0 +SW_AGENT_PYTHON_COMMIT=c76a6ec51a478ac91abb20ec8f22a99b8d4d6a58 +SW_AGENT_CLIENT_JS_COMMIT=af0565a67d382b683c1dbd94c379b7080db61449 +SW_AGENT_CLIENT_JS_TEST_COMMIT=4f1eb1dcdbde3ec4a38534bf01dded4ab5d2f016 +SW_KUBERNETES_COMMIT_SHA=0f3ec68e5a7e1608cec8688716b848ed15e971e5 +SW_ROVER_COMMIT=90c93c706743aac1f5853b677730edae8cc32a2c +SW_CTL_COMMIT=219876daf985fd474955834ef0b65013f0890e96 + +SW_OAP_COMMIT=dc39ce9bb44ed33d9c2bb0d5a054b1dfd5bbd657 + +TARGET=test diff --git a/test/stress/env.dev b/test/stress/env.dev new file mode 100644 index 0000000..496b269 --- /dev/null +++ b/test/stress/env.dev @@ -0,0 +1,31 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +SW_AGENT_JAVA_COMMIT=5bc1d1d1f1d9ce6a4f7fce20e8ecc330bccf47ec +SW_AGENT_E2E_SERVICE_PROVIDER_COMMIT=34a4553e23530e8255efe6f5a0adff9e69555d64 +SW_AGENT_SATELLITE_COMMIT=1987e1d566ac90f6b58a45fd9bfa27bf8faad635 +SW_AGENT_NGINX_LUA_COMMIT=c3cee4841798a147d83b96a10914d4ac0e11d0aa +SW_AGENT_NODEJS_COMMIT=2e7560518aff846befd4d6bc815fe5e38c704a11 +SW_AGENT_GO_COMMIT=4af380c2db6243106b0fc650b6003ce3b3eb82a0 +SW_AGENT_PYTHON_COMMIT=c76a6ec51a478ac91abb20ec8f22a99b8d4d6a58 +SW_AGENT_CLIENT_JS_COMMIT=af0565a67d382b683c1dbd94c379b7080db61449 +SW_AGENT_CLIENT_JS_TEST_COMMIT=4f1eb1dcdbde3ec4a38534bf01dded4ab5d2f016 +SW_KUBERNETES_COMMIT_SHA=0f3ec68e5a7e1608cec8688716b848ed15e971e5 +SW_ROVER_COMMIT=90c93c706743aac1f5853b677730edae8cc32a2c +SW_CTL_COMMIT=219876daf985fd474955834ef0b65013f0890e96 + +SW_OAP_COMMIT=dc39ce9bb44ed33d9c2bb0d5a054b1dfd5bbd657 + +TARGET=dev diff --git a/test/stress/log4j2.xml b/test/stress/log4j2.xml new file mode 100644 index 0000000..e3174f5 --- /dev/null +++ b/test/stress/log4j2.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ Licensed to the Apache Software Foundation (ASF) under one or more + ~ contributor license agreements. See the NOTICE file distributed with + ~ this work for additional information regarding copyright ownership. + ~ The ASF licenses this file to You under the Apache License, Version 2.0 + ~ (the "License"); you may not use this file except in compliance with + ~ the License. You may obtain a copy of the License at + ~ + ~ http://www.apache.org/licenses/LICENSE-2.0 + ~ + ~ Unless required by applicable law or agreed to in writing, software + ~ distributed under the License is distributed on an "AS IS" BASIS, + ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ~ See the License for the specific language governing permissions and + ~ limitations under the License. + ~ + --> + +<Configuration status="INFO"> + <Appenders> + <Console name="Console" target="SYSTEM_OUT"> + <PatternLayout charset="UTF-8" pattern="%d %c %L [%t] %-5p %x - %m%n"/> + </Console> + </Appenders> + <Loggers> + <logger name="org.apache.skywalking.oap.server.storage.plugin.banyandb" level="DEBUG"/> + <logger name="org.apache.skywalking.oap.server.core.storage.ttl" level="DEBUG"/> + <logger name="org.apache.skywalking.restapi" level="DEBUG"/> + <Root level="INFO"> + <AppenderRef ref="Console"/> + </Root> + </Loggers> +</Configuration> diff --git a/test/stress/scripts/consumer.js b/test/stress/scripts/consumer.js new file mode 100644 index 0000000..5a0fe30 --- /dev/null +++ b/test/stress/scripts/consumer.js @@ -0,0 +1,29 @@ +/* + * Licensed to Apache Software Foundation (ASF) under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Apache Software Foundation (ASF) licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import http from "k6/http"; +import { check, group } from "k6"; + +export default function () { + // POST request + let res = http.post("http://consumer:9092/info"); + check(res, { + "status is 200": (r) => r.status === 200, + }); +} \ No newline at end of file
