Skip to content

Commit 07fa755

Browse files
author
dimmaryanto93
committed
dynamic configuration from environtment
1 parent a54df5b commit 07fa755

File tree

3 files changed

+72
-8
lines changed

3 files changed

+72
-8
lines changed

Diff for: docker-compose.yml

+7
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ services:
4949
logstash:
5050
build: ./logstash/
5151
image: dimmaryanto93/logstash-jdbc-plugin:1.1
52+
environment:
53+
- LOGSTASH_JDBC_URL=jdbc:mysql://mysql:3306/example?useSSL=false
54+
- LOGSTASH_JDBC_DRIVER=com.mysql.jdbc.Driver
55+
- LOGSTASH_JDBC_DRIVER_JAR_LOCATION=mysql-connector-java.jar
56+
- LOGSTASH_JDBC_USERNAME=admin
57+
- LOGSTASH_JDBC_PASSWORD=admin
58+
- LOGSTASH_ELASTICSEARCH_HOST=http://elasticsearch:9200
5259
ports:
5360
- 9600:9600
5461
- 5044:5044

Diff for: flyway/sql/V2__data.sql

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
insert into requirement(id, name, registration_nomor)
2+
values ('001', 'req 1', '190001'),
3+
('002', 'req 2', '190001'),
4+
('003', 'req 3', '190001'),
5+
('004', 'req 4', '190001'),
6+
('005', 'req 5', '190001'),
7+
('006', 'req 6', '190001'),
8+
('007', 'req 7', '190001'),
9+
('008', 'req 8', '190001');
10+
11+
insert into test_script(id, file_name, requirement_id)
12+
values ('001', 'login normal flow', '001'),
13+
('002', 'login username salah', '001'),
14+
('003', 'login password salah', '001'),
15+
('004', 'login user disabled', '001'),
16+
('005', 'login user blocked', '001'),
17+
('006', 'create registration normal flow', '002'),
18+
('007', 'create registration missing column', '002'),
19+
('008', 'update registration', '002'),
20+
('009', 'delete registration', '002'),
21+
('010', 'copy from parent', '003'),
22+
('011', 'create registration missing column', '003');
23+
24+
insert into design_step(id, step_name, test_script_id)
25+
values (uuid(), 'input valid username', '001'),
26+
(uuid(), 'input valid password', '001'),
27+
(uuid(), 'klick button submit', '001'),
28+
(uuid(), 'masuk ke halaman utama', '001'),
29+
(uuid(), 'input wrong username!', '002'),
30+
(uuid(), 'input valid password', '002'),
31+
(uuid(), 'click button submit', '002'),
32+
(uuid(), 'notification username & password salah', '002'),
33+
(uuid(), 'input valid username', '003'),
34+
(uuid(), 'input wrong password!', '003'),
35+
(uuid(), 'click button submit', '003'),
36+
(uuid(), 'show notification username & password salah', '003'),
37+
(uuid(), 'setelah login, masuk ke menu registration list', '006'),
38+
(uuid(), 'click new registration', '006'),
39+
(uuid(), 'pilih type project new registration', '006'),
40+
(uuid(), 'input nama project', '006'),
41+
(uuid(), 'click button submit', '006'),
42+
(uuid(), 'muncul notification registration created!', '006');

Diff for: logstash/jdbc-input-plugin.conf

+23-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
1-
# Logstash jdbc input -> Elasticsearch pipeline.
1+
# Logstash jdbc input -> elasticseach with environtment variables
22
input {
33
jdbc {
4-
jdbc_driver_library => "mysql-connector-java.jar"
5-
jdbc_driver_class => "com.mysql.jdbc.Driver"
6-
jdbc_connection_string => "jdbc:mysql://mysql:3306/example"
7-
jdbc_user => "admin"
8-
jdbc_password => "admin"
4+
jdbc_driver_library => "${LOGSTASH_JDBC_DRIVER_JAR_LOCATION}"
5+
jdbc_driver_class => "${LOGSTASH_JDBC_DRIVER}"
6+
jdbc_connection_string => "${LOGSTASH_JDBC_URL}"
7+
jdbc_user => "${LOGSTASH_JDBC_USERNAME}"
8+
jdbc_password => "${LOGSTASH_JDBC_PASSWORD}"
99
schedule => "* * * * *"
10-
statement => "SELECT * from requirement"
10+
statement => "select concat(
11+
ifnull(req.id, '0'),
12+
'/',
13+
ifnull(test.id, '0'),
14+
'/',
15+
ifnull(design.id, '0')) as id,
16+
req.id as requirement_id,
17+
req.name as requirement_id,
18+
req.registration_nomor as registration_nomor,
19+
test.id as test_id,
20+
test.file_name as test_filename,
21+
design.id as design_id,
22+
design.step_name as design_step_name
23+
from requirement req
24+
left join test_script test on req.id = test.requirement_id
25+
left join design_step design on test.id = design.test_script_id"
1126
}
1227
}
1328

1429
output {
1530
elasticsearch {
16-
hosts => ["http://elasticsearch:9200"]
31+
hosts => ["${LOGSTASH_ELASTICSEARCH_HOST}"]
1732
index => "test_script"
1833
document_id => "%{id}"
1934
}

0 commit comments

Comments
 (0)