-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
129 lines (106 loc) · 3.4 KB
/
Makefile
File metadata and controls
129 lines (106 loc) · 3.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
.PHONY: all build test clean docker-build docker-run lint test-unit test-integration test-coverage fmt
# Envs
BINARY_SERVER=bin/server
BINARY_CLIENT=bin/client
DOCKER_COMPOSE=docker-compose.yml
COVERAGE_FILE=coverage.out
COVERAGE_HTML=coverage.html
# Main commands
all: clean build test
build:
@echo "Building..."
@mkdir -p bin
go build -o $(BINARY_SERVER) ./cmd/server
go build -o $(BINARY_CLIENT) ./cmd/client
# Testing
test: test-unit test-integration test-coverage
test-unit:
@echo "Running unit tests..."
go test -v -race -count=1 ./pkg/...
test-integration:
@echo "Running integration tests..."
go test -v -race -count=1 ./integration/...
test-coverage:
@echo "Running tests with coverage..."
go test -v -race -coverprofile=$(COVERAGE_FILE) -covermode=atomic ./...
go tool cover -html=$(COVERAGE_FILE) -o $(COVERAGE_HTML)
@echo "Coverage report generated in $(COVERAGE_HTML)"
# Cleaning
clean:
@echo "Cleaning..."
rm -rf bin/
rm -f $(COVERAGE_FILE)
rm -f $(COVERAGE_HTML)
# Docker commands
docker-build:
@echo "Building Docker images..."
docker-compose build
docker-run:
@echo "Running Docker containers..."
docker-compose up
docker-stop:
@echo "Stopping Docker containers..."
docker-compose down
# Local run
run-server: build
@echo "Running server locally..."
./$(BINARY_SERVER)
run-client: build
@echo "Running client locally..."
./$(BINARY_CLIENT)
# Linters
lint:
@echo "Running linters..."
golangci-lint run ./...
fmt:
@echo "Formatting code..."
go fmt ./cmd/... ./pkg/... ./integration/...
# Benchmarks
bench:
@echo "Running benchmarks..."
go test -bench=. -benchmem ./...
# Race detector
race:
@echo "Running race detector..."
go test -race ./...
# DDoS testing tool
build-ddos:
@echo "Building DDoS testing tool..."
go build -o bin/ddos ./tools/ddos
run-ddos: build-ddos
@echo "Running DDoS simulation..."
./bin/ddos
run-ddos-heavy: build-ddos
@echo "Running heavy DDoS simulation..."
./bin/ddos -clients 1000 -duration 60s
## Protection testing tool
build-protection:
@echo "Running protection testing tool..."
go build -o bin/protection ./tools/protection/main.go
run-protection: build-protection
./bin/protection -attack invalid_pow -clients 50 -duration 10s
./bin/protection -attack connection_limit -clients 50 -duration 10s
./bin/protection -attack failed_attempts -clients 50 -duration 10s
./bin/protection -attack slowloris -clients 50 -duration 10s
# Help
help:
@echo "Available commands:"
@echo " make build - Build the project"
@echo " make test - Run all tests with coverage"
@echo " make test-unit - Run only unit tests"
@echo " make test-integration - Run only integration tests"
@echo " make test-coverage - Generate test coverage report"
@echo " make clean - Clean build artifacts"
@echo " make docker-build - Build Docker images"
@echo " make docker-run - Run Docker containers"
@echo " make docker-stop - Stop Docker containers"
@echo " make run-server - Run server locally"
@echo " make run-client - Run client locally"
@echo " make lint - Run linters"
@echo " make fmt - Format code"
@echo " make bench - Run benchmarks"
@echo " make race - Run race detector"
@echo " make build-ddos - Build DDoS testing tool"
@echo " make run-ddos - Run DDoS simulation"
@echo " make run-ddos-heavy - Run heavy DDoS simulation"
@echo " make run-protection - Run protection testing tool"