Skip to content

Commit

Permalink
refactor(polkadot connector): remove prometheus from testcases
Browse files Browse the repository at this point in the history
  • Loading branch information
AnmolBansalDEV committed Nov 11, 2023
1 parent e37583c commit 98aad54
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { PrometheusExporter } from "../../../main/typescript/prometheus-exporter/prometheus-exporter";
import {
IListenOptions,
LogLevelDesc,
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { PrometheusExporter } from "../../../main/typescript/prometheus-exporter/prometheus-exporter";
import {
IListenOptions,
LogLevelDesc,
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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 });
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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();
});

0 comments on commit 98aad54

Please sign in to comment.