Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/src/rust/receiver-mock/target/
/src/rust/sumologic-mock/target/
.github/
/src/go/stress-tester
/src/go/k8s-api-test
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ updates:
timezone: "Europe/Warsaw"

- package-ecosystem: "cargo"
directory: "src/rust/receiver-mock"
directory: "src/rust/sumologic-mock"
schedule:
interval: "daily"
time: "06:00"
Expand Down
11 changes: 11 additions & 0 deletions .github/workflows/dev_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,16 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_KUBECTL }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_KUBECTL }}
build-and-push-image-sumologic-mock:
uses: ./.github/workflows/build_and_push_image.yml
needs: extract-image-tag
with:
build_tag: ${{ needs.extract-image-tag.outputs.build_tag }}
sufffix: sumologic-mock
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_SUMOLOGIC_MOCK }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_SUMOLOGIC_MOCK }}
build-binaries:
uses: ./.github/workflows/build_binaries.yml
11 changes: 11 additions & 0 deletions .github/workflows/pre_release_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,14 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_KUBECTL }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_KUBECTL }}
build-and-push-image-sumologic-mock:
uses: ./.github/workflows/build_and_push_image.yml
needs: extract-image-tag
with:
build_tag: ${{ needs.extract-image-tag.outputs.build_tag }}
suffix: sumologic-mock
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_SUMOLOGIC_MOCK }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_SUMOLOGIC_MOCK }}
14 changes: 7 additions & 7 deletions .github/workflows/pull_requests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
- name: Check markdown files with markdownlint
run: make markdownlint

test-receiver-mock:
test-sumologic-mock:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v4
Expand All @@ -26,14 +26,14 @@ jobs:
toolchain: stable
- name: Install Protoc
uses: arduino/setup-protoc@v2
- name: Build receiver-mock
working-directory: src/rust/receiver-mock/
- name: Build Sumo Logic Mock
working-directory: src/rust/sumologic-mock/
run: cargo rustc -- -D warnings
- name: Check receiver-mock formatting
working-directory: src/rust/receiver-mock/
- name: Check sumologic-mock formatting
working-directory: src/rust/sumologic-mock/
run: make check-rustfmt
- name: Test receiver-mock
working-directory: src/rust/receiver-mock/
- name: Test sumologic-mock
working-directory: src/rust/sumologic-mock/
run: make test

build-image:
Expand Down
12 changes: 12 additions & 0 deletions .github/workflows/release_builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,18 @@ jobs:
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_KUBECTL }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_KUBECTL }}
build-and-push-image-sumologic-mock:
uses: ./.github/workflows/build_and_push_image.yml
needs: extract-image-tag
with:
build_tag: ${{ needs.extract-image-tag.outputs.build_tag }}
tag_latest: true
suffix: sumologic-mock
secrets:
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID_SUMOLOGIC_MOCK }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY_SUMOLOGIC_MOCK }}
build-binaries:
uses: ./.github/workflows/build_binaries.yml
create-release:
Expand Down
5 changes: 0 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ RUN apk update \
# Protoc is needed to build opentelemetry-proto Rust dependency.
&& apk add protoc

WORKDIR /receiver-mock
COPY ./src/rust/receiver-mock .
RUN cargo build --release

WORKDIR /logs-generator
COPY ./src/rust/logs-generator .
RUN cargo build --release
Expand Down Expand Up @@ -95,7 +91,6 @@ COPY --from=go-builder \
/usr/bin/

COPY --from=rust-builder \
/receiver-mock/target/release/receiver-mock \
/logs-generator/target/release/logs-generator \
/usr/bin/

Expand Down
22 changes: 22 additions & 0 deletions Dockerfile.sumologic-mock
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
FROM rust:1.68.2-alpine3.16 as rust-builder
RUN apk update \
&& apk upgrade \
&& apk add g++ git \
# Cmake and make are needed to build proto-build Rust dependency.
&& apk add cmake make \
# Protoc is needed to build opentelemetry-proto Rust dependency.
&& apk add protoc

WORKDIR /sumologic-mock
COPY ./src/rust/sumologic-mock .
RUN cargo build --release

FROM alpine:3.17.3
ARG TARGETARCH
ARG TARGETOS

COPY --from=rust-builder \
/sumologic-mock/target/release/sumologic-mock \
/usr/bin/

CMD ["/usr/bin/sumologic-mock"]
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,19 @@ build-image-tools:
build-image-kubectl:
TAG=$(BUILD_TAG) docker buildx bake kubectl

build-image-sumologic-mock:
TAG=$(BUILD_TAG) docker buildx bake sumologic-mock

build-image-multiplatform: build-image-multiplatform-tools build-image-multiplatform-kubectl

build-image-multiplatform-tools:
TAG=$(BUILD_TAG) docker buildx bake tools-multiplatform
TAG=$(BUILD_TAG) docker buildx bake tools-multiplatform

build-image-multiplatform-kubectl:
TAG=$(BUILD_TAG) docker buildx bake kubectl-multiplatform
TAG=$(BUILD_TAG) docker buildx bake kubectl-multiplatform

build-image-multiplatform-sumologic-mock:
TAG=$(BUILD_TAG) docker buildx bake sumologic-mock-multiplatform

tag-release-image-with-latest-tools:
make push-image-tools BUILD_TAG=latest
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,19 +156,19 @@ You can configure this tool by setting the following env variables:
2021/07/09 00:33:10 Expected number of spans for all traces: 40
```

### Receiver-mock
### Sumo Logic Mock

Small tool for mocking sumologic receiver to avoid sending data outside of cluster.
Small tool for mocking Sumo Logic receiver to avoid sending data outside of cluster.

```bash
$ kubectl run receiver-mock \
$ kubectl run sumologic-mock \
-it --rm \
--restart=Never \
--image sumologic/kubernetes-tools \
-- receiver-mock --help
-- sumologic-mock --help
```

[More information](src/rust/receiver-mock/README.md)
[More information](src/rust/sumologic-mock/README.md)

### Template dependency configuration

Expand Down
18 changes: 18 additions & 0 deletions docker-bake.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ variable "IMAGE" {
default = "kubernetes-tools"
}

variable "SUMOLOGIC_MOCK_IMAGE" {
default = "sumologic-mock"
}

variable "TAG" {
default = "dev-latest"
}
Expand Down Expand Up @@ -54,6 +58,20 @@ target "kubectl-multiplatform" {
inherits = ["kubectl", "multiplatform"]
}

target "sumologic-mock" {
dockerfile = "Dockerfile.sumologic-mock"
tags = ["${SUMOLOGIC_MOCK_IMAGE}:${TAG}"]
cache-from = [
"${CACHE_IMAGE}:${BUILD_RUST_CACHE_TAG}",
]
output = ["type=docker"]
platforms = ["linux/amd64"]
}

target "sumologic-mock-multiplatform" {
inherits = ["sumologic-mock", "multiplatform"]
}

group "cache" {
targets = ["rust-cache", "go-cache", "tools-cache"]
}
Expand Down
1 change: 0 additions & 1 deletion scripts/test-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ function test_image() {
local apps="
stress-tester
k8s-api-test
receiver-mock
check
fix-log-symlinks
tools-usage
Expand Down
7 changes: 0 additions & 7 deletions src/commands/tools-usage
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,6 @@ This image provides a set of tools for Kubernetes Collection. You can use follow
--env SPANS_PER_MIN=6000 \
-- stress-tester

* Receiver mock:

kubectl run receiver-mock \
-it --rm --restart=Never \
--image sumologic/kubernetes-tools \
-- receiver-mock --help

* Interactive mode:

kubectl run tools \
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "receiver-mock"
name = "sumologic-mock"
version = "0.1.0"
authors = ["Sumo Logic <[email protected]>"]
edition = "2021"
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Receiver-mock
# Sumo Logic Mock

receiver-mock is an small containerized application written in rust which can be used for local testing of the [`kubernetes sumologic collection`](https://github.com/SumoLogic/sumologic-kubernetes-collection)
Sumo Logic Mock is an small containerized application written in rust which can be used for local testing of the [`kubernetes sumologic collection`](https://github.com/SumoLogic/sumologic-kubernetes-collection)

## Running

Expand All @@ -10,7 +10,7 @@ cargo run

### Arguments

List of arguments taken by receiver-mock:
List of arguments taken by Sumo Logic Mock:

| Long form | Short form | Default value | Description |
|-----------------------------|-------------------|:-------------:|------------------------------------------------------------------------------------------------|
Expand All @@ -30,7 +30,7 @@ List of arguments taken by receiver-mock:

## Terraform mock

It expose the `/terraform.*` url which can be used to set HTTP source for k8s collection to receiver-mock itself
It expose the `/terraform.*` url which can be used to set HTTP source for k8s collection to Sumo Logic Mock itself

Example output:

Expand Down Expand Up @@ -188,15 +188,15 @@ The following endpoints provide information about received traces:

These are endpoints which provide information about received metrics:

- `metrics` - exposes receiver-mock metrics in prometheus format
- `metrics` - exposes Sumo Logic Mock metrics in prometheus format

```
# TYPE receiver_mock_metrics_count counter
receiver_mock_metrics_count 123
# TYPE receiver_mock_logs_count counter
receiver_mock_logs_count 123
# TYPE receiver_mock_logs_bytes_count counter
receiver_mock_logs_bytes_count 45678
# TYPE sumologic_mock_metrics_count counter
sumologic_mock_metrics_count 123
# TYPE sumologic_mock_logs_count counter
sumologic_mock_logs_count 123
# TYPE sumologic_mock_logs_bytes_count counter
sumologic_mock_logs_bytes_count 45678
```

- `/metrics-list` - returns list of counted unique metrics
Expand Down Expand Up @@ -286,7 +286,7 @@ The following endpoints provide information about received logs:

## Dump message

Receiver mock comes with special `/dump` endpoint, which is going to print message on stdout independently on the header value.
Sumo Logic Mock comes with special `/dump` endpoint, which is going to print message on stdout independently on the header value.

## Disclaimer

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ mod time;

#[derive(Parser)]
#[command(
name = "Receiver mock",
name = "Sumo Logic Mock",
author = "Sumo Logic <[email protected]>",
version = "0.0",
about = "Receiver mock can be used for testing performance or functionality of kubernetes collection without sending data to sumologic"
about = "Sumo Logic Mock can be used for testing performance or functionality of kubernetes collection without sending data to sumologic"
)]
struct Cli {
#[arg(short, long, default_value_t = 3000, help = "Port to listen on")]
Expand Down Expand Up @@ -150,7 +150,7 @@ async fn run_app(hostname: String, port: u16, opts: Options) -> std::io::Result<
fields: Mutex::new(HashMap::new()),
});

info!("Receiver mock is waiting for enemy on 0.0.0.0:{}!", port);
info!("Sumo Logic Mock is listening on 0.0.0.0:{}!", port);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've liked that part :(

Copy link
Contributor Author

@sumo-drosiek sumo-drosiek Jan 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It used to be Sumock is waiting for enemy before we agreed to use receiver-mock name

I just made it public and archive: https://github.com/sumo-drosiek/sumock

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let result = actix_web::HttpServer::new(move || {
actix_web::App::new()
// Middleware printing headers for all handlers.
Expand Down
Loading