Skip to content

Commit a535465

Browse files
committed
customize testing files to account for integration test
because this plugin needs another container for an integration test we're adding here the necessary tweaks for this setup: 'run.sh' will run both normal and integration tests 'setup.sh' will fetch the postgres driver from within the logstash container 'docker-compose.override.yml' adds the postgres container
1 parent 19161ff commit a535465

File tree

4 files changed

+88
-0
lines changed

4 files changed

+88
-0
lines changed

.ci/docker-compose.override.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
version: '3'
2+
3+
services:
4+
5+
logstash:
6+
environment:
7+
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
8+
LOGSTASH_SOURCE: 1
9+
PG_CONNECTION_STRING: "jdbc:postgresql://postgresql:5432"
10+
POSTGRES_PASSWORD: "test_user_password"
11+
12+
postgresql:
13+
image: postgres:latest
14+
environment:
15+
POSTGRES_PASSWORD: "test_user_password"
16+
volumes:
17+
- ./setup.sql:/docker-entrypoint-initdb.d/init.sql
18+
ports:
19+
- 5432:5432
20+

.ci/run.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#!/usr/bin/env bash
2+
3+
# This is intended to be run inside the docker container as the command of the docker-compose.
4+
set -ex
5+
6+
export USER='logstash'
7+
8+
bundle exec rspec spec && bundle exec rspec spec --tag integration

.ci/setup.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
curl -o /usr/share/logstash/postgresql.jar https://jdbc.postgresql.org/download/postgresql-42.2.8.jar

.ci/setup.sql

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
create database jdbc_streaming_db;
2+
3+
\c jdbc_streaming_db;
4+
5+
6+
create table reference_table (
7+
ip VARCHAR(50) NOT NULL,
8+
name VARCHAR(50) NOT NULL,
9+
location VARCHAR(50) NOT NULL
10+
);
11+
12+
13+
DO $$
14+
DECLARE
15+
counter INTEGER := 1 ;
16+
ipTemplate VARCHAR(50) := '10.%s.1.1';
17+
nameTemplate VARCHAR(50) := 'ldn-server-%s';
18+
locationTemplate VARCHAR(50) := 'LDN-%s-2-3';
19+
BEGIN
20+
21+
WHILE counter <= 250
22+
LOOP
23+
INSERT INTO reference_table
24+
VALUES ((SELECT FORMAT(ipTemplate, counter)),
25+
(SELECT FORMAT(nameTemplate, counter)),
26+
(SELECT FORMAT(locationTemplate, counter)));
27+
counter = counter + 1;
28+
END LOOP;
29+
END $$;
30+
31+
32+
create database jdbc_static_db;
33+
34+
\c jdbc_static_db;
35+
36+
37+
create table reference_table (
38+
ip VARCHAR(50) NOT NULL,
39+
name VARCHAR(50) NOT NULL,
40+
location VARCHAR(50) NOT NULL
41+
);
42+
43+
44+
INSERT INTO reference_table VALUES ('10.1.1.1', 'ldn-server-1', 'LDN-2-3-4');
45+
INSERT INTO reference_table VALUES ('10.2.1.1', 'nyc-server-1', 'NYC-5-2-8');
46+
INSERT INTO reference_table VALUES ('10.3.1.1', 'mv-server-1', 'MV-9-6-4');
47+
48+
create DATABASE jdbc_input_db;
49+
50+
\c jdbc_input_db;
51+
52+
CREATE TABLE employee (
53+
emp_no integer NOT NULL,
54+
first_name VARCHAR (50) NOT NULL,
55+
last_name VARCHAR (50) NOT NULL
56+
);
57+
58+
INSERT INTO employee VALUES (1, 'David', 'Blenkinsop');
59+
INSERT INTO employee VALUES (2, 'Mark', 'Guckenheimer');

0 commit comments

Comments
 (0)