Skip to content

Commit

Permalink
purge the alert checker test
Browse files Browse the repository at this point in the history
  • Loading branch information
just-mitch committed Nov 26, 2024
1 parent 62af9ca commit 2993624
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 36 deletions.
4 changes: 1 addition & 3 deletions yarn-project/end-to-end/scripts/e2e_test_with_alerts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,8 @@ docker run \
-e METRICS_PORT="4318" \
-e COLLECT_METRICS="true" \
-e PULL_REQUEST="$PULL_REQUEST" \
-e CHECK_ALERTS="true" \
$env_args \
--rm aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG \
"$test_path" "$@" || [ "$ignore_failures" = "true" ]


echo "Running alert checker..."
docker run -e ALERTS_FILE="alerts.yaml" --network host --rm aztecprotocol/end-to-end:$AZTEC_DOCKER_TAG quality_of_service/alert_checker.test.ts
20 changes: 20 additions & 0 deletions yarn-project/end-to-end/src/e2e_p2p/gossip_network.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,29 @@ import fs from 'fs';

import { shouldCollectMetrics } from '../fixtures/fixtures.js';
import { type NodeContext, createNodes } from '../fixtures/setup_p2p_test.js';
import { AlertChecker, type AlertConfig } from '../quality_of_service/alert_checker.js';
import { P2PNetworkTest, WAIT_FOR_TX_TIMEOUT } from './p2p_network.js';
import { createPXEServiceAndSubmitTransactions } from './shared.js';

const CHECK_ALERTS = process.env.CHECK_ALERTS === 'true';

// Don't set this to a higher value than 9 because each node will use a different L1 publisher account and anvil seeds
const NUM_NODES = 4;
const NUM_TXS_PER_NODE = 2;
const BOOT_NODE_UDP_PORT = 40600;

const DATA_DIR = './data/gossip';

const qosAlerts: AlertConfig[] = [
{
alert: 'SequencerTimeToCollectAttestations',
expr: 'aztec_sequencer_time_to_collect_attestations > 2500',
labels: { severity: 'error' },
for: '10m',
annotations: {},
},
];

describe('e2e_p2p_network', () => {
let t: P2PNetworkTest;
let nodes: AztecNodeService[];
Expand All @@ -39,6 +52,13 @@ describe('e2e_p2p_network', () => {
}
});

afterAll(async () => {
if (CHECK_ALERTS) {
const checker = new AlertChecker(t.logger);
await checker.runAlertCheck(qosAlerts);
}
});

it('should rollup txs from all peers', async () => {
// create the bootstrap node for the network
if (!t.bootstrapNodeEnr) {
Expand Down

This file was deleted.

19 changes: 14 additions & 5 deletions yarn-project/end-to-end/src/quality_of_service/alert_checker.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { type DebugLogger } from '@aztec/aztec.js';
import { fileURLToPath } from '@aztec/foundation/url';

import * as fs from 'fs';
import * as yaml from 'js-yaml';
import { dirname, join } from 'path';

export interface AlertConfig {
alert: string;
Expand All @@ -18,6 +16,7 @@ export interface AlertCheckerConfig {
grafanaCredentials: string;
}

// This config is good if you're running the otel-lgtm stack locally
const DEFAULT_CONFIG: AlertCheckerConfig = {
grafanaEndpoint: 'http://localhost:3000/api/datasources/proxy/uid/prometheus/api/v1/query',
grafanaCredentials: 'admin:admin',
Expand All @@ -32,10 +31,12 @@ export class AlertChecker {
this.logger = logger;
}

/**
* Load the alerts config from a file path.
* @param filePath - The absolute path to the alerts file.
*/
private loadAlertsConfig(filePath: string): AlertConfig[] {
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const fileContents = fs.readFileSync(join(__dirname, filePath), 'utf8');
const fileContents = fs.readFileSync(filePath, 'utf8');
const data = yaml.load(fileContents) as { alerts: AlertConfig[] };
return data.alerts;
}
Expand Down Expand Up @@ -79,6 +80,10 @@ export class AlertChecker {
}
}

/**
* Run the alert check based on the alerts defined in an array.
* @param alerts - The alerts to check.
*/
public async runAlertCheck(alerts: AlertConfig[]): Promise<void> {
try {
await this.checkAlerts(alerts);
Expand All @@ -89,6 +94,10 @@ export class AlertChecker {
}
}

/**
* Run the alert check based on the alerts defined in a yaml file.
* @param filePath - The absolute path to the alerts file.
*/
public async runAlertCheckFromFilePath(filePath: string): Promise<void> {
const alerts = this.loadAlertsConfig(filePath);
await this.checkAlerts(alerts);
Expand Down
10 changes: 0 additions & 10 deletions yarn-project/end-to-end/src/quality_of_service/alerts.yaml

This file was deleted.

0 comments on commit 2993624

Please sign in to comment.