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
48 changes: 48 additions & 0 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Integration Tests
on:
pull_request:
paths-ignore:
- "docs/**"
- "*.md"
permissions:
contents: read
jobs:
integration:
name: Integration Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.22
- name: Start Cortex
run: |
docker run -d --name cortex \
-p 9009:9009 \
-v ${{ github.workspace }}/integration/cortex-config.yaml:/etc/cortex/config.yaml \
cortexproject/cortex:v1.18.1 \
-config.file=/etc/cortex/config.yaml \
-target=all,alertmanager
- name: Wait for Cortex
run: |
for i in $(seq 1 30); do
if wget -qO- http://localhost:9009/ready > /dev/null 2>&1; then
echo "Cortex is ready"
exit 0
fi
echo "Waiting for Cortex... ($i)"
sleep 2
done
echo "Cortex failed to start"
docker logs cortex
exit 1
- name: Run Integration Tests
env:
CORTEX_ADDRESS: http://localhost:9009
run: go test -mod=vendor -tags=integration -v -count=1 ./integration/...
- name: Cortex Logs
if: failure()
run: docker logs cortex
- name: Cleanup
if: always()
run: docker stop cortex && docker rm cortex
Comment thread
github-advanced-security[bot] marked this conversation as resolved.
Fixed
43 changes: 43 additions & 0 deletions integration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Integration Tests

## Running

```bash
# Start Cortex
docker run -d --name cortex-test -p 9009:9009 \
-v $(pwd)/integration/cortex-config.yaml:/etc/cortex/config.yaml \
cortexproject/cortex:v1.18.1 \
-config.file=/etc/cortex/config.yaml \
-target=all,alertmanager

# Wait for ready
until curl -s http://localhost:9009/ready > /dev/null 2>&1; do sleep 2; done && echo "Ready"

# Run tests
go test -mod=vendor -tags=integration -v -count=1 ./integration/...

# Cleanup
docker stop cortex-test && docker rm cortex-test
```

## Coverage

These integration tests require a running Cortex instance. Offline commands (lint, check, prepare, parse) are covered by unit tests in `pkg/rules/`.

| Command | Tested? |
|---------|:---:|
| **rules load/list/print/get** | Yes |
| **rules delete (group)** | Yes |
| **rules delete-namespace** | Yes |
| **alertmanager load** | Yes |
| **alertmanager load (with templates)** | Yes |
| **alertmanager get** | Yes |
| **alertmanager delete** | Yes |
| **remote-read dump/stats** | Yes |
| **remote-read export** | Yes |
| **loadgen (write workload)** | Yes |
| **analyse** (grafana/ruler/dashboard/rule-file) | No |
| **bucket-validation** | No |
| **config** (use-context) | No |
| **alert verify** | No |
| **push-gateway** | No |
4 changes: 4 additions & 0 deletions integration/alertmanager-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
route:
receiver: default
receivers:
- name: default
67 changes: 67 additions & 0 deletions integration/cortex-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
auth_enabled: false

server:
http_listen_port: 9009
grpc_server_max_recv_msg_size: 104857600
grpc_server_max_send_msg_size: 104857600
grpc_server_max_concurrent_streams: 1000

distributor:
shard_by_all_labels: true
pool:
health_check_ingesters: true

ingester_client:
grpc_client_config:
max_recv_msg_size: 104857600
max_send_msg_size: 104857600
grpc_compression: gzip

ingester:
lifecycler:
min_ready_duration: 0s
final_sleep: 0s
num_tokens: 512
ring:
kvstore:
store: inmemory
replication_factor: 1

blocks_storage:
tsdb:
dir: /tmp/cortex/tsdb
bucket_store:
sync_dir: /tmp/cortex/tsdb-sync
backend: filesystem
filesystem:
dir: /tmp/cortex/data/tsdb

compactor:
data_dir: /tmp/cortex/compactor
sharding_ring:
kvstore:
store: inmemory

frontend_worker:
match_max_concurrent: true

ruler:
enable_api: true

ruler_storage:
backend: filesystem
filesystem:
dir: /tmp/cortex/rules

alertmanager:
enable_api: true
external_url: http://localhost:9009/alertmanager
sharding_ring:
kvstore:
store: inmemory
replication_factor: 1

alertmanager_storage:
backend: filesystem
filesystem:
dir: /tmp/cortex/alerts
Loading
Loading