Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update push gateway #966

Merged
merged 1 commit into from
Aug 28, 2020
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
6 changes: 6 additions & 0 deletions packages/caliper-core/lib/common/config/Config.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ const nconf = require('nconf');
nconf.formats.yaml = require('nconf-yaml');

const keys = {
Auth: {
PrometheusPush: {
UserName: 'caliper-auth-prometheuspush-username',
Password: 'caliper-auth-prometheuspush-password'
}
},
Bind: {
Sut: 'caliper-bind-sut',
Args: 'caliper-bind-args',
Expand Down
10 changes: 9 additions & 1 deletion packages/caliper-core/lib/common/config/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@
#

caliper:
# Settings related to the authorization
auth:
# Prometheus Push Gateway
prometheuspush:
# username
username:
# password
password:
# Settings related to the binding command
bind:
# The binding specification of the SUT in the <SUT type>:<SDK version> format
Expand Down Expand Up @@ -61,7 +69,7 @@ caliper:
# Configurations related to caliper test monitors
monitor:
# Default update interval
defaultinterval: 5000
defaultinterval: 10000
# Default scrape port for prometheus tx observer
prometheusscrapeport: 3000
# Configurations related to the logging mechanism
Expand Down
146 changes: 0 additions & 146 deletions packages/caliper-core/lib/common/prometheus/prometheus-push-client.js

This file was deleted.

29 changes: 25 additions & 4 deletions packages/caliper-core/lib/common/utils/caliper-utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,15 @@

'use strict';

const loggingUtil = require('./logging-util.js');
const Config = require('../config/config-util');

const {exec, spawn} = require('child_process');
const path = require('path');
require('winston-daily-rotate-file');
const fs = require('fs');
const path = require('path');
const yaml = require('js-yaml');
const loggingUtil = require('./logging-util.js');
const Config = require('../config/config-util');
const url = require('url');
require('winston-daily-rotate-file');

const BuiltinConnectors = new Map([
['burrow', '@hyperledger/caliper-burrow'],
Expand Down Expand Up @@ -588,6 +590,25 @@ class CaliperUtils {
return value / 1000;
}

/**
* Augment the passed URL with basic auth if the settings are present
* @param {string} urlPath the URL to augment
* @param {string} component the component being augmented
* @returns {string} the URL to be used, which may have been augmented with basic auth
*/
static augmentUrlWithBasicAuth(urlPath, component) {
const username = Config.get(Config.keys.Auth[component].UserName, undefined);
const password = Config.get(Config.keys.Auth[component].Password, undefined);
if (username && password) {
const myURL = new url.URL(urlPath);
myURL.username = username;
myURL.password = password;
return url.format(myURL);
} else {
return urlPath;
}
}

}

module.exports = CaliperUtils;
3 changes: 3 additions & 0 deletions packages/caliper-core/lib/common/utils/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,8 @@ module.exports = {
TxsSubmitted: 'txsSubmitted',
TxsFinished: 'txsFinished'
}
},
AuthComponents: {
PushGateway: 'PrometheusPush'
}
};
Loading