Skip to content

Commit 50f3e4e

Browse files
d-linkoDavid LinkoBrianSipos
authored
57 update sql schema and stored procedures for latest internet draft (#109)
* moved amp-sql to ion * updated sql to latest internet drafts * fixed errors in stored procedures * renamed amp-sql to refdb-sql * cleaned up repo, removed unused files * Backporting ION compiler compat fix from apl-fy24 * Aligning workflow conditions with dev branch * Bumping CI action versions for compatibility * removed old code * Moving SQL containers into normal integration test configs * Updates for working SQL DDL --------- Co-authored-by: David Linko <[email protected]> Co-authored-by: Brian Sipos <[email protected]>
1 parent f0e4bd3 commit 50f3e4e

21 files changed

+4626
-14
lines changed

integration-test-ion/Containerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,14 @@ COPY --chmod=755 systemd/service_is_running.sh /usr/local/bin/service_is_running
105105

106106
# Test tools
107107
RUN apt-get update && apt-get install -y \
108-
curl git tshark
108+
curl git tshark postgresql-client
109109
RUN pip3 install --break-system-packages git+https://github.com/JHUAPL-DTNMA/dtnma-ace.git@apl-fy24
110110
RUN git clone --branch apl-fy24 https://github.com/JHUAPL-DTNMA/dtnma-adms.git /usr/local/share/ace/adms
111111

112112
# REFDA and REFDM to test
113113
RUN apt-get update && apt-get install -y \
114114
cmake ninja-build ruby pkg-config \
115-
flex libfl-dev bison libpcre2-dev civetweb libcivetweb-dev libssl-dev libcjson-dev libsystemd-dev
115+
flex libfl-dev bison libpcre2-dev libpq-dev civetweb libcivetweb-dev libssl-dev libcjson-dev libsystemd-dev
116116
COPY deps /usr/src/nm/deps
117117
COPY cmake /usr/src/nm/cmake
118118
COPY src /usr/src/nm/src
@@ -121,6 +121,7 @@ RUN ls -lt /usr/src/nm/
121121
RUN cd /usr/src/nm && \
122122
cmake -S . -B build/default \
123123
-DCMAKE_BUILD_TYPE=Debug \
124+
-DTRANSPORT_UNIX_SOCKET=OFF \
124125
-DTRANSPORT_ION_BP=ON \
125126
-DBUILD_TESTING=OFF \
126127
-DBUILD_DOCS_API=OFF -DBUILD_DOCS_MAN=OFF \

integration-test-ion/compose.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,21 @@
1+
volumes:
2+
postgres-data:
3+
# temporary storage
4+
15
services:
6+
postgres:
7+
build:
8+
context: ../refdb-sql
9+
dockerfile: Containerfile
10+
hostname: postgres
11+
restart: unless-stopped
12+
environment:
13+
POSTGRES_USER: ${DB_USER}
14+
POSTGRES_PASSWORD: ${DB_PASSWORD}
15+
POSTGRES_DB: ${DB_NAME}
16+
volumes:
17+
- "postgres-data:/var/lib/postgresql/data"
18+
219
manager:
320
hostname: manager
421
build:
@@ -7,7 +24,9 @@ services:
724
target: manager
825
ports:
926
- "8089:8089/tcp"
10-
depends_on: {}
27+
depends_on:
28+
postgres:
29+
condition: service_healthy
1130
privileged: true
1231
tty: true
1332
cap_add:
@@ -21,6 +40,10 @@ services:
2140
DTNMA_LOGLEVEL: debug
2241
ION_NODE_NUM: 1
2342
MGR_NODE_NUM: 1
43+
DB_HOST: postgres
44+
DB_USER: ${DB_USER}
45+
DB_PASSWORD: ${DB_PASSWORD}
46+
DB_NAME: ${DB_NAME}
2447
DUMPCAP_OUTFILE: /var/log/pcap/manager.pcap
2548
DUMPCAP_OPTS: -i lo -i eth0
2649

integration-test-ion/run.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ cd "${SELFDIR}"
2323

2424
DOCKER=${DOCKER:-docker}
2525

26+
export DB_NAME=refdm
27+
export DB_USER=refdm
28+
export DB_PASSWORD=notsecret
29+
2630
if [ "$1" = "start" ]
2731
then
2832
export DOCKER_BUILDKIT=1
2933

3034
${DOCKER} compose build
31-
${DOCKER} compose up -d --force-recreate --remove-orphans
35+
${DOCKER} compose up --detach --force-recreate --remove-orphans
3236
elif [ "$1" = "stop" ]
3337
then
34-
${DOCKER} compose stop
35-
${DOCKER} compose rm -fv
38+
${DOCKER} compose down --rmi local --volumes
39+
${DOCKER} compose rm --force --volumes
3640
elif [ "$1" = "check" ]
3741
then
3842
${DOCKER} compose ps

integration-test-socket/Containerfile

+3-2
Original file line numberDiff line numberDiff line change
@@ -92,14 +92,14 @@ COPY --chmod=755 systemd/service_is_running.sh /usr/local/bin/service_is_running
9292

9393
# Test tools
9494
RUN apt-get update && apt-get install -y \
95-
curl git tshark
95+
curl git tshark postgresql-client
9696
RUN pip3 install --break-system-packages git+https://github.com/JHUAPL-DTNMA/dtnma-ace.git@apl-fy24
9797
RUN git clone --branch apl-fy24 https://github.com/JHUAPL-DTNMA/dtnma-adms.git /usr/local/share/ace/adms
9898

9999
# REFDA and REFDM to test
100100
RUN apt-get update && apt-get install -y \
101101
cmake ninja-build ruby pkg-config \
102-
flex libfl-dev bison libpcre2-dev civetweb libcivetweb-dev libssl-dev libcjson-dev libsystemd-dev
102+
flex libfl-dev bison libpcre2-dev libpq-dev civetweb libcivetweb-dev libssl-dev libcjson-dev libsystemd-dev
103103
COPY deps /usr/src/nm/deps
104104
COPY cmake /usr/src/nm/cmake
105105
COPY src /usr/src/nm/src
@@ -108,6 +108,7 @@ RUN ls -lt /usr/src/nm/
108108
RUN cd /usr/src/nm && \
109109
cmake -S . -B build/default \
110110
-DCMAKE_BUILD_TYPE=Debug \
111+
-DTRANSPORT_UNIX_SOCKET=ON \
111112
-DTRANSPORT_ION_BP=OFF \
112113
-DBUILD_TESTING=OFF \
113114
-DBUILD_DOCS_API=OFF -DBUILD_DOCS_MAN=OFF \

integration-test-socket/compose.yml

+24-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,30 @@
1+
volumes:
2+
postgres-data:
3+
# temporary storage
4+
15
services:
6+
postgres:
7+
build:
8+
context: ../refdb-sql
9+
dockerfile: Containerfile
10+
hostname: postgres
11+
restart: unless-stopped
12+
environment:
13+
POSTGRES_USER: ${DB_USER}
14+
POSTGRES_PASSWORD: ${DB_PASSWORD}
15+
POSTGRES_DB: ${DB_NAME}
16+
volumes:
17+
- "postgres-data:/var/lib/postgresql/data"
18+
219
combined:
320
build:
421
context: ..
522
dockerfile: integration-test-socket/Containerfile
623
ports:
724
- "8089:8089/tcp"
8-
depends_on: {}
25+
depends_on:
26+
postgres:
27+
condition: service_healthy
928
privileged: true
1029
tty: true
1130
cap_add:
@@ -18,3 +37,7 @@ services:
1837
REFDA_EID: file:/var/run/refda.sock
1938
REFDA_SOCKET: /var/run/refda.sock
2039
REFDM_SOCKET: /var/run/refdm.sock
40+
DB_HOST: postgres
41+
DB_USER: ${DB_USER}
42+
DB_PASSWORD: ${DB_PASSWORD}
43+
DB_NAME: ${DB_NAME}

integration-test-socket/run.sh

+7-3
Original file line numberDiff line numberDiff line change
@@ -23,16 +23,20 @@ cd "${SELFDIR}"
2323

2424
DOCKER=${DOCKER:-docker}
2525

26+
export DB_NAME=refdb
27+
export DB_USER=refdm
28+
export DB_PASSWORD=notsecret
29+
2630
if [ "$1" = "start" ]
2731
then
2832
export DOCKER_BUILDKIT=1
2933

3034
${DOCKER} compose build
31-
${DOCKER} compose up -d --force-recreate --remove-orphans
35+
${DOCKER} compose up --detach --force-recreate --remove-orphans
3236
elif [ "$1" = "stop" ]
3337
then
34-
${DOCKER} compose stop
35-
${DOCKER} compose rm -fv
38+
${DOCKER} compose down --rmi local --volumes
39+
${DOCKER} compose rm --force --volumes
3640
elif [ "$1" = "check" ]
3741
then
3842
${DOCKER} compose ps

refdb-sql/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
refdb-sql/postgres/pgpass.conf

refdb-sql/Containerfile

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2025 The Johns Hopkins University Applied Physics
2+
# Laboratory LLC.
3+
4+
# This file is part of the Delay-Tolerant Networking Management
5+
# Architecture (DTNMA) Tools package.
6+
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
18+
# This is a postgres stateful database with data definition startup SQL scripts
19+
FROM postgres:14
20+
21+
COPY postgres/Database_Scripts/*/*.sql /docker-entrypoint-initdb.d/
22+
COPY postgres/Database_Scripts/*.sql /docker-entrypoint-initdb.d/
23+
24+
# This is used for testing, it is easier to delete the amp_agent after inserting it using adm_amp_agent.sql instead of removing the script since other scripts are also relying on amp_agent
25+
# COPY postgres/Database_Scripts/Routines/amp_agent_delete.sql /docker-entrypoint-initdb.d/31-amp_agent_delete.sql
26+
27+
HEALTHCHECK --start-period=10s --interval=10s --timeout=5s --retries=5 \
28+
CMD pg_isready -U healthcheck

0 commit comments

Comments
 (0)