@nsshunt/stsconfig 1.11.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
File without changes
@@ -0,0 +1,167 @@
1
+ #.env
2
+ # ==================================================================================================
3
+ # Development Settings
4
+ # ==================================================================================================
5
+ # Database username
6
+ DB_USER=postgres
7
+ # Database password
8
+ #DB_PASSWORD=somepassword
9
+ # Database password file. To create, use 'echo -n [password] > /home/marcusbettens/projects/dbpassword'
10
+ # This will set the database password to the contents of the dbpassword file without the trailing /cr character.
11
+ DB_PASSWORD_FILE=/home/marcusbettens/projects/dbpassword
12
+ # Database host
13
+ DB_HOST=localhost
14
+ # Database port
15
+ DB_PORT=5432
16
+ # Database name
17
+ DB_DATABASE=testdb17
18
+ # Maximum pool size for database connections (per thread)
19
+ POOL_SIZE=200
20
+ # Database Script Folder
21
+ DB_SCRIPT_FOLDER=/var/lib/sts/stsglobalresources/db-scripts
22
+ # sudo mkdir /var/run/sts
23
+ # sudo chown marcusbettens /var/run/sts
24
+ #PORT=/var/run/sts/stsrest01.sock
25
+
26
+ PUBLISH_DEBUG=false
27
+ PUBLISH_TIMEOUT=750
28
+ PUBLISH_INTERVAL=1000
29
+
30
+ # STSRest01 service host and connection details
31
+ REST01_ENDPOINT=http://localhost
32
+ REST01_HOST_PORT=3003
33
+ REST01_PORT=3003
34
+ REST01_APIROOT=/stsrest01/v1
35
+ REST01_EMAIL=K6TestUser@sts
36
+ #REST01_PASSWORD=somepassword
37
+ REST01_PASSWORD_FILE=/home/marcusbettens/projects/rest01passwordfile
38
+ REST01_SERVICE_NAME=STSRest01
39
+ REST01_SERVICE_VERSION=1.0.0
40
+ REST01_PROM_SUPPORT=true
41
+ REST01_PROM_CLUSTER_PORT=3013
42
+
43
+ # STSInstrumentManager service host and connection details
44
+ IM_ENDPOINT=http://localhost
45
+ IM_HOST_PORT=3001
46
+ IM_PORT=3001
47
+ IM_APIROOT=/stsinstrumentmanager/v1
48
+ IM_EMAIL=K6TestUser@sts
49
+ #IM_PASSWORD=K6TestUserPassword
50
+ IM_PASSWORD_FILE=/home/marcusbettens/projects/impasswordfile
51
+ IM_SERVICE_NAME=STSInstrumentManager
52
+ IM_SERVICE_VERSION=1.0.0
53
+ IM_PROM_SUPPORT=true
54
+ IM_PROM_CLUSTER_PORT=3011
55
+
56
+ # STSAuth service host and connection details
57
+ AS_ENDPOINT=http://localhost
58
+ AS_HOST_PORT=3002
59
+ AS_PORT=3002
60
+ AS_APIROOT=/stsauth/v1
61
+ AS_EMAIL=K6TestUser@sts
62
+ #AS_PASSWORD=K6TestUserPassword
63
+ AS_PASSWORD_FILE=/home/marcusbettens/projects/aspasswordfile
64
+ AS_SERVICE_NAME=STSAuth
65
+ AS_SERVICE_VERSION=1.0.0
66
+ AS_PROM_SUPPORT=true
67
+ AS_PROM_CLUSTER_PORT=3012
68
+
69
+ # STS Test Orchestrator service host and connection details
70
+ TO_ENDPOINT=http://localhost
71
+ TO_HOST_PORT=3004
72
+ TO_PORT=3004
73
+ TO_APIROOT=/ststestorchestrator/v1
74
+ TO_EMAIL=K6TestUser@sts
75
+ #TO_PASSWORD=somepassword
76
+ TO_PASSWORD_FILE=/home/marcusbettens/projects/topasswordfile
77
+ TO_SERVICE_NAME=STSTestOrchestrator
78
+ TO_SERVICE_VERSION=1.0.0
79
+ TO_PROM_SUPPORT=true
80
+ TO_PROM_CLUSTER_PORT=3014
81
+
82
+ # STS Test Runner service host and connection details
83
+ TR_EMAIL=K6TestUser@sts
84
+ #TR_PASSWORD=somepassword
85
+ TR_PASSWORD_FILE=/home/marcusbettens/projects/trpasswordfile
86
+ TR_SERVICE_NAME=STSRestRunner
87
+ TR_SERVICE_VERSION=1.0.0
88
+ TR_PROM_SUPPORT=true
89
+ TR_PROM_CLUSTER_PORT=3015
90
+
91
+ # Auth Server public and private key paths
92
+ AS_PRIVATE_KEY_PATH=/var/lib/sts/stsglobalresources/keys/private.key
93
+ AS_PUBLIC_KEY_PATH=/var/lib/sts/stsglobalresources/keys/public.key
94
+
95
+ # Node runtime environment
96
+ NODE_ENV=debug
97
+ # Default K6 test script path
98
+ K6SCRIPTPATH=.
99
+ # Redis server end point
100
+ REDIS_SERVER=localhost
101
+ # Redis server port
102
+ REDIS_PORT=6379
103
+ # Use redis for Microservice
104
+ USE_REDIS=false
105
+ # Use redis as a layer 1 cache
106
+ USE_L1_REDIS=false
107
+ # Automatically flush the redis cache when terminating the Microservice
108
+ REDIS_END_FLUSH=false
109
+ # Log error messages to the console within the microservice
110
+ CONSOLE_LOG_ERRORS=false
111
+ # Maximum number of CPUs (incl. logical processors) to use within the Microservice.
112
+ # Use -1 to use all available within the runtime container. Each CPU will spawn a node work thread.
113
+ MAX_CPU=2
114
+ # Automatically re-spawn a worker thread if one dies.
115
+ RESPAWN=false
116
+ # Default number of entries to create for a fresh database
117
+ DEFAULT_DB_ENTRIES=10000
118
+ # Default flag to automatically copy from the source RESFK_ records to the working set RESCP_ records
119
+ # during initial fresh database creation.
120
+ DEFAULT_DB_POPULATE=true
121
+ # Default flag to automatically populate the redis cache (if enabled) with the current RESCP_ records
122
+ # as they are being created. Only valid when DEFAULT_DB_POPULATE = true AND USE_REDIS = true.
123
+ DEFAULT_REDIS_POPULATE=true
124
+ # Default number of entries K6 should test against.
125
+ DEFAULT_K6_ENTRIES=10000
126
+ # Default microservice end-point for K6 tests.
127
+ DEFAULT_K6_MS_HOST=localhost
128
+ # Default microservice port for K6 tests.
129
+ DEFAULT_K6_MS_PORT=3000
130
+ # Default ratio (%) that each test should be an update rather than just a read.
131
+ DEFAULT_K6_UPDATE_RATIO=2
132
+ # Default ratio (%) that for an update, this update will actually be a delete. Only valid when
133
+ # DEFAULT_K6_UPDATE_RATIO is > 0
134
+ DEFAULT_K6_DELETE_RATIO=0
135
+ # Default flag to always create a new record for each interation during K6 test runs. The new
136
+ # record will contain a UUID for the ID to ensure uniqueness.
137
+ DEFAULT_K6_ALWAYS_ADD=false
138
+ # Default number of virtual CPUs to use on each testing node.
139
+ DEFAULT_K6_VCPU=20
140
+ # Default duration each test node should run the K6 test.
141
+ DEFAULT_K6_DURATION=30s
142
+ # ==================================================================================================
143
+ # Production Settings
144
+ # ==================================================================================================
145
+ #PORT=3000
146
+ #NODE_ENV=production
147
+ #DATABASE_URL=postgresql://postgres:02740274@192.168.0.160:5432/testdb
148
+ #REDIS_SERVER=192.168.0.160
149
+ #REDIS_PORT=6379
150
+ #USE_REDIS=true
151
+ #REDIS_END_FLUSH=false
152
+ #CONSOLE_LOG_ERRORS=false
153
+ #
154
+ # Only use for self signed certificates, otherwise remove from .env file
155
+ #NODE_TLS_REJECT_UNAUTHORIZED=0
156
+ #
157
+ # To run PROD from command line
158
+ # PORT=3000 NODE_ENV=production DATABASE_URL='postgresql://postgres:02740274@192.168.0.27:5432/testdb' node app
159
+ #
160
+ # To run DEV from command line
161
+ # PORT=3000 NODE_ENV=debug DB_USER=postgres DB_PASSWORD=02740274 DB_HOST=192.168.0.27 DB_PORT=5432 DB_DATABASE=testdb node app
162
+
163
+ MONITOR = false
164
+ TRANSPORT = RESTAPI
165
+
166
+ #MONITOR = true
167
+ #TRANSPORT = RESTAPI
package/package.json CHANGED
@@ -1,13 +1,12 @@
1
1
  {
2
2
  "name": "@nsshunt/stsconfig",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "",
5
5
  "main": "stsconfig.js",
6
6
  "dependencies": {
7
7
  "colors": "^1.4.0",
8
8
  "debug": "^4.3.3",
9
- "dotenv": "^16.0.0",
10
- "yaml": "^1.10.2"
9
+ "dotenv": "^16.0.0"
11
10
  },
12
11
  "standard": {
13
12
  "parser": "@babel/eslint-parser"
package/stsconfig.js CHANGED
@@ -1,4 +1,3 @@
1
- const YAML = require('yaml');
2
1
  const { accessSync, constants, readFileSync } = require('fs');
3
2
  const debug = require('debug')(`proc:${process.pid}`);
4
3
  require('colors');
@@ -10,45 +9,33 @@ require('colors');
10
9
  // Fall back to use a password from an environment variable
11
10
 
12
11
  // Add tthe STSENVFILE to script run commands in order to use the require .env file for configuration
13
- let envfile = (process.env.STSENVFILE === undefined ? '../stsglobalresources/.env' : process.env.STSENVFILE);
14
- let yamlfile = (process.env.STSYAMLFILE === undefined ? '../stsglobalresources/config.yml' : process.env.STSYAMLFILE);
12
+ let envfile = (process.env.STSENVFILE === undefined ? '/.env' : process.env.STSENVFILE);
15
13
 
16
14
  require('dotenv').config({ path: envfile });
17
15
 
18
- let deffileconfig = { };
19
- try {
20
- accessSync(yamlfile, constants.R_OK);
21
- const file = readFileSync(yamlfile, 'utf8');
22
- deffileconfig = YAML.parse(file);
23
- } catch (err) {
24
- debug(`Problem loading YAML file: [${yamlfile}], Error: [${err}]`.yellow);
25
- }
26
-
27
16
  const defconfig =
28
17
  {
29
18
  // Node runtime environment
30
- isProduction: (process.env.NODE_ENV === 'production')
19
+ isProduction: (process.env.NODE_ENV === undefined ? false : process.env.NODE_ENV === 'production')
31
20
  // Log error messages to the console within the microservice
32
21
  ,consoleLogErrors: (process.env.CONSOLE_LOG_ERRORS === undefined ? false : (process.env.CONSOLE_LOG_ERRORS === "true" ? true : false ))
33
22
  // Database username.
34
23
  ,dbuser: (process.env.DB_USER === undefined ? 'postgres' : process.env.DB_USER)
35
24
  // Database password.
36
25
  ,dbpassword: (process.env.DB_PASSWORD === undefined ? 'password' : process.env.DB_PASSWORD)
37
- // Database password file.
26
+ // Database password file
38
27
  ,dbpasswordfile: process.env.DB_PASSWORD_FILE
39
- // Database host.
28
+ // Database host
40
29
  ,dbhost: (process.env.DB_HOST === undefined ? 'localhost' : process.env.DB_HOST)
41
- // Database port.
30
+ // Database port
42
31
  ,dbport: (process.env.DB_PORT === undefined ? '5432' : process.env.DB_PORT)
43
32
  // Database name.
44
33
  ,database: (process.env.DB_DATABASE === undefined ? 'stsrestmsdb01' : process.env.DB_DATABASE) // STS REST MicroService Database 01
45
- // Database connection string to be used in production mode.
34
+ // Database connection string to be used in production mode
46
35
  ,databaseUrl: process.env.DATABASE_URL
47
36
  // Database script(s) folder
48
37
  ,databasescriptfolder: (process.env.DB_SCRIPT_FOLDER === undefined ? "/var/lib/sts/stsglobalresources/db-scripts" : process.env.DB_SCRIPT_FOLDER)
49
38
 
50
- // Use the on-screen UI for the server. Set to false for head-less mode (i.e. inside cluster etc.)
51
- ,useui: (process.env.USEUI === undefined ? true : (process.env.USEUI === "true" ? true : false ))
52
39
  // The maximum pool size for pg. There will be one pool per thread.
53
40
  ,poolSize: (process.env.POOL_SIZE === undefined ? 500 : parseInt(process.env.POOL_SIZE))
54
41
  // Maximum number of CPUs (incl. logical processors) to use within the Microservice.
@@ -57,7 +44,7 @@ const defconfig =
57
44
  // Automatically re-spawn a worker thread if one dies.
58
45
  ,respawnOnFail: (process.env.RESPAWN === undefined ? false : (process.env.RESPAWN === "true" ? true : false ))
59
46
  // Default number of entries to create for a fresh database.
60
- ,defaultDatabaseEntries: process.env.DEFAULT_DB_ENTRIES
47
+ ,defaultDatabaseEntries: (process.env.DEFAULT_DB_ENTRIES === undefined ? 10000 : process.env.DEFAULT_DB_ENTRIES)
61
48
  // Microservice listen port.
62
49
  ,useRedis: (process.env.USE_REDIS === undefined ? false : (process.env.USE_REDIS === "true" ? true : false ))
63
50
  // Use redis for Microservice.
@@ -65,104 +52,40 @@ const defconfig =
65
52
  // Automatically flush the redis cache when terminating the Microservice.
66
53
  ,endFlush: (process.env.REDIS_END_FLUSH === undefined ? false : (process.env.REDIS_END_FLUSH === "true" ? true : false ))
67
54
  // Redis server port.
68
- ,redisPort: process.env.REDIS_PORT
55
+ ,redisPort: (process.env.REDIS_PORT === undefined ? '6379' : process.env.REDIS_PORT)
69
56
  // Redis server endpoint.
70
- ,redisServer: process.env.REDIS_SERVER
57
+ ,redisServer: (process.env.REDIS_SERVER === undefined ? 'localhost' : process.env.REDIS_SERVER)
71
58
  // Default K6 test script path
72
59
  ,k6ScriptPath: (process.env.K6SCRIPTPATH === undefined ? "." : process.env.K6SCRIPTPATH)
73
- // Default flag to automatically copy from the source RESFK_ records to the working set RESCP_ records
74
- // during initial fresh database creation.
75
- ,defaultDatabasePopulate: (process.env.DEFAULT_DB_POPULATE === undefined ? true : (process.env.DEFAULT_DB_POPULATE === "true" ? true : false ))
76
- // Default flag to automatically populate the redis cache (if enabled) with the current RESCP_ records
77
- // as they are being created. Only valid when DEFAULT_DB_POPULATE = true AND USE_REDIS = true.
78
- ,defaultRedisPopulate: (process.env.DEFAULT_REDIS_POPULATE === undefined ? true : (process.env.DEFAULT_REDIS_POPULATE === "true" ? true : false))
79
- // Default number of entries K6 should test against.
80
- ,defaultK6Entries: (process.env.DEFAULT_K6_ENTRIES === undefined ? 100000 : parseInt(process.env.DEFAULT_K6_ENTRIES))
81
- // Default microservice end-point for K6 tests.
82
- ,defaultK6MicroServiceHost: (process.env.DEFAULT_K6_MS_HOST === undefined ? 'localhost' : process.env.DEFAULT_K6_MS_HOST)
83
- // Default microservice port for K6 tests.
84
- ,defaultK6MicroServicePort: (process.env.DEFAULT_K6_MS_PORT === undefined ? 3000 : parseInt(process.env.DEFAULT_K6_MS_PORT))
85
- // Default ratio (%) that each test should be an update rather than just a read.
86
- ,defaultK6MicroServiceUpdateRatio: (process.env.DEFAULT_K6_UPDATE_RATIO === undefined ? 2 : parseInt(process.env.DEFAULT_K6_UPDATE_RATIO))
87
- // Default ratio (%) that for an update, this update will actually be a delete. Only valid when
88
- // DEFAULT_K6_UPDATE_RATIO is > 0
89
- ,defaultK6MicroServiceDeleteRatio: (process.env.DEFAULT_K6_DELETE_RATIO === undefined ? 0 : parseInt(process.env.DEFAULT_K6_DELETE_RATIO))
90
- // Default flag to always create a new record for each interation during K6 test runs. The new
91
- // record will contain a UUID for the ID to ensure uniqueness.
92
- ,defaultK6MicroServiceAlwaysAdd: (process.env.DEFAULT_K6_ALWAYS_ADD === undefined ? false : (process.env.DEFAULT_K6_ALWAYS_ADD === "true" ? true : false))
93
- // Default number of virtual CPUs to use on each testing node.
94
- ,defaultK6MicroServiceVCPUs: (process.env.DEFAULT_K6_VCPU === undefined ? 20 : parseInt(process.env.DEFAULT_K6_VCPU))
95
- // Default duration each test node should run the K6 test.
96
- ,defaultK6MicroServiceDuration: (process.env.DEFAULT_K6_DURATION === undefined ? "30s" : process.env.DEFAULT_K6_DURATION)
97
- // Default token refresh modulas.
98
- ,defaulttokenrefreshmod: (process.env.DEFAULT_K6_TOKEN_REFRESH_MOD === undefined ? 5000 : parseInt(process.env.DEFAULT_K6_TOKEN_REFRESH_MOD))
99
- // Default sleep duration (ms) between iterations - random number between 0 and this number.
100
- ,defaultitersleep: (process.env.DEFAULT_K6_ITER_SLEEP === undefined ? 0 : parseInt(process.env.DEFAULT_K6_ITER_SLEEP))
101
60
  // Default number of entries to create for a fresh database.
102
61
  ,defaultDatabaseMinExtraDataSize: (process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE === undefined ? 0 : parseInt(process.env.DEFAULT_DATABASE_MIN_EXTRA_DATA_SIZE))
103
62
  // Default number of entries to create for a fresh database.
104
63
  ,defaultDatabaseMaxExtraDataSize: (process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE === undefined ? 2000 : parseInt(process.env.DEFAULT_DATABASE_MAX_EXTRA_DATA_SIZE))
105
64
 
106
- /* To be developed in future ...
107
- // Config Server (CS) endpoint
108
- ,csendpoint: (process.env.CS_ENDPOINT === undefined ? "http://localhost" : process.env.CS_ENDPOINT)
109
- // Config Server (CS) port
110
- ,csport: (process.env.CS_PORT === undefined ? "3000" : process.env.CS_PORT)
111
- // Config Server (CS) endpoint
112
- ,csapiroot: (process.env.CS_APIROOT === undefined ? "/api/v1/k6testing" : process.env.CS_APIROOT)
113
- // Config Server (CS) username email
114
- ,csemail: (process.env.CS_EMAIL === undefined ? "K6TestUser@sts" : process.env.CS_EMAIL)
115
- // Config Server (CS) username password
116
- ,cspassword: (process.env.CS_PASSWORD === undefined ? "K6TestUserPassword" : process.env.CS_PASSWORD)
117
- */
118
-
119
65
  // STSREST01 Server endpoint
120
- ,rest01endpoint: (process.env.REST01_ENDPOINT === undefined ?
121
- (process.env.ENDPOINT === undefined ? "http://localhost" : process.env.ENDPOINT)
122
- : process.env.REST01_ENDPOINT)
66
+ ,rest01endpoint: (process.env.REST01_ENDPOINT === undefined ? "http://localhost" : process.env.REST01_ENDPOINT)
123
67
  // STSREST01 Server port (listen port for the service)
124
- ,rest01hostport: (process.env.REST01_HOST_PORT === undefined ?
125
- (process.env.HOST_PORT === undefined ? "3000" : process.env.HOST_PORT)
126
- : process.env.REST01_HOST_PORT)
68
+ ,rest01hostport: (process.env.REST01_HOST_PORT === undefined ? "3003" : process.env.REST01_HOST_PORT)
127
69
  // STSREST01 Server port (client port to access the service)
128
- ,rest01port: (process.env.REST01_PORT === undefined ?
129
- (process.env.PORT === undefined ? "3000" : process.env.PORT)
130
- : process.env.REST01_PORT)
70
+ ,rest01port: (process.env.REST01_PORT === undefined ? "3003" : process.env.REST01_PORT)
131
71
  // STSREST01 Server endpoint
132
- ,rest01apiroot: (process.env.REST01_APIROOT === undefined ?
133
- (process.env.APIROOT === undefined ? "/stsrest01/v1/im" : process.env.APIROOT)
134
- : process.env.REST01_APIROOT)
72
+ ,rest01apiroot: (process.env.REST01_APIROOT === undefined ? "/stsrest01/v1" : process.env.REST01_APIROOT)
135
73
  // STSREST01 Prometheus metric support
136
- ,rest01prometheussupport: (process.env.REST01_PROM_SUPPORT === undefined ?
137
- (process.env.PROM_SUPPORT === undefined ? true : (process.env.PROM_SUPPORT === "true" ? true : false))
138
- : (process.env.REST01_PROM_SUPPORT === "true" ? true : false))
74
+ ,rest01prometheussupport: (process.env.REST01_PROM_SUPPORT === undefined ? true : (process.env.REST01_PROM_SUPPORT === "true" ? true : false))
139
75
  // STSREST01 Cluster Server port (port used for cluster prometheus scrapes). Service will listen on this port at mount point /metrics
140
- ,rest01prometheusclusterport: (process.env.REST01_PROM_CLUSTER_PORT === undefined ?
141
- (process.env.PROM_CLUSTER_PORT === undefined ? "3010" : process.env.PROM_CLUSTER_PORT)
142
- : process.env.REST01_PROM_CLUSTER_PORT)
76
+ ,rest01prometheusclusterport: (process.env.REST01_PROM_CLUSTER_PORT === undefined ? "3013" : process.env.REST01_PROM_CLUSTER_PORT)
143
77
  // STSREST01 Service Name
144
- ,rest01servicename: (process.env.REST01_SERVICE_NAME === undefined ?
145
- (process.env.SERVICE_NAME === undefined ? "STSRest01" : process.env.SERVICE_NAME)
146
- : process.env.REST01_SERVICE_NAME)
78
+ ,rest01servicename: (process.env.REST01_SERVICE_NAME === undefined ? "STSRest01" : process.env.REST01_SERVICE_NAME)
147
79
  // STSREST01 Service Version
148
- ,rest01serviceversion: (process.env.REST01_SERVICE_VERSION === undefined ?
149
- (process.env.SERVICE_VERSION === undefined ? "1.0.0" : process.env.SERVICE_VERSION)
150
- : process.env.REST01_SERVICE_VERSION)
80
+ ,rest01serviceversion: (process.env.REST01_SERVICE_VERSION === undefined ? "1.0.0" : process.env.REST01_SERVICE_VERSION)
151
81
  // STSREST01 Service Credentials
152
82
  // -----------------------------
153
83
  // STSREST01 Server username email
154
- ,rest01email: (process.env.REST01_EMAIL === undefined ?
155
- (process.env.EMAIL === undefined ? "K6TestUser@sts" : process.env.EMAIL)
156
- : process.env.REST01_EMAIL)
84
+ ,rest01email: (process.env.REST01_EMAIL === undefined ? "K6TestUser@sts" : process.env.REST01_EMAIL)
157
85
  // STSREST01 Server username password
158
- ,rest01password: (process.env.REST01_PASSWORD === undefined ?
159
- (process.env.PASSWORD === undefined ? "K6TestUserPassword" : process.env.PASSWORD)
160
- : process.env.REST01_PASSWORD)
86
+ ,rest01password: (process.env.REST01_PASSWORD === undefined ? "K6TestUserPassword" : process.env.REST01_PASSWORD)
161
87
  // STSREST01 Server username password file
162
- ,rest01passwordfile: (process.env.REST01_PASSWORD_FILE === undefined ?
163
- ( process.env.PASSWORD_FILE === undefined ? "rest01passwordfile" : process.env.PASSWORD_FILE)
164
- : process.env.REST01_PASSWORD_FILE)
165
-
88
+ ,rest01passwordfile: process.env.REST01_PASSWORD_FILE
166
89
 
167
90
  // STS Instrument Manager Service endpoint
168
91
  ,imendpoint: (process.env.IM_ENDPOINT === undefined ? "http://localhost" : process.env.IM_ENDPOINT)
@@ -175,7 +98,7 @@ const defconfig =
175
98
  // STS Instrument Manager Prometheus metric support
176
99
  ,imprometheussupport: (process.env.IM_PROM_SUPPORT === undefined ? true : (process.env.IM_PROM_SUPPORT === "true" ? true : false ))
177
100
  // STS Instrument Manager Cluster Server port (port used for cluster prometheus scrapes)
178
- ,imprometheusclusterport: (process.env.IM_PROM_CLUSTER_PORT === undefined ? "3010" : process.env.IM_PROM_CLUSTER_PORT)
101
+ ,imprometheusclusterport: (process.env.IM_PROM_CLUSTER_PORT === undefined ? "3011" : process.env.IM_PROM_CLUSTER_PORT)
179
102
  // STS Instrument Manager Service Name
180
103
  ,imservicename: (process.env.IM_SERVICE_NAME === undefined ? "STSInstrumentManager" : process.env.IM_SERVICE_NAME)
181
104
  // STS Instrument Manager Service Version
@@ -186,6 +109,8 @@ const defconfig =
186
109
  ,imemail: (process.env.IM_EMAIL === undefined ? "K6TestUser@sts" : process.env.IM_EMAIL)
187
110
  // STS Instrument Manager Service username password
188
111
  ,impassword: (process.env.IM_PASSWORD === undefined ? "K6TestUserPassword" : process.env.IM_PASSWORD)
112
+ // STS Instrument Manager Service username password file
113
+ ,impasswordfile: process.env.IM_PASSWORD_FILE
189
114
 
190
115
  // STS Test Orchestrator Service endpoint
191
116
  ,toendpoint: (process.env.TO_ENDPOINT === undefined ? "http://localhost" : process.env.TO_ENDPOINT)
@@ -198,7 +123,7 @@ const defconfig =
198
123
  // STS Test Orchestrator Prometheus metric support
199
124
  ,toprometheussupport: (process.env.TO_PROM_SUPPORT === undefined ? true : (process.env.TO_PROM_SUPPORT === "true" ? true : false ))
200
125
  // STS Test Orchestrator Cluster Server port (port used for cluster prometheus scrapes)
201
- ,toprometheusclusterport: (process.env.TO_PROM_CLUSTER_PORT === undefined ? "3010" : process.env.TO_PROM_CLUSTER_PORT)
126
+ ,toprometheusclusterport: (process.env.TO_PROM_CLUSTER_PORT === undefined ? "3014" : process.env.TO_PROM_CLUSTER_PORT)
202
127
  // STS Test Orchestrator Service Name
203
128
  ,toservicename: (process.env.TO_SERVICE_NAME === undefined ? "STSTestOrchestrator" : process.env.TO_SERVICE_NAME)
204
129
  // STS Test Orchestrator Service Version
@@ -209,6 +134,8 @@ const defconfig =
209
134
  ,toemail: (process.env.TO_EMAIL === undefined ? "K6TestUser@sts" : process.env.TO_EMAIL)
210
135
  // STS Test Orchestrator Service username password
211
136
  ,topassword: (process.env.TO_PASSWORD === undefined ? "K6TestUserPassword" : process.env.TO_PASSWORD)
137
+ // STS Test Orchestrator Service username password file
138
+ ,topasswordfile: process.env.TO_PASSWORD_FILE
212
139
 
213
140
  // Auth Server endpoint
214
141
  ,asendpoint: (process.env.AS_ENDPOINT === undefined ? "http://localhost" : process.env.AS_ENDPOINT)
@@ -232,11 +159,17 @@ const defconfig =
232
159
  ,asemail: (process.env.AS_EMAIL === undefined ? "K6TestUser@sts" : process.env.AS_EMAIL)
233
160
  // Auth Server username password
234
161
  ,aspassword: (process.env.AS_PASSWORD === undefined ? "K6TestUserPassword" : process.env.AS_PASSWORD)
162
+ // Auth Server username password file
163
+ ,aspasswordfile: process.env.AS_PASSWORD_FILE
164
+ // Auth Server - Private Key (when using JWT)
165
+ ,asprivatekeypath: (process.env.AS_PRIVATE_KEY_PATH === undefined ? "/var/lib/sts/stsglobalresources/keys/private.key" : process.env.AS_PRIVATE_KEY_PATH)
166
+ // Auth Server - Public Key (when using JWT)
167
+ ,aspublickeypath: (process.env.AS_PUBLIC_KEY_PATH === undefined ? "/var/lib/sts/stsglobalresources/keys/public.key" : process.env.AS_PUBLIC_KEY_PATH)
235
168
 
236
169
  // STS Test Runner Prometheus metric support
237
170
  ,trprometheussupport: (process.env.TR_PROM_SUPPORT === undefined ? true : (process.env.TR_PROM_SUPPORT === "true" ? true : false ))
238
171
  // STS Test Runner Cluster Server port (port used for cluster prometheus scrapes)
239
- ,trprometheusclusterport: (process.env.TR_PROM_CLUSTER_PORT === undefined ? "3010" : process.env.TR_PROM_CLUSTER_PORT)
172
+ ,trprometheusclusterport: (process.env.TR_PROM_CLUSTER_PORT === undefined ? "3015" : process.env.TR_PROM_CLUSTER_PORT)
240
173
  // STS Test Runner Service Name
241
174
  ,trservicename: (process.env.TR_SERVICE_NAME === undefined ? "STSRestRunner" : process.env.TR_SERVICE_NAME)
242
175
  // STS Test Runner Service Version
@@ -247,14 +180,8 @@ const defconfig =
247
180
  ,tremail: (process.env.TR_EMAIL === undefined ? "K6TestUser@sts" : process.env.TR_EMAIL)
248
181
  // STS Test Runner password
249
182
  ,trpassword: (process.env.TR_PASSWORD === undefined ? "K6TestUserPassword" : process.env.TR_PASSWORD)
250
-
251
- // Auth Server - Private Key
252
- ,asprivatekeypath: (process.env.AS_PRIVATE_KEY_PATH === undefined ? "/var/lib/sts/stsglobalresources/keys/private.key" : process.env.AS_PRIVATE_KEY_PATH)
253
- // Auth Server - Public Key
254
- ,aspublickeypath: (process.env.AS_PUBLIC_KEY_PATH === undefined ? "/var/lib/sts/stsglobalresources/keys/public.key" : process.env.AS_PUBLIC_KEY_PATH)
255
-
256
- // Special flags
257
- ,monitor: (process.env.MONITOR === undefined ? false : (process.env.MONITOR === "true" ? true : false ))
183
+ // STS Test Runner password file
184
+ ,trpasswordfile: process.env.TR_PASSWORD_FILE
258
185
 
259
186
  // Duration (in ms) between each publish event.
260
187
  ,publishinterval: (process.env.PUBLISH_INTERVAL === undefined ? 1000 : parseInt(process.env.PUBLISH_INTERVAL))
@@ -269,6 +196,7 @@ const defconfig =
269
196
  // Transport(s) to use for sending instrumentation data to the instrumentation server
270
197
  ,transport: (process.env.TRANSPORT === undefined ? 0 : process.env.TRANSPORT)
271
198
 
199
+ /*
272
200
  // Instrument Defaults
273
201
  // Logger lines (sliding window size)
274
202
  ,instrumentLoggerSize: (process.env.INSTRUMENT_LOGGER_SIZE === undefined ? 200 : parseInt(process.env.INSTRUMENT_LOGGER_SIZE))
@@ -281,6 +209,7 @@ const defconfig =
281
209
 
282
210
  // Sample size (number of readings to use for P(x) calculations. Time approx. (Sample Interval / 1000) * Sample Size, i.e. Caluclate P(x) on the observed data for the last 6 minutes.
283
211
  ,instrumentSampleSize: (process.env.INSTRUMENT_SAMPLE_SIZE === undefined ? 600 : parseInt(process.env.INSTRUMENT_SAMPLE_SIZE))
212
+ */
284
213
 
285
214
  // Use secure cookies option when passing back cookies from STS services (such as STSAuth service).
286
215
  // This setting will be ignore for production mode. In production mode services will always use secure cookies.
@@ -311,23 +240,98 @@ const defconfig =
311
240
  ,timeout: (process.env.TIMEOUT === undefined ? 10000 : parseInt(process.env.TIMEOUT))
312
241
  // Reference: https://nodejs.org/api/http.html#class-httpagent
313
242
  // timeout <number> Socket timeout in milliseconds. This will set the timeout when the socket is created.
243
+
244
+ // Maximum payload size allowed for express server calls
245
+ ,maxPayloadSize: (process.env.MAX_PAYLOAD_SIZE === undefined ? '50mb' : process.env.MAX_PAYLOAD_SIZE)
246
+
247
+ // Instrumentation Config Settings
248
+ // -------------------------------
249
+ // Generic interval (ms) to make on observation for instrumentation objects.
250
+ ,instrumentationObservationInterval: (process.env.INSTRUMENTATION_OBSERVATION_INTERVAL === undefined ? 1000 : parseInt(process.env.INSTRUMENTATION_OBSERVATION_INTERVAL))
251
+
252
+ // Generic sliding time window (seconds) for instrumentation objects that process telemetry over time (e.g. P(x) instruments).
253
+ ,instrumentationTimeWindow: (process.env.INSTRUMENTATION_TIME_WINDOW === undefined ? 600 : parseInt(process.env.INSTRUMENTATION_TIME_WINDOW))
254
+
255
+ // Service Specific Config Settings
256
+ // --------------------------------
257
+ // STSAuth
258
+ // -------
259
+ // Define the valid age for a JWT access token (in ms). Default 10 minutes.
260
+ ,authJWTAccessTokenTimeout: (process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT === undefined ? 600 : parseInt(process.env.AUTH_JWT_ACCESS_TOKEN_TIMEOUT))
261
+
262
+ // Define the valid age for a JWT refresh token (in ms). Default 24 hours.
263
+ ,authJWTRefreshTokenTimeout: (process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT === undefined ? (3600 * 24) : parseInt(process.env.AUTH_JWT_REFRESH_TOKEN_TIMEOUT))
264
+
265
+ // Define the valid age for an authentication/session cookie. Default 24 hours.
266
+ ,authCookieTimeout: (process.env.AUTH_COOKIE_TIMEOUT === undefined ? (3600 * 24) : parseInt(process.env.AUTH_COOKIE_TIMEOUT))
267
+
268
+ // STSAppFramework (library)
269
+ // -------------------------
270
+ // Define the time (ms) to wait prior to exiting the application (using process.exit(0))
271
+ ,masterProcessExitTime: (process.env.MASTER_PROCESS_EXIT_TIME === undefined ? 500 : parseInt(process.env.MASTER_PROCESS_EXIT_TIME))
272
+
273
+ // Define the time (ms) to wait prior to exiting the application (using process.exit(0))
274
+ ,childProcessExitTime: (process.env.CHILD_PROCESS_EXIT_TIME === undefined ? 500 : parseInt(process.env.CHILD_PROCESS_EXIT_TIME))
275
+
276
+ // Define the interval (ms) to collect system information for instrumentation purposes
277
+ ,systemInformationInterval: (process.env.SYSTEM_INFORMATION_INTERVAL === undefined ? 1000 : parseInt(process.env.SYSTEM_INFORMATION_INTERVAL))
278
+
279
+ // Ignore socket.io REST api calls and/or WebSocket calls when collecting telemetry for instrumentation purposes.
280
+ ,ignoresocketio: (process.env.IGNORE_SOCKETIO === undefined ? true : (process.env.IGNORE_SOCKETIO === "true" ? true : false ))
281
+
282
+ /*
283
+ // STSModels (library)
284
+ // -------------------
285
+ // Define the interval for checking instrumentation updates on a instrumentation model. Entries in the model will be removed after this timeout value (ms) if no
286
+ // activity has been detected. Default 5 seconds.
287
+ ,modelPurgeUpdateTimeout: (process.env.MODEL_PURGE_UPDATE_TIMEOUT === undefined ? 5000 : parseInt(process.env.MODEL_PURGE_UPDATE_TIMEOUT))
288
+ */
314
289
  }
315
290
 
316
- if (defconfig.dbpasswordfile !== undefined)
317
- {
291
+ const ReadPasswordFile = (passwordFile) => {
318
292
  try {
319
- accessSync(defconfig.dbpasswordfile, constants.R_OK);
320
- const data = readFileSync(defconfig.dbpasswordfile, 'utf8');
321
- defconfig.dbpassword = data;
322
- debug(`Successfully loaded database password file: [${defconfig.dbpasswordfile}]`.green);
293
+ accessSync(passwordFile, constants.R_OK);
294
+ const data = readFileSync(passwordFile, 'utf8');
295
+ debug(`Successfully loaded password file: [${passwordFile}]`.green);
296
+ return data;
323
297
  } catch (err) {
324
- debug(`Problem loading database password file: [${defconfig.dbpasswordfile}], Error: [${err}]`.red);
298
+ debug(`Problem loading password file: [${passwordFile}], Error: [${err}]`.red);
299
+ return "";
325
300
  }
326
301
  }
327
302
 
303
+ // Database password file
304
+ if (defconfig.dbpasswordfile !== undefined) {
305
+ defconfig.dbpassword = ReadPasswordFile(defconfig.dbpasswordfile);
306
+ }
307
+
308
+ // Auth Server username password file
309
+ if (defconfig.aspasswordfile !== undefined) {
310
+ defconfig.aspassword = ReadPasswordFile(defconfig.aspasswordfile);
311
+ }
312
+
313
+ // STSREST01 Server username password file
314
+ if (defconfig.rest01passwordfile !== undefined) {
315
+ defconfig.rest01password = ReadPasswordFile(defconfig.rest01passwordfile);
316
+ }
317
+
318
+ // STS Test Runner password file
319
+ if (defconfig.trpasswordfile !== undefined) {
320
+ defconfig.trpassword = ReadPasswordFile(defconfig.trpasswordfile);
321
+ }
322
+
323
+ // STS Test Orchestrator Service username password file
324
+ if (defconfig.topasswordfile !== undefined) {
325
+ defconfig.topassword = ReadPasswordFile(defconfig.topasswordfile);
326
+ }
327
+
328
+ // STS Instrument Manager Service username password file
329
+ if (defconfig.impasswordfile !== undefined) {
330
+ defconfig.impassword = ReadPasswordFile(defconfig.impasswordfile);
331
+ }
332
+
328
333
  // Preference order is YAML file then .env file
329
334
  const $options = {
330
- ...deffileconfig,
331
335
  ...defconfig
332
336
  // Computed connection string to be used in development mode.
333
337
  ,connectionString: `postgresql://${defconfig.dbuser}:${defconfig.dbpassword}@${defconfig.dbhost}:${defconfig.dbport}/${defconfig.database}`
package/stsconfig.test.js CHANGED
@@ -11,10 +11,75 @@ describe("Test", () =>
11
11
 
12
12
  });
13
13
 
14
- test('Testing Module', async () =>
14
+ test('Checking default config items', async () =>
15
15
  {
16
- expect.assertions(1);
17
- expect(1).toEqual(1);
16
+ expect.assertions(21);
17
+
18
+ process.env.STSENVFILE = './.env-test-file-1'; // Empty environment file
19
+ let goptions = require('./stsconfig.js').$options;
20
+
21
+ expect(goptions.isProduction).toEqual(false);
22
+ expect(goptions.consoleLogErrors).toEqual(false);
23
+ expect(goptions.dbuser).toEqual('postgres');
24
+ expect(goptions.dbpassword).toEqual('password');
25
+ expect(goptions.dbpasswordfile).toEqual(undefined);
26
+ expect(goptions.dbhost).toEqual('localhost');
27
+ expect(goptions.dbport).toEqual('5432');
28
+ expect(goptions.database).toEqual('stsrestmsdb01');
29
+ expect(goptions.databaseUrl).toEqual(undefined);
30
+ expect(goptions.databasescriptfolder).toEqual('/var/lib/sts/stsglobalresources/db-scripts');
31
+
32
+ expect(goptions.poolSize).toEqual(500);
33
+ expect(goptions.useCPUs).toEqual(-1);
34
+ expect(goptions.respawnOnFail).toEqual(false);
35
+ expect(goptions.defaultDatabaseEntries).toEqual(10000);
36
+ expect(goptions.useRedis).toEqual(false);
37
+ expect(goptions.endFlush).toEqual(false);
38
+ expect(goptions.redisPort).toEqual('6379');
39
+ expect(goptions.redisServer).toEqual('localhost');
40
+ expect(goptions.k6ScriptPath).toEqual('.');
41
+ expect(goptions.defaultDatabaseMinExtraDataSize).toEqual(0);
42
+ expect(goptions.defaultDatabaseMaxExtraDataSize).toEqual(2000);
43
+ });
44
+
45
+ test('Checking default rest01 service config', async () =>
46
+ {
47
+ expect.assertions(11);
48
+
49
+ process.env.STSENVFILE = './.env-test-file-1'; // Empty environment file
50
+ let goptions = require('./stsconfig.js').$options;
51
+
52
+ expect(goptions.rest01endpoint).toEqual('http://localhost');
53
+ expect(goptions.rest01hostport).toEqual('3003');
54
+ expect(goptions.rest01port).toEqual('3003');
55
+ expect(goptions.rest01apiroot).toEqual('/stsrest01/v1');
56
+ expect(goptions.rest01prometheussupport).toEqual(true);
57
+ expect(goptions.rest01prometheusclusterport).toEqual('3013');
58
+ expect(goptions.rest01servicename).toEqual('STSRest01');
59
+ expect(goptions.rest01serviceversion).toEqual('1.0.0');
60
+ expect(goptions.rest01email).toEqual('K6TestUser@sts');
61
+ expect(goptions.rest01password).toEqual('K6TestUserPassword');
62
+ expect(goptions.rest01passwordfile).toEqual(undefined);
63
+ });
64
+
65
+ test('Checking default instrument manager service config', async () =>
66
+ {
67
+ expect.assertions(11);
68
+
69
+ process.env.STSENVFILE = './.env-test-file-1'; // Empty environment file
70
+ let goptions = require('./stsconfig.js').$options;
71
+
72
+ expect(goptions.imendpoint).toEqual('http://localhost');
73
+ expect(goptions.imhostport).toEqual('3001');
74
+ expect(goptions.import).toEqual('3001');
75
+ expect(goptions.imapiroot).toEqual('/stsinstrumentmanager/v1');
76
+ expect(goptions.imprometheussupport).toEqual(true);
77
+ expect(goptions.imprometheusclusterport).toEqual('3011');
78
+ expect(goptions.imservicename).toEqual('STSInstrumentManager');
79
+ expect(goptions.imserviceversion).toEqual('1.0.0');
80
+ expect(goptions.imemail).toEqual('K6TestUser@sts');
81
+ expect(goptions.impassword).toEqual('K6TestUserPassword');
82
+ expect(goptions.impasswordfile).toEqual(undefined);
18
83
  });
19
84
  });
20
85