mirror of
https://github.com/FerretDB/documentdb.git
synced 2026-11-08 03:52:41 -05:00
### Does this PR have any customer impact? ### Type (Feature, Refactoring, Bugfix, DevOps, Testing, Perf, etc) ### Does it involve schema level changes? (Table, Column, Index, UDF, etc level changes) ### Are you introducing any new config? If yes, do you have tests with and without them being set? ### Release Note (Refer [Template](../docs/release_notes/pgmongo_template.md)) ### Description In oss, we noticed frequently sql test result difference introduced by newer package minor versions (postgres, pgvector, postgis, etc). To make oss CI integration stable and to make test result consistent in oss and pgmongo, we should specify fixed versions for packages in oss, and align with pgmongo. Will depend on manual package version update after verifying the compatibility and meanwhile update test results. ---- #### AI description (iteration 1) #### PR Classification Code cleanup and enhancement. #### PR Summary This pull request declares and uses fixed versions of various packages to ensure consistency and reliability in the build environment. - Updated `/oss/.devcontainer/Dockerfile` to declare and use fixed versions for multiple dependencies including PostgreSQL, Citus, libbson, PG_CRON, PG_VECTOR, Intel Decimal Math Library, PCRE2, and PostGIS. - Modified `/.devcontainer/Dockerfile` to align with the fixed versioning approach and added necessary environment variables. - Added `GetPostgresSourceRef` function in `oss/scripts/utils.sh` to map PostgreSQL versions to specific source references. - Updated `oss/scripts/install_setup_intel_decimal_math_lib.sh` and `oss/scripts/install_setup_pcre2.sh` to accept version parameters. - Moved several scripts from `/scripts` to `/oss/scripts` for better organization. Related work items: #3571853
128 lines
3.2 KiB
Bash
Executable File
128 lines
3.2 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
# fail if trying to reference a variable that is not set.
|
|
set -u
|
|
# exit immediately if a command exits with a non-zero status
|
|
set -e
|
|
|
|
# trap to print line number on error
|
|
error() {
|
|
local parent_lineno="$1"
|
|
local message="${2:-x}"
|
|
local code="${3:-1}"
|
|
if [[ -n "$message" ]] ; then
|
|
echo "Error on or near line ${parent_lineno}: ${message}; exiting with status ${code}"
|
|
else
|
|
echo "Error on or near line ${parent_lineno}; exiting with status ${code}"
|
|
fi
|
|
exit "${code}"
|
|
}
|
|
trap 'error ${LINENO}' ERR
|
|
|
|
function GetPostgresPath()
|
|
{
|
|
local pgVersion=$1
|
|
local osVersion=$(cat /etc/os-release | grep "^ID=");
|
|
|
|
if [[ "$osVersion" == "ID=ubuntu" || "$osVersion" == "ID=debian"|| "$osVersion" == "ID=mariner" ]]; then
|
|
echo "/usr/lib/postgresql/$pgVersion/bin"
|
|
else
|
|
echo "/usr/pgsql-$pgVersion/bin"
|
|
fi
|
|
}
|
|
|
|
function GetPostgresSourceRef()
|
|
{
|
|
local pgVersion=$1
|
|
if [ "$pgVersion" == "16" ]; then
|
|
# This maps to REL_16_2:b78fa8547d02fc72ace679fb4d5289dccdbfc781
|
|
POSTGRESQL_REF="REL_16_2"
|
|
elif [ "$pgVersion" == "15" ]; then
|
|
# This maps to REL15_3:8382864eb5c9f9ebe962ac20b3392be5ae304d23
|
|
POSTGRESQL_REF="REL_15_3"
|
|
else
|
|
echo "Invalid PG Version specified $pgVersion";
|
|
exit 1;
|
|
fi
|
|
|
|
echo $POSTGRESQL_REF
|
|
}
|
|
|
|
function GetPGCTL()
|
|
{
|
|
local pgVersion=${PG_VERSION:-16}
|
|
echo ${pgctlPath:-$(GetPostgresPath $pgVersion)/pg_ctl}
|
|
}
|
|
|
|
function GetInitDB()
|
|
{
|
|
local pgVersion=${PG_VERSION:-16}
|
|
echo $(GetPostgresPath $pgVersion)/initdb
|
|
}
|
|
|
|
function StopServer()
|
|
{
|
|
local _directory=$1
|
|
local _extraOptions=${2:-""}
|
|
|
|
$(GetPGCTL) stop -D $_directory $_extraOptions || true;
|
|
echo "Stopped all PG instances on $_directory";
|
|
}
|
|
|
|
function StartServer()
|
|
{
|
|
local _directory=$1
|
|
local _port=$2
|
|
local _logPath=${3:-$_directory/pglog.log}
|
|
local _pgctlPath=$(GetPGCTL)
|
|
|
|
echo "Starting postgres in $_directory"
|
|
echo "Calling: $_pgctlPath start -D $_directory -o \"-p $_port -l $_logPath\""
|
|
$_pgctlPath start -D $_directory -o "-p $_port" -l $_logPath
|
|
}
|
|
|
|
|
|
function SetupPostgresServerExtensions()
|
|
{
|
|
local user=$1
|
|
local port=$2
|
|
local extensionName=$3
|
|
local extensionVersion=${4:-}
|
|
|
|
local versionString="";
|
|
if [ "$extensionVersion" != "" ]; then
|
|
versionString="WITH VERSION '${extensionVersion}'";
|
|
fi
|
|
|
|
echo "create extension $extensionName on port $port with version '${extensionVersion:-latest}'."
|
|
psql -p $port -U $user -d postgres -c "CREATE EXTENSION $extensionName $versionString CASCADE;"
|
|
|
|
psql -p $port -U $user -d postgres -c "SELECT * FROM pg_extension WHERE extname = '$extensionName';"
|
|
}
|
|
|
|
|
|
function InitDatabaseExtended()
|
|
{
|
|
local _directory=$1
|
|
local _preloadLibraries=$2
|
|
|
|
echo "Deleting directory $_directory"
|
|
rm -rf $_directory
|
|
mkdir -p $_directory
|
|
|
|
echo "Calling initdb for $_directory"
|
|
$(GetInitDB) -D $_directory
|
|
SetupPostgresConfigurations $_directory "$_preloadLibraries"
|
|
}
|
|
|
|
|
|
function SetupPostgresConfigurations()
|
|
{
|
|
local installdir=$1;
|
|
local preloadLibraries=$2;
|
|
requiredLibraries="pg_cron, ${preloadLibraries}";
|
|
echo shared_preload_libraries = \'$requiredLibraries\' | tee -a $installdir/postgresql.conf
|
|
echo cron.database_name = \'postgres\' | tee -a $installdir/postgresql.conf
|
|
echo ssl = off | tee -a $installdir/postgresql.conf
|
|
}
|