From 98aad54a997bc65da6747dee9fca66b27967ce4b Mon Sep 17 00:00:00 2001 From: Anmol Bansal Date: Sun, 29 Oct 2023 14:39:32 +0000 Subject: [PATCH] refactor(polkadot connector): remove prometheus from testcases --- .../integration/deploy-ink-contract.test.ts | 5 ---- .../integration/invoke-ink-contract.test.ts | 5 ---- .../integration/run-transaction.test.ts | 28 +++++++++++++++---- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/deploy-ink-contract.test.ts b/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/deploy-ink-contract.test.ts index 3bea18f82c2..59a0bf6f560 100644 --- a/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/deploy-ink-contract.test.ts +++ b/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/deploy-ink-contract.test.ts @@ -1,4 +1,3 @@ -import { PrometheusExporter } from "../../../main/typescript/prometheus-exporter/prometheus-exporter"; import { IListenOptions, LogLevelDesc, @@ -26,9 +25,6 @@ const testCase = "deploy contract through all available methods"; const logLevel: LogLevelDesc = "TRACE"; const DEFAULT_WSPROVIDER = "ws://127.0.0.1:9944"; const instanceId = "test-polkadot-connector"; -const prometheus: PrometheusExporter = new PrometheusExporter({ - pollingIntervalInMin: 1, -}); test("BEFORE " + testCase, async (t: Test) => { const pruning = pruneDockerAllIfGithubAction({ logLevel }); @@ -66,7 +62,6 @@ test(testCase, async (t: Test) => { }); const connectorOptions: IPluginLedgerConnectorPolkadotOptions = { logLevel: logLevel, - prometheusExporter: prometheus, pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), wsProviderUrl: DEFAULT_WSPROVIDER, instanceId: instanceId, diff --git a/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts b/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts index 18d64a31d45..f869967a772 100644 --- a/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts +++ b/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/invoke-ink-contract.test.ts @@ -1,4 +1,3 @@ -import { PrometheusExporter } from "../../../main/typescript/prometheus-exporter/prometheus-exporter"; import { IListenOptions, LogLevelDesc, @@ -26,9 +25,6 @@ const testCase = "invoke contract with all invocation types"; const logLevel: LogLevelDesc = "TRACE"; const DEFAULT_WSPROVIDER = "ws://127.0.0.1:9944"; const instanceId = "test-polkadot-connector"; -const prometheus: PrometheusExporter = new PrometheusExporter({ - pollingIntervalInMin: 1, -}); test("BEFORE " + testCase, async (t: Test) => { const pruning = pruneDockerAllIfGithubAction({ logLevel }); @@ -63,7 +59,6 @@ test(testCase, async (t: Test) => { }); const connectorOptions: IPluginLedgerConnectorPolkadotOptions = { logLevel: logLevel, - prometheusExporter: prometheus, pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), wsProviderUrl: DEFAULT_WSPROVIDER, instanceId: instanceId, diff --git a/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/run-transaction.test.ts b/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/run-transaction.test.ts index fc44f6027c5..a5da6ff2c06 100644 --- a/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/run-transaction.test.ts +++ b/packages/cactus-plugin-ledger-connector-polkadot/src/test/typescript/integration/run-transaction.test.ts @@ -1,4 +1,3 @@ -import { PrometheusExporter } from "../../../main/typescript/prometheus-exporter/prometheus-exporter"; import { AddressInfo } from "net"; import { v4 as uuidv4 } from "uuid"; import { Configuration } from "@hyperledger/cactus-core-api"; @@ -20,14 +19,12 @@ import { } from "../../../main/typescript/public-api"; import { PluginRegistry } from "@hyperledger/cactus-core"; import { PluginKeychainMemory } from "@hyperledger/cactus-plugin-keychain-memory"; +import { K_CACTUS_POLKADOT_TOTAL_TX_COUNT } from "../../../main/typescript/prometheus-exporter/metrics"; const testCase = "transact through all available methods "; const logLevel: LogLevelDesc = "TRACE"; const DEFAULT_WSPROVIDER = "ws://127.0.0.1:9944"; const instanceId = "test-polkadot-connector"; -const prometheus: PrometheusExporter = new PrometheusExporter({ - pollingIntervalInMin: 1, -}); test("BEFORE " + testCase, async (t: Test) => { const pruning = pruneDockerAllIfGithubAction({ logLevel }); @@ -62,7 +59,6 @@ test(testCase, async (t: Test) => { }); const connectorOptions: IPluginLedgerConnectorPolkadotOptions = { logLevel: logLevel, - prometheusExporter: prometheus, pluginRegistry: new PluginRegistry({ plugins: [keychainPlugin] }), wsProviderUrl: DEFAULT_WSPROVIDER, instanceId: instanceId, @@ -195,5 +191,27 @@ test(testCase, async (t: Test) => { t4.ok(transactionResponse.blockHash); t4.end(); }); + test("get prometheus exporter metrics", async (t5: Test) => { + const res = await apiClient.getPrometheusMetrics(); + const promMetricsOutput = + "# HELP " + + K_CACTUS_POLKADOT_TOTAL_TX_COUNT + + " Total transactions executed\n" + + "# TYPE " + + K_CACTUS_POLKADOT_TOTAL_TX_COUNT + + " gauge\n" + + K_CACTUS_POLKADOT_TOTAL_TX_COUNT + + '{type="' + + K_CACTUS_POLKADOT_TOTAL_TX_COUNT + + '"} 3'; + t5.ok(res, "Response truthy OK"); + t5.ok(res.data); + t5.equal(res.status, 200); + t5.true( + res.data.includes(promMetricsOutput), + "Total Transaction Count equals 3 OK.", + ); + t5.end(); + }); t.end(); });