Skip to content

Commit d545f65

Browse files
committed
Add IT test
1 parent 2cc04c4 commit d545f65

File tree

5 files changed

+181
-0
lines changed

5 files changed

+181
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing,
13+
# software distributed under the License is distributed on an
14+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
# KIND, either express or implied. See the License for the
16+
# specific language governing permissions and limitations
17+
# under the License.
18+
#
19+
# Minimal SSH server for integration tests: allows password auth and TCP forwarding
20+
# so Hop can tunnel to Postgres through this container.
21+
#
22+
FROM alpine:3.19
23+
24+
RUN apk add --no-cache openssh && \
25+
ssh-keygen -A && \
26+
adduser -D -s /bin/sh hop && \
27+
echo "hop:hop_ssh_password" | chpasswd && \
28+
sed -i 's/^#\?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config && \
29+
sed -i 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/' /etc/ssh/sshd_config && \
30+
sed -i 's/^#\?AllowTcpForwarding.*/AllowTcpForwarding yes/' /etc/ssh/sshd_config && \
31+
sed -i 's/^#\?GatewayPorts.*/GatewayPorts no/' /etc/ssh/sshd_config
32+
33+
EXPOSE 22
34+
35+
CMD ["/usr/sbin/sshd", "-D"]

docker/integration-tests/integration-tests-database.yaml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,27 @@ services:
2323
depends_on:
2424
postgres:
2525
condition: service_healthy
26+
ssh:
27+
condition: service_started
2628
links:
2729
- postgres
2830
- mssql
2931
- mysql
32+
- ssh
33+
environment:
34+
- SSH_TUNNEL_HOST=ssh
35+
- SSH_TUNNEL_PORT=22
36+
- SSH_TUNNEL_USER=hop
37+
- SSH_TUNNEL_PASSWORD=hop_ssh_password
3038
volumes:
3139
- ./resource/mssql/mssql_bulkload.csv:/tmp/mssql_bulkload.csv
3240

41+
ssh:
42+
build:
43+
context: .
44+
dockerfile: ssh.Dockerfile
45+
# No host port exposure needed; test container connects via service name "ssh"
46+
3347
postgres:
3448
image: postgres:latest
3549
env_file:
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Licensed to the Apache Software Foundation (ASF) under one or more
5+
contributor license agreements. See the NOTICE file distributed with
6+
this work for additional information regarding copyright ownership.
7+
The ASF licenses this file to You under the Apache License, Version 2.0
8+
(the "License"); you may not use this file except in compliance with
9+
the License. You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
<workflow>
21+
<name>main-0038-postgres-via-ssh</name>
22+
<name_sync_with_filename>Y</name_sync_with_filename>
23+
<description>PostgreSQL via SSH tunnel</description>
24+
<extended_description/>
25+
<workflow_version/>
26+
<created_user>-</created_user>
27+
<created_date>2025/03/16 00:00:00.000</created_date>
28+
<modified_user>-</modified_user>
29+
<modified_date>2025/03/16 00:00:00.000</modified_date>
30+
<parameters>
31+
</parameters>
32+
<actions>
33+
<action>
34+
<name>Start</name>
35+
<description/>
36+
<type>SPECIAL</type>
37+
<attributes/>
38+
<DayOfMonth>1</DayOfMonth>
39+
<doNotWaitOnFirstExecution>N</doNotWaitOnFirstExecution>
40+
<hour>12</hour>
41+
<intervalMinutes>60</intervalMinutes>
42+
<intervalSeconds>0</intervalSeconds>
43+
<minutes>0</minutes>
44+
<repeat>N</repeat>
45+
<schedulerType>0</schedulerType>
46+
<weekDay>1</weekDay>
47+
<parallel>N</parallel>
48+
<xloc>50</xloc>
49+
<yloc>50</yloc>
50+
<attributes_hac/>
51+
</action>
52+
<action>
53+
<name>SQL</name>
54+
<description/>
55+
<type>SQL</type>
56+
<attributes/>
57+
<connection>unit-test-db-ssh</connection>
58+
<sendOneStatement>N</sendOneStatement>
59+
<sql>SELECT 1 AS one, current_database() AS db</sql>
60+
<sqlfromfile>N</sqlfromfile>
61+
<useVariableSubstitution>N</useVariableSubstitution>
62+
<parallel>N</parallel>
63+
<xloc>195</xloc>
64+
<yloc>50</yloc>
65+
<attributes_hac/>
66+
</action>
67+
</actions>
68+
<hops>
69+
<hop>
70+
<from>Start</from>
71+
<to>SQL</to>
72+
<enabled>Y</enabled>
73+
<evaluation>Y</evaluation>
74+
<unconditional>Y</unconditional>
75+
</hop>
76+
</hops>
77+
<notepads>
78+
</notepads>
79+
<attributes/>
80+
</workflow>
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"rdbms": {
3+
"POSTGRESQL": {
4+
"sshTunnelPort": "${SSH_TUNNEL_PORT}",
5+
"sshTunnelUsePrivateKey": false,
6+
"databaseName": "${POSTGRES_DATABASE}",
7+
"pluginId": "POSTGRESQL",
8+
"sshTunnelEnabled": true,
9+
"accessType": 0,
10+
"sshTunnelUsername": "${SSH_TUNNEL_USER}",
11+
"hostname": "${POSTGRES_HOST}",
12+
"password": "${POSTGRES_PASSWORD}",
13+
"pluginName": "PostgreSQL",
14+
"port": "${POSTGRES_PORT}",
15+
"sshTunnelHost": "${SSH_TUNNEL_HOST}",
16+
"attributes": {
17+
"SUPPORTS_TIMESTAMP_DATA_TYPE": "Y",
18+
"QUOTE_ALL_FIELDS": "N",
19+
"SUPPORTS_BOOLEAN_DATA_TYPE": "Y",
20+
"FORCE_IDENTIFIERS_TO_LOWERCASE": "N",
21+
"PRESERVE_RESERVED_WORD_CASE": "Y",
22+
"SQL_CONNECT": "",
23+
"FORCE_IDENTIFIERS_TO_UPPERCASE": "N",
24+
"PREFERRED_SCHEMA_NAME": ""
25+
},
26+
"manualUrl": "",
27+
"sshTunnelPassphrase": "Encrypted ",
28+
"sshTunnelPassword": "${SSH_TUNNEL_PASSWORD}",
29+
"sshTunnelPrivateKeyFile": "",
30+
"username": "${POSTGRES_USER}"
31+
}
32+
},
33+
"name": "unit-test-db-ssh"
34+
}

integration-tests/scripts/run-tests.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,20 @@ if [ -z "${POSTGRES_PASSWORD}" ]; then
6161
POSTGRES_PASSWORD=hop_password
6262
fi
6363

64+
# SSH tunnel parameters (for PostgreSQL-via-SSH integration tests)
65+
if [ -z "${SSH_TUNNEL_HOST}" ]; then
66+
SSH_TUNNEL_HOST=ssh
67+
fi
68+
if [ -z "${SSH_TUNNEL_PORT}" ]; then
69+
SSH_TUNNEL_PORT=22
70+
fi
71+
if [ -z "${SSH_TUNNEL_USER}" ]; then
72+
SSH_TUNNEL_USER=hop
73+
fi
74+
if [ -z "${SSH_TUNNEL_PASSWORD}" ]; then
75+
SSH_TUNNEL_PASSWORD=hop_ssh_password
76+
fi
77+
6478
if [ -z "${PROJECT_NAME}" ]; then
6579
PROJECT_NAME="*"
6680
fi
@@ -152,6 +166,10 @@ for d in "${CURRENT_DIR}"/../${PROJECT_NAME}/; do
152166
-p POSTGRES_PORT=${POSTGRES_PORT} \
153167
-p POSTGRES_USER=${POSTGRES_USER} \
154168
-p POSTGRES_PASSWORD=${POSTGRES_PASSWORD} \
169+
-p SSH_TUNNEL_HOST=${SSH_TUNNEL_HOST} \
170+
-p SSH_TUNNEL_PORT=${SSH_TUNNEL_PORT} \
171+
-p SSH_TUNNEL_USER=${SSH_TUNNEL_USER} \
172+
-p SSH_TUNNEL_PASSWORD=${SSH_TUNNEL_PASSWORD} \
155173
-p BOOTSTRAP_SERVERS=${BOOTSTRAP_SERVERS} \
156174
-f $hop_file > >(tee /tmp/test_output) 2> >(tee /tmp/test_output_err >&1)
157175

0 commit comments

Comments
 (0)