Skip to content

Commit

Permalink
load testing using docker
Browse files Browse the repository at this point in the history
  • Loading branch information
jurabek committed Apr 6, 2024
1 parent 2b2410f commit c7a34e5
Show file tree
Hide file tree
Showing 9 changed files with 99 additions and 4 deletions.
11 changes: 10 additions & 1 deletion src/backend/docker/docker-compose.grafana.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,13 @@ services:
retries: 5
networks:
- loki
- default
- default

influxdb:
image: influxdb:1.8
networks:
- default
ports:
- "8086:8086"
environment:
- INFLUXDB_DB=k6
1 change: 1 addition & 0 deletions src/backend/docker/docker-compose.override.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ services:
- OTEL_EXPORTER_OTLP_ENDPOINT=http://otel-collector:4317
- OTEL_EXPORTER_OTLP_ENDPOINT_HTTP=http://otel-collector:4318/v1/metrics
- BASE_URL=/checkout
- LOG_LEVEL=debug

catalog-api:
environment:
Expand Down
2 changes: 0 additions & 2 deletions src/backend/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ services:

catalog-api:
image: catalog-api
container_name: catalog
build: ./services/catalog-api
depends_on:
- catalog-db
Expand All @@ -40,7 +39,6 @@ services:

order-api:
image: restaurant/order-api
container_name: order
build:
platforms:
- "linux/arm64"
Expand Down
3 changes: 3 additions & 0 deletions src/backend/load-tests/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@ FROM grafana/xk6
RUN xk6 build --with github.com/szkiba/xk6-faker@latest

# Copy checkout
COPY ./checkout.js ./

ENTRYPOINT [ "/bin/sh" ]
2 changes: 1 addition & 1 deletion src/backend/load-tests/checkout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const options = {
},
};

const baseUrl = "http://localhost:8080";
const baseUrl = "http://traefik:8080";
const cartUrl = baseUrl + "/shoppingcart";
const catalogUrl = baseUrl + "/catalog";
const checkoutUrl = baseUrl + "/checkout";
Expand Down
74 changes: 74 additions & 0 deletions src/backend/services/checkout-api/package-lock.json

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

2 changes: 2 additions & 0 deletions src/backend/services/checkout-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"mocha": "^10.2.0",
"nodemon": "^3.0.1",
"prettier": "^3.1.0",
"prisma": "^5.12.0",
"sinon": "^17.0.1",
"ts-node": "^10.9.1",
"typescript": "^5.0.2"
Expand All @@ -37,6 +38,7 @@
"kafkajs": "^2.2.4",
"opentelemetry-instrumentation-kafkajs": "^0.40.0",
"pino": "^8.11.0",
"pino-http": "^9.0.0",
"zod": "^3.22.4"
}
}
6 changes: 6 additions & 0 deletions src/backend/services/checkout-api/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,15 @@ import router from './routes/routes';
import { logger } from './utils/logger';
import { config } from './config/config';
import express from 'express';
import pinoHTTP from 'pino-http';

const app = express();
app.use(express.json());
app.use(
pinoHTTP({
logger,
})
);

app.use(config.baseUrl, router)

Expand Down
2 changes: 2 additions & 0 deletions src/backend/services/checkout-api/src/routes/routes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import express, { Request, Response } from "express";
import { UserCheckoutReq, UserCheckoutSchema } from "../models/model";
import Checkout from "../checkout/checkout";
import { logger } from "../utils/logger";

const router = express.Router();

Expand All @@ -15,6 +16,7 @@ router.post('/api/v1/checkout', async (req: Request, res: Response) => {
transaction_id: checkout.transaction_id,
});
} catch (error) {
logger.error(error);
res.status(500).send({ error_message: error })
}
});
Expand Down

0 comments on commit c7a34e5

Please sign in to comment.