-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
Support 1 Kibana and 1 Elasticsearch URL as input params #9760
Changes from 7 commits
c42e8b8
96f33d0
2427894
693f64b
ea9d912
9629bcc
8917742
7cdc0f7
333d909
5da1635
a1fa8f8
e03f5bf
456134e
97b4bbd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,17 @@ There are three ways to run the tests depending on your goals: | |
+ | ||
["source","shell"] | ||
---------- | ||
export TEST_KIBANA_URL=https://kibana:[email protected]:443 | ||
|
||
export TEST_ES_URL=https://elastic:[email protected]:9200 | ||
node scripts/functional_test_runner | ||
---------- | ||
|
||
|
||
** Or you can override any or all of these individual parts of the URL and leave the others to the default values. | ||
+ | ||
["source","shell"] | ||
---------- | ||
export TEST_KIBANA_PROTOCOL=https | ||
export TEST_KIBANA_HOSTNAME=my-kibana-instance.internal.net | ||
export TEST_KIBANA_PORT=443 | ||
|
@@ -405,4 +416,4 @@ const log = getService(‘log’); | |
|
||
// log.debug only writes when using the `--debug` or `--verbose` flag. | ||
log.debug(‘done clicking menu’); | ||
----------- | ||
----------- |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
import { format as formatUrl } from 'url'; | ||
import url, { format as formatUrl } from 'url'; | ||
import pkg from '../../../package.json'; | ||
import { admin } from '../../../test/shield'; | ||
|
||
|
@@ -20,13 +20,42 @@ export const esTestConfig = new class EsTestConfig { | |
} | ||
|
||
getUrlParts() { | ||
|
||
let testEsUrl; | ||
let testEsProtocol; | ||
let testEsHostname; | ||
let testEsPort; | ||
let testEsUsername; | ||
let testEsPassword; | ||
|
||
// Allow setting one complete TEST_ES_URL for Es like https://elastic:changeme@myCloudInstance:9200 | ||
if (process.env.TEST_ES_URL) { | ||
testEsUrl = url.parse(process.env.TEST_ES_URL); | ||
// have to remove the ":" off protocol | ||
testEsProtocol = testEsUrl.protocol.slice(0, -1); | ||
testEsHostname = testEsUrl.hostname; | ||
testEsPort = parseInt(testEsUrl.port, 10); | ||
testEsUsername = testEsUrl.username; | ||
testEsPassword = testEsUrl.password; | ||
} else { | ||
// Allow setting any individual component(s) of the URL, | ||
// or use default values (username and password from shield.js) | ||
testEsProtocol = process.env.TEST_ES_PROTOCOL || 'http'; | ||
testEsHostname = process.env.TEST_ES_HOSTNAME || 'localhost'; | ||
testEsPort = parseInt(process.env.TEST_ES_PORT, 10) || 9220; | ||
testEsUsername = process.env.TEST_ES_USERNAME || admin.username; | ||
testEsPassword = process.env.TEST_ES_PASSWORD || admin.password; | ||
} | ||
console.log(testEsProtocol); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove these |
||
|
||
|
||
return { | ||
protocol: process.env.TEST_ES_PROTOCOL || 'http', | ||
hostname: process.env.TEST_ES_HOSTNAME || 'localhost', | ||
port: parseInt(process.env.TEST_ES_PORT, 10) || 9220, | ||
auth: admin.username + ':' + admin.password, | ||
username: admin.username, | ||
password: admin.password, | ||
protocol: testEsProtocol, | ||
hostname: testEsHostname, | ||
port: testEsPort, | ||
auth: testEsUsername + ':' + testEsPassword, | ||
username: testEsUsername, | ||
password: testEsPassword, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there any risk in doing: getUrlParts() {
let protocol;
let hostname;
let port;
let auth;
let username;
let password;
if (process.env.TEST_ES_URL) {
// Allow setting one complete TEST_ES_URL for Es like
// https://elastic:changeme@myCloudInstance:9200
const testEsUrl = url.parse(process.env.TEST_ES_URL);
// have to remove the ":" off protocol
protocol = testEsUrl.protocol.slice(0, -1);
hostname = testEsUrl.hostname;
port = parseInt(testEsUrl.port, 10);
username = testEsUrl.username;
password = testEsUrl.password;
} else {
// Allow setting any individual component(s) of the URL,
// or use default values (username and password from shield.js)
protocol = process.env.TEST_ES_PROTOCOL || 'http';
hostname = process.env.TEST_ES_HOSTNAME || 'localhost';
port = parseInt(process.env.TEST_ES_PORT, 10) || 9220;
username = process.env.TEST_ES_USERNAME || admin.username;
password = process.env.TEST_ES_PASSWORD || admin.password;
}
console.log(protocol);
return {
protocol,
hostname,
port,
auth: `${username}:${password}`,
username,
password,
};
} (edited: removed too much first time) |
||
}; | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,38 @@ | ||
import { kibanaUser } from './shield'; | ||
import url from 'url'; | ||
|
||
let testKibanaUrl; | ||
let testKibanaProtocol; | ||
let testKibanaHostname; | ||
let testKibanaPort; | ||
let testKibanaUsername; | ||
let testKibanaPassword; | ||
|
||
// Allow setting one complete TEST_KIBANA_URL for Kibana like https://elastic:changeme@myCloudInstance:5601 | ||
if (process.env.TEST_KIBANA_URL) { | ||
testKibanaUrl = url.parse(process.env.TEST_KIBANA_URL); | ||
// have to remove the ":" off protocol | ||
testKibanaProtocol = testKibanaUrl.protocol.slice(0, -1); | ||
testKibanaHostname = testKibanaUrl.hostname; | ||
testKibanaPort = parseInt(testKibanaUrl.port, 10); | ||
testKibanaUsername = testKibanaUrl.username; | ||
testKibanaPassword = testKibanaUrl.password; | ||
} else { | ||
// Allow setting any individual component(s) of the URL, | ||
// or use default values (username and password from shield.js) | ||
testKibanaProtocol = process.env.TEST_KIBANA_PROTOCOL || 'http'; | ||
testKibanaHostname = process.env.TEST_KIBANA_HOSTNAME || 'localhost'; | ||
testKibanaPort = parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620; | ||
testKibanaUsername = process.env.TEST_KIBANA_USERNAME || kibanaUser.username; | ||
testKibanaPassword = process.env.TEST_KIBANA_PASSWORD || kibanaUser.password; | ||
} | ||
|
||
export const kibanaTestServerUrlParts = { | ||
protocol: process.env.TEST_KIBANA_PROTOCOL || 'http', | ||
hostname: process.env.TEST_KIBANA_HOSTNAME || 'localhost', | ||
port: parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620, | ||
auth: kibanaUser.username + ':' + kibanaUser.password, | ||
username: kibanaUser.username, | ||
password: kibanaUser.password, | ||
|
||
protocol: testKibanaProtocol, | ||
hostname: testKibanaHostname, | ||
port: testKibanaPort, | ||
username: testKibanaUsername, | ||
password: testKibanaPassword, | ||
auth: `${testKibanaUsername}:${testKibanaPassword}` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. import { kibanaUser } from './shield';
import url from 'url';
let protocol;
let hostname;
let port;
let username;
let password;
let auth;
// Allow setting one complete TEST_KIBANA_URL for Kibana like
// https://elastic:changeme@myCloudInstance:5601
if (process.env.TEST_KIBANA_URL) {
const testKibanaUrl = url.parse(process.env.TEST_KIBANA_URL);
// have to remove the ":" off protocol
protocol = testKibanaUrl.protocol.slice(0, -1);
hostname = testKibanaUrl.hostname;
port = parseInt(testKibanaUrl.port, 10);
username = testKibanaUrl.username;
password = testKibanaUrl.password;
} else {
// Allow setting any individual component(s) of the URL,
// or use default values (username and password from shield.js)
protocol = process.env.TEST_KIBANA_PROTOCOL || 'http';
hostname = process.env.TEST_KIBANA_HOSTNAME || 'localhost';
port = parseInt(process.env.TEST_KIBANA_PORT, 10) || 5620;
username = process.env.TEST_KIBANA_USERNAME || kibanaUser.username;
password = process.env.TEST_KIBANA_PASSWORD || kibanaUser.password;
}
export const kibanaTestServerUrlParts = {
protocol,
hostname,
port,
auth: `${username}:${password}`,
username,
password,
}; maybe make things more consistent with the ES file, too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the suggestion! I made that change and it is cleaner. |
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we just return an object here if TEST_ES_URL is defined? Then we can get rid of all the variables and last return.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That sounds pretty good. I'll try it that way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if I can do that for both the kibana and elasticsearch files;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For Kibana: