-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
102 changed files
with
1,582 additions
and
252 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,16 @@ | ||
BASE_SPACE=$(shell pwd) | ||
BUILD_SPACE=$(BASE_SPACE)/build | ||
|
||
IMPORT_PATH=github.com/aws/amazon-cloudwatch-agent-test | ||
ALL_SRC := $(shell find . -name '*.go' -type f | sort) | ||
TOOLS_BIN_DIR := $(abspath ./build/tools) | ||
|
||
GOIMPORTS = $(TOOLS_BIN_DIR)/goimports | ||
LINTER = $(TOOLS_BIN_DIR)/golangci-lint | ||
IMPI = $(TOOLS_BIN_DIR)/impi | ||
ADDLICENSE = $(TOOLS_BIN_DIR)/addlicense | ||
|
||
GOIMPORTS_OPT?= -w -local $(IMPORT_PATH) | ||
|
||
WIN_BUILD = GOOS=windows GOARCH=amd64 go build -trimpath -o $(BUILD_SPACE) | ||
LINUX_AMD64_BUILD = CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -trimpath -o $(BUILD_SPACE) | ||
|
@@ -22,14 +30,56 @@ LOADGEN_LINUX_ARM64_BUILD = $(LINUX_ARM64_BUILD)/linux/arm64 | |
LOADGEN_DARWIN_AMD64_BUILD = $(DARWIN_AMD64_BUILD)/darwin/amd64 | ||
LOADGEN_DARWIN_ARM64_BUILD = $(DARWIN_ARM64_BUILD)/darwin/arm64 | ||
|
||
install-tools: | ||
install-goimports: | ||
GOBIN=$(TOOLS_BIN_DIR) go install golang.org/x/tools/cmd/goimports | ||
|
||
install-impi: | ||
GOBIN=$(TOOLS_BIN_DIR) go install github.com/pavius/impi/cmd/[email protected] | ||
|
||
install-addlicense: | ||
# Using 04bfe4e to get SPDX template changes that are not present in the most recent tag v1.0.0 | ||
# This is required to be able to easily omit the year in our license header. | ||
GOBIN=$(TOOLS_BIN_DIR) go install github.com/google/addlicense@04bfe4e | ||
|
||
install-golang-lint: | ||
#Install from source for golangci-lint is not recommended based on https://golangci-lint.run/usage/install/#install-from-source so using binary | ||
#installation | ||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN_DIR) v1.50.1 | ||
|
||
lint: install-tools | ||
fmt: install-goimports addlicense | ||
go fmt ./... | ||
@echo $(ALL_SRC) | xargs -n 10 $(GOIMPORTS) $(GOIMPORTS_OPT) | ||
|
||
impi: install-impi | ||
@echo $(ALL_SRC) | xargs -n 10 $(IMPI) --local $(IMPORT_PATH) --scheme stdThirdPartyLocal | ||
@echo "Check import order/grouping finished" | ||
|
||
simple-lint: checklicense impi | ||
|
||
lint: install-golang-lint simple-lint | ||
${LINTER} run ./... | ||
|
||
addlicense: install-addlicense | ||
@ADDLICENSEOUT=`$(ADDLICENSE) -y="" -s=only -l="mit" -c="Amazon.com, Inc. or its affiliates. All Rights Reserved." $(ALL_SRC) 2>&1`; \ | ||
if [ "$$ADDLICENSEOUT" ]; then \ | ||
echo "$(ADDLICENSE) FAILED => add License errors:\n"; \ | ||
echo "$$ADDLICENSEOUT\n"; \ | ||
exit 1; \ | ||
else \ | ||
echo "Add License finished successfully"; \ | ||
fi | ||
|
||
checklicense: install-addlicense | ||
@ADDLICENSEOUT=`$(ADDLICENSE) -check $(ALL_SRC) 2>&1`; \ | ||
if [ "$$ADDLICENSEOUT" ]; then \ | ||
echo "$(ADDLICENSE) FAILED => add License errors:\n"; \ | ||
echo "$$ADDLICENSEOUT\n"; \ | ||
echo "Use 'make addlicense' to fix this."; \ | ||
exit 1; \ | ||
else \ | ||
echo "Check License finished successfully"; \ | ||
fi | ||
|
||
compile: | ||
# this is a workaround to compile and cache all of the tests without actually running any of them | ||
go test -run=NO_MATCH ./... | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM golang:1.19 AS build | ||
WORKDIR $GOPATH/main | ||
COPY . . | ||
RUN go env -w GOPROXY=direct | ||
RUN GO111MODULE=on go mod download | ||
RUN GO111MODULE=on CGO_ENABLED=0 GOOS=linux go build -o=/bin/main . | ||
EXPOSE 80 | ||
EXPOSE 443 | ||
FROM scratch | ||
ENV AWS_REGION="us-west-2" | ||
COPY --from=build /bin/main /bin/main | ||
COPY certificates certificates | ||
ENTRYPOINT ["/bin/main"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# Header above mocked_servers cert in bundle | ||
CERT_HEADER=mockserver | ||
|
||
CONFIG_PATH=openssl.conf | ||
CERT_PATH=certificates/ssl/certificate.crt | ||
KEY_PATH=certificates/private.key | ||
BUNDLE_PATH=certificates/ssl/ca-bundle.crt | ||
.PHONY: clean | ||
clean: | ||
rm -rf $(CERT_PATH) $(BUNDLE_PATH) $(KEY_PATH) | ||
touch $(CERT_PATH) $(BUNDLE_PATH) $(KEY_PATH) | ||
.PHONY: update-certs | ||
update-certs: clean gen-cert update-bundle | ||
|
||
# Expects mocked_servers cert to be the last cert in the bundle | ||
# Cuts until the first instance of "mocked_servers" in the bundle | ||
# and concatenates it with the current cert | ||
.PHONY: update-bundle | ||
update-bundle: | ||
sed /$(CERT_HEADER)/q $(BUNDLE_PATH) | cat - $(CERT_PATH) > $(BUNDLE_PATH).tmp && \ | ||
mv $(BUNDLE_PATH).tmp $(BUNDLE_PATH) | ||
|
||
# Generates the annual cert and private key using the config | ||
.PHONY: gen-cert | ||
gen-cert: | ||
openssl req -config $(CONFIG_PATH) -new -x509 -nodes -days 365 -out $(CERT_PATH) -keyout $(KEY_PATH) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# The Mock Server | ||
|
||
## Overview | ||
|
||
The Mock Server is a simple server designed for receiving metric and trace data, providing a simulated endpoint for testing purposes. It listens on two separate ports: 8080 and 443. | ||
## Running the server | ||
This server is runs as a docker container to run this server: | ||
1. First build the docker container with | ||
```sh | ||
sudo docker build -t mockserver . | ||
``` | ||
2. Run the container by mapping the ports you would like to use, for example: | ||
```sh | ||
sudo docker run --name mockserver -d -p 8080:8080 -p 443:443 mockserver | ||
``` | ||
|
||
## How it Works | ||
### The Receiver | ||
|
||
The receiver component of the Mock Server operates on port 443. It is responsible for receiving messages and incrementing the transaction count. To simulate real-world conditions, there is a built-in 15ms latency between each received message. The data received can be sent to three possible routes: | ||
|
||
- **Check Receiver Status:** You can check if the receiver is alive by making a request to `/ping`. | ||
|
||
- **Send Data:** Use the `/put-data` route to send data. This route supports two sub-routes: | ||
- `/put-data/trace/v1`: Use this sub-route for sending trace data. | ||
- `/put-data/metrics`: Use this sub-route for sending metrics data. | ||
|
||
> [!Important] | ||
> Currently, both traces and metrics are handled in the same way. | ||
### The Verifier | ||
|
||
The verifier component can be accessed via a listener on port 8080. It provides information about the transactions, including: | ||
|
||
- **Transactions per Minute:** You can obtain the transactions per minute by making a request to `/tpm`. | ||
|
||
- **Transaction Count:** To check the total transaction count, use the `/check-data` route. | ||
|
||
- **Verifier Status:** Determine if the verification server is alive by sending a request to `/ping`. | ||
|
||
|
Oops, something went wrong.