Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
52c30c6
Add SSL mode tests and skip timing-sensitive tests under SSL
Aug 31, 2025
4848855
Add blank lines for improved readability in test_sslmode.py
Aug 31, 2025
fba64d5
Enhance SSL testing support with detailed OpenGauss SSL setup instruc…
Aug 31, 2025
9bab615
Improve README formatting with blank lines for clarity in installatio…
Aug 31, 2025
7b8c8d0
Improve formatting in README.rst for OpenGauss SSL setup instructions
Aug 31, 2025
e8bdffc
Add SSL-enabled tests workflow and rename existing tests workflow
Aug 31, 2025
c0c0fd7
Add permission reset and shallow fetch to SSL tests workflow
Aug 31, 2025
2f94f8f
Add omm user creation and set ownership/permissions for certificate a…
Aug 31, 2025
ec6d15c
Add sudo to chmod command for certificate and config directories in S…
Aug 31, 2025
fe9e0a0
Run openssl commands as omm user in SSL tests workflow
Aug 31, 2025
f1a2879
Run certificate and config file generation as omm user and remove red…
Aug 31, 2025
69217ab
Simplify SSL mode to require in GAUSSDB_TEST_DSN for SSL tests workflow
Aug 31, 2025
fc460fe
Use full paths with github.workspace and add SSL configuration verifi…
Aug 31, 2025
7eb44f9
Add configuration file copying and permissions setup for openGauss in…
Aug 31, 2025
ebaf4de
Update SSL test workflow to remove conf volume, adjust permissions, a…
Aug 31, 2025
2d2b99f
Update OpenSSL in tests-ssl workflow and fix GAUSSDB_TEST_DSN format
Aug 31, 2025
476a024
Install specific OpenSSL version 1.1.1f in tests-ssl.yml workflow
Aug 31, 2025
e47f837
Enhance OpenSSL 1.1.1f installation with shared library support and d…
Aug 31, 2025
2a863dd
Enable MDC2 support in OpenSSL 1.1.1f configuration in tests-ssl.yml
Aug 31, 2025
b5e28ce
Add weak SSL ciphers support and enhance OpenSSL configuration checks…
Aug 31, 2025
c861d92
Move OpenSSL environment variables to correct workflow step in tests-…
Aug 31, 2025
ba71fc2
Switch to ubuntu-20.04 and remove OpenSSL 1.1.1f installation in test…
Sep 1, 2025
00a9416
Switch to ubuntu-22.04
Sep 1, 2025
0b8548f
Switch to ubuntu-22.04
Sep 1, 2025
f67d6db
Move certificate generation to certs directory and simplify workflow …
Sep 1, 2025
11bf8a2
Move certificate generation to certs directory and simplify workflow …
Sep 1, 2025
1f0cd6e
Update pg_hba.conf to enable MD5 authentication and set certificate p…
Sep 1, 2025
0a23098
Replace volume mount with explicit directory creation and file copy f…
Sep 1, 2025
e58bb5c
Update SSL test workflow to adjust permissions for certs and configur…
Sep 1, 2025
b07f2a1
Update SSL test workflow to adjust permissions for certs and configur…
Sep 1, 2025
16c66c3
Update sslmode to verify-ca
Sep 1, 2025
13d3c61
Update sslmode to verify-ca
Sep 1, 2025
8f695d8
Update sslmode to verify-ca
Sep 1, 2025
0252027
Fix SSL cert permissions
Sep 1, 2025
617843a
Fix SSL cert permissions
Sep 1, 2025
3b4210a
Fix SSL cert permissions
Sep 1, 2025
674aa4f
Fix SSL cert permissions
Sep 1, 2025
3992a91
Update GAUSSDB_TEST_DSN
Sep 1, 2025
3c10f68
Update client certificates
Sep 1, 2025
36fafd1
Update client certificate subject to root and add SSL mode check in t…
Sep 1, 2025
386a84f
Update GAUSSDB_TEST_DSN to include client certificate and key for SSL
Sep 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
240 changes: 240 additions & 0 deletions .github/workflows/tests-ssl.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
name: Tests with SSL

on:
push:
branches:
- "*"
pull_request:
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref_name }}
cancel-in-progress: true

jobs:
test:
runs-on: ubuntu-22.04

services:
opengauss:
image: opengauss/opengauss-server:latest
ports:
- 5432:5432
env:
GS_USERNAME: root
GS_USER_PASSWORD: Passwd@123
GS_PASSWORD: Passwd@123
options: >-
--privileged=true
--name opengauss-custom

steps:
- name: Reset permissions for checkout
run: |
sudo chmod -R u+rwX certs || true
if: always()

- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Set up Python 3.9
uses: actions/setup-python@v5
with:
python-version: "3.9"
cache: pip

- name: Create and activate virtual environment
run: |
python -m venv venv
echo "VENV_PATH=$GITHUB_WORKSPACE/venv/bin" >> $GITHUB_ENV
source venv/bin/activate

- name: Create omm user
run: |
sudo useradd -m -s /bin/bash omm || true
sudo usermod -aG docker omm || true

- name: Create configuration directories
run: |
mkdir -p ${{ github.workspace }}/opengauss/conf
sudo chown omm:omm ${{ github.workspace }}/opengauss/conf ${{ github.workspace }}/certs || true
sudo chmod 755 ${{ github.workspace }}/opengauss/conf ${{ github.workspace }}/certs || true

- name: Set certificate permissions
run: |
sudo chown -R omm:omm ${{ github.workspace }}/certs
sudo chmod 644 ${{ github.workspace }}/certs/*key || true
sudo chmod 644 ${{ github.workspace }}/certs/*.crt || true

- name: Create postgresql.conf with SSL
run: |
sudo -u omm bash -c 'cat > ${{ github.workspace }}/opengauss/conf/postgresql.conf <<EOF
max_connections = 200
session_timeout = 10min
bulk_write_ring_size = 2GB
max_prepared_transactions = 200
cstore_buffers = 512MB
enable_incremental_checkpoint = on
incremental_checkpoint_timeout = 60s
enable_double_write = on
wal_keep_segments = 16
enable_slot_log = off
synchronous_standby_names = '"'"'*'"'"'
walsender_max_send_size = 8MB
hot_standby = on
enable_kill_query = off
logging_collector = on
log_filename = '"'"'postgresql-%Y-%m-%d_%H%M%S.log'"'"'
log_file_mode = 0600
log_rotation_size = 20MB
log_min_duration_statement = 1800000
log_connections = off
log_disconnections = off
log_duration = off
log_hostname = off
log_line_prefix = '"'"'%m %u %d %h %p %S '"'"'
log_timezone = '"'"'UTC'"'"'
enable_alarm = on
connection_alarm_rate = 0.9
alarm_report_interval = 10
alarm_component = '"'"'/opt/snas/bin/snas_cm_cmd'"'"'
use_workload_manager = on
datestyle = '"'"'iso, mdy'"'"'
timezone = '"'"'UTC'"'"'
lc_messages = '"'"'en_US.utf8'"'"'
lc_monetary = '"'"'en_US.utf8'"'"'
lc_numeric = '"'"'en_US.utf8'"'"'
lc_time = '"'"'en_US.utf8'"'"'
default_text_search_config = '"'"'pg_catalog.english'"'"'
lockwait_timeout = 1200s
pgxc_node_name = '"'"'gaussdb'"'"'
audit_enabled = on
job_queue_processes = 10
dolphin.nulls_minimal_policy = on
password_encryption_type = 0
wal_level = logical
application_name = '"'"''"'"'
listen_addresses = '"'"'*'"'"'
max_replication_slots = 10
max_wal_senders = 10
shared_buffers = 512MB
ssl = on
ssl_cert_file = '"'"'/var/lib/opengauss/certs/server.crt'"'"'
ssl_key_file = '"'"'/var/lib/opengauss/certs/server.key'"'"'
ssl_ca_file = '"'"'/var/lib/opengauss/certs/ca.crt'"'"'
EOF'
sudo chmod 644 ${{ github.workspace }}/opengauss/conf/postgresql.conf

- name: Create pg_hba.conf with SSL
run: |
sudo -u omm bash -c 'cat > ${{ github.workspace }}/opengauss/conf/pg_hba.conf <<EOF
local all all trust
host all all 127.0.0.1/32 trust
host all all ::1/128 trust
hostssl all all 0.0.0.0/0 cert
host all all 0.0.0.0/0 md5
host replication gaussdb 0.0.0.0/0 md5
EOF'
sudo chmod 644 ${{ github.workspace }}/opengauss/conf/pg_hba.conf

- name: Debug file permissions
run: |
ls -l ${{ github.workspace }}/opengauss/conf/
whoami
docker info --format '{{.ServerVersion}}'
docker ps -a

- name: Copy configuration files to container data directory
run: |
docker exec opengauss-custom mkdir -p /var/lib/opengauss/data
docker cp ${{ github.workspace }}/opengauss/conf/postgresql.conf opengauss-custom:/var/lib/opengauss/data/postgresql.conf
docker cp ${{ github.workspace }}/opengauss/conf/pg_hba.conf opengauss-custom:/var/lib/opengauss/data/pg_hba.conf

docker exec opengauss-custom mkdir -p /var/lib/opengauss/certs
docker cp ${{ github.workspace }}/certs/server.crt opengauss-custom:/var/lib/opengauss/certs/
docker cp ${{ github.workspace }}/certs/server.key opengauss-custom:/var/lib/opengauss/certs/
docker cp ${{ github.workspace }}/certs/ca.crt opengauss-custom:/var/lib/opengauss/certs/

- name: Fix SSL cert permissions
run: |
sudo chown -R $(whoami):$(whoami) ${{ github.workspace }}/certs
sudo chmod 600 ${{ github.workspace }}/certs/*

- name: Set permissions inside container
run: |
docker exec opengauss-custom chown omm:omm /var/lib/opengauss/data/postgresql.conf /var/lib/opengauss/data/pg_hba.conf /var/lib/opengauss/certs/server.crt /var/lib/opengauss/certs/server.key /var/lib/opengauss/certs/ca.crt
docker exec opengauss-custom chmod 600 /var/lib/opengauss/data/postgresql.conf /var/lib/opengauss/data/pg_hba.conf /var/lib/opengauss/certs/server.crt /var/lib/opengauss/certs/server.key /var/lib/opengauss/certs/ca.crt

- name: Restart openGauss to apply configuration
run: |
docker restart opengauss-custom

- name: Install GaussDB libpq driver
run: |
sudo apt update
sudo apt install -y wget unzip
wget -O /tmp/GaussDB_driver.zip https://dbs-download.obs.cn-north-1.myhuaweicloud.com/GaussDB/1730887196055/GaussDB_driver.zip
unzip /tmp/GaussDB_driver.zip -d /tmp/ && rm -rf /tmp/GaussDB_driver.zip
\cp /tmp/GaussDB_driver/Centralized/Hce2_X86_64/GaussDB-Kernel*64bit_Python.tar.gz /tmp/
tar -zxvf /tmp/GaussDB-Kernel*64bit_Python.tar.gz -C /tmp/ && rm -rf /tmp/GaussDB-Kernel*64bit_Python.tar.gz && rm -rf /tmp/_GaussDB && rm -rf /tmp/GaussDB_driver
echo /tmp/lib | sudo tee /etc/ld.so.conf.d/gauss-libpq.conf
sudo sed -i '1s|^|/tmp/lib\n|' /etc/ld.so.conf
sudo ldconfig
ldconfig -p | grep pq

- name: Install dependencies
run: |
source venv/bin/activate
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install ./tools/isort-gaussdb/
pip install "./gaussdb[dev,test]"
pip install ./gaussdb_pool

- name: Wait for openGauss to be ready
env:
GSQL_PASSWORD: Passwd@123
run: |
source venv/bin/activate
for i in {1..30}; do
pg_isready -h localhost -p 5432 -U root && break
sleep 10
done
if ! pg_isready -h localhost -p 5432 -U root; then
echo "openGauss is not ready"
exit 1
fi

- name: Verify SSL configuration
run: |
docker exec opengauss-custom bash -c "su - omm -c 'gsql -d postgres -c \"SHOW ssl;\"'" | grep -q "on" || { echo "ERROR: ssl is not set to 'on'"; exit 1; }
docker exec opengauss-custom bash -c "su - omm -c 'gsql -d postgres -c \"SHOW ssl_cert_file;\"'" | grep -q "/var/lib/opengauss/certs/server.crt" || { echo "ERROR: ssl_cert_file is not set to '/var/lib/opengauss/certs/server.crt'"; exit 1; }
docker exec opengauss-custom bash -c "su - omm -c 'gsql -d postgres -c \"SHOW ssl_key_file;\"'" | grep -q "/var/lib/opengauss/certs/server.key" || { echo "ERROR: ssl_key_file is not set to '/var/lib/opengauss/certs/server.key'"; exit 1; }
docker exec opengauss-custom bash -c "su - omm -c 'gsql -d postgres -c \"SHOW ssl_ca_file;\"'" | grep -q "/var/lib/opengauss/certs/ca.crt" || { echo "ERROR: ssl_ca_file is not set to '/var/lib/opengauss/certs/ca.crt'"; exit 1; }
echo "SSL configuration verified successfully"

- name: Create test database
run: |
docker exec opengauss-custom bash -c "su - omm -c 'gsql -d postgres -c \"CREATE DATABASE test ;\"'"

- name: Create report directory
run: |
mkdir -p reports

- name: Run tests
env:
PYTHONPATH: ./gaussdb:./gaussdb_pool
GAUSSDB_IMPL: python
GAUSSDB_TEST_DSN: "host=127.0.0.1 port=5432 dbname=test user=root password=Passwd@123 sslmode=verify-ca sslrootcert=${{ github.workspace }}/certs/ca.crt sslcert=${{ github.workspace }}/certs/client.crt sslkey=${{ github.workspace }}/certs/client.key"
run: |
export PGSSLDEBUG=1
source venv/bin/activate
pytest -s -v

- name: Cleanup
if: always()
run: |
docker stop opengauss-custom
docker rm opengauss-custom
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Tests
name: Tests without SSL

on:
push:
Expand Down
Loading
Loading