Skip to content

fix(elasticsearch): replace placeholder comments with selflog error h… #303

fix(elasticsearch): replace placeholder comments with selflog error h…

fix(elasticsearch): replace placeholder comments with selflog error h… #303

Workflow file for this run

name: CI
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
test:
name: Test
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-15]
go: ['1.21', '1.22', '1.23']
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go }}
cache: false
- name: Get dependencies
run: go mod download
- name: Test
run: go test -v ./...
- name: Test with race detector
run: go test -race -v ./...
- name: Test mtlog-analyzer
run: |
cd cmd/mtlog-analyzer
go test -v ./...
- name: Test mtlog-lsp
run: |
cd cmd/mtlog-lsp
go test -v ./...
- name: Test benchmarks module
run: |
cd benchmarks
go test -v ./...
- name: Test logr adapter module
run: |
cd adapters/logr
go test -v ./...
- name: Test OTEL adapter module
run: |
cd adapters/otel
go test -v ./...
go test -race -v ./...
- name: Test HTTP middleware adapter module
run: |
cd adapters/middleware
go test -v ./...
go test -race -v ./...
- name: Test Sentry adapter module
run: |
cd adapters/sentry
go test -v ./...
go test -race -v ./...
- name: Test coverage
run: go test -coverprofile=coverage.out ./...
if: matrix.os == 'ubuntu-latest' && matrix.go == '1.23'
- name: Upload coverage
uses: codecov/codecov-action@v4
with:
file: ./coverage.out
flags: unittests
name: codecov-umbrella
if: matrix.os == 'ubuntu-latest' && matrix.go == '1.23'
lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: latest
fuzz:
name: Fuzz Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Start OTEL Collector for OTEL adapter tests
run: |
# Start collector for OTEL adapter tests which include integration tests
docker run -d \
--name otel-collector \
--network host \
-v ${{ github.workspace }}/.github/otel-collector-config.yaml:/etc/otel-collector-config.yaml \
otel/opentelemetry-collector:latest \
--config=/etc/otel-collector-config.yaml
# Wait for collector to be ready
echo "Waiting for OTEL Collector..."
timeout=30
while [ $timeout -gt 0 ]; do
if curl -f http://localhost:13133/ 2>/dev/null; then
echo "OTEL Collector is ready"
break
fi
echo "Waiting for OTEL Collector... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "OTEL Collector failed to start in 30 seconds"
exit 1
fi
- name: Run fuzz tests
run: |
# Parser fuzz tests
go test -fuzz=FuzzParseMessageTemplate -fuzztime=30s ./internal/parser
go test -fuzz=FuzzExtractPropertyNames -fuzztime=30s ./internal/parser
# Output template fuzz tests
go test -fuzz=FuzzParseOutputTemplate -fuzztime=30s ./internal/formatters/output
go test -fuzz=FuzzTimeFormatting -fuzztime=30s ./internal/formatters/output
go test -fuzz=FuzzLevelFormatting -fuzztime=30s ./internal/formatters/output
# OTEL adapter fuzz tests (with collector available for chaos tests)
cd adapters/otel
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go test -fuzz=FuzzBridgeMessageTemplate -fuzztime=30s .
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go test -fuzz=FuzzHandlerProperties -fuzztime=30s .
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go test -fuzz=FuzzEnricherContext -fuzztime=30s .
OTEL_EXPORTER_OTLP_ENDPOINT=localhost:4317 go test -fuzz=FuzzOTLPSinkConfiguration -fuzztime=30s .
benchmark:
name: Benchmark
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Run benchmarks
run: |
cd benchmarks
go test -run=^$ -bench=. -benchmem -benchtime=10s . | tee ../benchmark.txt
- name: Upload benchmark results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: benchmark.txt
vscode-extension:
name: VS Code Extension
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-15]
node-version: [18.x, 20.x]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: vscode-extension/mtlog-analyzer/package-lock.json
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Build and Install mtlog-analyzer
run: |
cd cmd/mtlog-analyzer
go build -o $HOME/go/bin/mtlog-analyzer .
cd ../..
- name: Install dependencies
working-directory: vscode-extension/mtlog-analyzer
run: npm ci
- name: Compile TypeScript
working-directory: vscode-extension/mtlog-analyzer
run: npm run compile
- name: Package extension
working-directory: vscode-extension/mtlog-analyzer
run: |
npm install -g @vscode/vsce
vsce package --no-dependencies
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '20.x'
- name: Upload VSIX
uses: actions/upload-artifact@v4
with:
name: mtlog-analyzer-vsix
path: vscode-extension/mtlog-analyzer/*.vsix
if: matrix.os == 'ubuntu-latest' && matrix.node-version == '20.x'
goland-plugin:
name: GoLand Plugin
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Java
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'temurin'
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Build and Install mtlog-analyzer
run: |
cd cmd/mtlog-analyzer
go build -o $HOME/go/bin/mtlog-analyzer .
cd ../..
- name: Make gradlew executable
working-directory: goland-plugin
run: chmod +x ./gradlew
- name: Build Plugin
working-directory: goland-plugin
run: ./gradlew buildPlugin
- name: Run Tests
working-directory: goland-plugin
run: |
# Run tests with real mtlog-analyzer
export PATH=$HOME/go/bin:$PATH
# Use set -o pipefail to ensure grep doesn't hide test failures
set -o pipefail
./gradlew test --info 2>&1 | grep -v "WARN.*directory not found"
- name: Run Plugin Verifier
working-directory: goland-plugin
run: ./gradlew verifyPlugin -PverifierIdeVersions=GO-2024.2,GO-2025.1
- name: Upload Plugin
uses: actions/upload-artifact@v4
with:
name: mtlog-analyzer-goland-plugin
path: goland-plugin/build/distributions/*.zip
zed-extension:
name: Zed Extension
strategy:
matrix:
os: [ubuntu-latest, macos-15]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Rust
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.85.0
targets: wasm32-wasip2
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Build and Install mtlog-lsp
run: |
cd cmd/mtlog-lsp
go build -o $HOME/go/bin/mtlog-lsp .
echo "$HOME/go/bin" >> $GITHUB_PATH
cd ../..
- name: Build Zed Extension
working-directory: zed-extension/mtlog
run: |
cargo build --release --target wasm32-wasip2
# Verify WASM was created
test -f target/wasm32-wasip2/release/mtlog_analyzer.wasm
- name: Run Rust Tests
working-directory: zed-extension/mtlog
run: cargo test
- name: Upload WASM artifact
uses: actions/upload-artifact@v4
with:
name: zed-extension-wasm-${{ matrix.os }}
path: zed-extension/mtlog/target/wasm32-wasip2/release/mtlog_analyzer.wasm
if: matrix.os == 'ubuntu-latest'
neovim-plugin:
name: Neovim Plugin
strategy:
matrix:
os: [ubuntu-latest, macos-15]
neovim: ['v0.10.0', 'stable']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Build and Install mtlog-analyzer
run: |
cd cmd/mtlog-analyzer
go build -o $HOME/go/bin/mtlog-analyzer .
echo "$HOME/go/bin" >> $GITHUB_PATH
cd ../..
- name: Setup Neovim
uses: rhysd/action-setup-vim@v1
with:
neovim: true
version: ${{ matrix.neovim }}
- name: Install Plenary
run: |
git clone --depth 1 https://github.com/nvim-lua/plenary.nvim ~/.local/share/nvim/site/pack/vendor/start/plenary.nvim
- name: Run Tests
working-directory: neovim-plugin
run: |
nvim --headless -u tests/minimal_init.lua -c "PlenaryBustedDirectory tests/spec/ {minimal_init = 'tests/minimal_init.lua', sequential = true}"
- name: Validate Health Check
working-directory: neovim-plugin
run: |
# Run checkhealth - on macOS it outputs to buffer not stdout, so we write to file
nvim --headless -u tests/minimal_init.lua -c "enew" -c "checkhealth mtlog" -c "w! health.txt" -c "qa" 2>&1
# Check if analyzer is detected and no errors occurred
if grep -q "mtlog-analyzer is installed\|mtlog-analyzer version" health.txt && ! grep -q "Error\|E121" health.txt; then
echo "✅ Health check passed: mtlog-analyzer detected"
else
echo "❌ Health check failed - output:"
cat health.txt
exit 1
fi
integration:
name: Integration Tests
runs-on: ubuntu-latest
services:
# Note: OTEL Collector is set up separately due to config requirements
seq:
image: datalust/seq:latest
env:
ACCEPT_EULA: Y
SEQ_FIRSTRUN_NOAUTHENTICATION: true
ports:
- 5341:5341
- 8080:80
elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:8.11.1
env:
discovery.type: single-node
xpack.security.enabled: false
ports:
- 9200:9200
options: >-
--health-cmd "curl -f http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 5
splunk:
image: splunk/splunk:latest
env:
SPLUNK_GENERAL_TERMS: --accept-sgt-current-at-splunk-com
SPLUNK_START_ARGS: --accept-license --seed-passwd changeme123!
SPLUNK_PASSWORD: changeme123!
SPLUNK_HEC_TOKEN: abcd1234
SPLUNK_ENABLE_LISTEN: 9997
SPLUNK_ADD: tcp 1514
ports:
- 8088:8088
- 8089:8089
- 8000:8000
options: >-
--health-cmd "curl -k -f https://localhost:8088/services/collector/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
steps:
- uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.23'
cache: false
- name: Start OTEL Collector
run: |
# Use the external config file from the repository
docker run -d \
--name otel-collector \
--network host \
-v ${{ github.workspace }}/.github/otel-collector-config.yaml:/etc/otel-collector-config.yaml \
otel/opentelemetry-collector:latest \
--config=/etc/otel-collector-config.yaml
- name: Wait for services
run: |
echo "Waiting for OTEL Collector..."
timeout=30
while [ $timeout -gt 0 ]; do
if curl -f http://localhost:13133/ 2>/dev/null; then
echo "OTEL Collector is ready"
break
fi
echo "Waiting for OTEL Collector... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "OTEL Collector failed to start in 30 seconds"
exit 1
fi
echo "Waiting for Seq..."
timeout=30
while [ $timeout -gt 0 ]; do
if curl -f http://localhost:8080/ 2>/dev/null; then
echo "Seq is ready"
break
fi
echo "Waiting for Seq... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "Seq failed to start in 30 seconds"
exit 1
fi
echo "Waiting for Elasticsearch..."
timeout=30
while [ $timeout -gt 0 ]; do
if curl -f http://localhost:9200/_cluster/health 2>/dev/null; then
echo "Elasticsearch is ready"
break
fi
echo "Waiting for Elasticsearch... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "Elasticsearch failed to start in 30 seconds"
exit 1
fi
echo "Waiting for Splunk..."
timeout=60
while [ $timeout -gt 0 ]; do
if curl -k -f https://localhost:8088/services/collector/health 2>/dev/null; then
echo "Splunk is ready"
break
fi
echo "Waiting for Splunk... ($timeout seconds left)"
sleep 1
timeout=$((timeout-1))
done
if [ $timeout -eq 0 ]; then
echo "Splunk failed to start in 60 seconds"
exit 1
fi
- name: Run integration tests
run: |
# Run main integration tests
go test -tags=integration -v ./...
# Run OTEL adapter integration tests
cd adapters/otel
go test -tags=integration -v ./integration/...
env:
OTEL_EXPORTER_OTLP_ENDPOINT: localhost:4317
OTEL_EXPORTER_OTLP_HTTP_ENDPOINT: localhost:4318
SEQ_URL: http://localhost:5341
SEQ_QUERY_URL: http://localhost:8080
ELASTICSEARCH_URL: http://localhost:9200
SPLUNK_URL: https://localhost:8088
SPLUNK_QUERY_URL: https://localhost:8089
SPLUNK_TOKEN: abcd1234
SPLUNK_USERNAME: admin
SPLUNK_PASSWORD: changeme123!