Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
efumagal committed Aug 9, 2023
1 parent 8690b59 commit 7af8f21
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
21 changes: 18 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,22 @@ Single trace:
go run main.go
```

## Load test
The webserv runs on port 8080.

### APIs

- **GET /health** Used for liveness/readiness probes
- **GET /hello** Returns a hello World HTML page
- **GET /distance** Calculates distance between two randomly generated 3D points
- **POST /action/cpu-load** Used to generate some CPU load for testing HPA

[Geo3D.postman_collection](postman_collection/Geo3D.postman_collection) can be imported in [Postman](https://www.postman.com) to try the endpoints implemented.

## Testing

The Go code should have unit tests, this was not done for time constraints but it is a crucial part in guranteeing the correctness of the application.

### Load test

Pre-requiste [K6](https://k6.io)

Expand All @@ -64,8 +79,8 @@ k6 run load_distance.js
- For a real app consider structuring the Go code using DDD/Hexagonal pattern
- Run Docker build and push only on related code changes
- Add unit tests and run them on PRs
- Generate OpenAPI specs
- In case of a real app use REST and generate OpenAPI specs

## Notes

- Before deploying on production thee will be probably be some functional/system tests
- Before deploying on production there will be probably be some functional/system automated tests
2 changes: 1 addition & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func main() {
// Create a child span
_, childSpan := tracer.Start(c.UserContext(), "cpu_computation")

for i := 0; i < 1_000; i++ {
for i := 0; i < 1_000_000; i++ {
start := geo.NewCoord3d(randFloat(-90, 90), randFloat(-180, 180), randFloat(0, 10000))
end := geo.NewCoord3d(randFloat(-90, 90), randFloat(-180, 180), randFloat(0, 10000))
geo.Distance3D(start, end)
Expand Down

0 comments on commit 7af8f21

Please sign in to comment.