Skip to content

Commit

Permalink
NO-ISSUE: Change the PostgreSQL port for unit tests to support runnin…
Browse files Browse the repository at this point in the history
…g both unit tests and the subsystem on the same machine. (#6987)
  • Loading branch information
eliorerz authored Nov 25, 2024
1 parent d8cdc34 commit 8dc67a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ display-coverage:

run-db-container:
$(CONTAINER_COMMAND) ps -q --filter "name=postgres" | xargs -r $(CONTAINER_COMMAND) kill && sleep 3
$(CONTAINER_COMMAND) run -d --rm --tmpfs /var/lib/pgsql/data --name postgres -e POSTGRESQL_ADMIN_PASSWORD=admin -e POSTGRESQL_MAX_CONNECTIONS=10000 -p 127.0.0.1:5432:5432 \
$(CONTAINER_COMMAND) run -d --rm --tmpfs /var/lib/pgsql/data --name postgres -e POSTGRESQL_ADMIN_PASSWORD=admin -e POSTGRESQL_MAX_CONNECTIONS=10000 -p 127.0.0.1:5433:5432 \
$(PSQL_IMAGE)
timeout 5m ./hack/wait_for_postgres.sh

Expand Down
2 changes: 1 addition & 1 deletion hack/start_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ mkdir -p /tmp/postgres/data
mkdir -p /tmp/postgres/sockets

initdb -D /tmp/postgres/data -U postgres
pg_ctl -D /tmp/postgres/data -l /tmp/postgres/logfile -o'-k /tmp/postgres/sockets' start
pg_ctl -D /tmp/postgres/data -l /tmp/postgres/logfile -o'-k /tmp/postgres/sockets -p 5433' start
2 changes: 1 addition & 1 deletion hack/wait_for_postgres.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -euo pipefail
PG_USER=postgres
PG_DATABASE=postgres
PG_HOST=127.0.0.1
PG_PORT=5432
PG_PORT=5433
export PGPASSWORD=admin

if [ -x "$(command -v pg_isready)" ]; then
Expand Down
14 changes: 7 additions & 7 deletions internal/common/common_unitest_db.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@ import (
* k8s cluster
* if k8s connection is not available try to run it as docker container
When SKIP_UT_DB env var is set localhost:5432 is being used.
When SKIP_UT_DB env var is set localhost:5433 is being used.
*/
const (
dbDockerName = "ut-postgres"
dbDefaultPort = "5432"
dbDefaultPort = "5433"

k8sNamespace = "assisted-installer"
)
Expand Down Expand Up @@ -134,9 +134,9 @@ func (c *K8SDBContext) Create() error {
Image: "quay.io/sclorg/postgresql-12-c8s",
Ports: []corev1.ContainerPort{
{
Name: "tcp-5432",
Name: "tcp-5433",
Protocol: corev1.ProtocolTCP,
ContainerPort: 5432,
ContainerPort: 5433,
},
},
Env: []corev1.EnvVar{
Expand All @@ -148,7 +148,7 @@ func (c *K8SDBContext) Create() error {
ReadinessProbe: &corev1.Probe{
ProbeHandler: corev1.ProbeHandler{
TCPSocket: &corev1.TCPSocketAction{
Port: intstr.FromInt(5432),
Port: intstr.FromInt(5433),
},
},
},
Expand Down Expand Up @@ -201,9 +201,9 @@ func (c *K8SDBContext) Create() error {
Spec: corev1.ServiceSpec{
Ports: []corev1.ServicePort{
{
Port: 5432,
Port: 5433,
Protocol: corev1.ProtocolTCP,
Name: "tcp-5432",
Name: "tcp-5433",
},
},
Type: corev1.ServiceTypeLoadBalancer,
Expand Down

0 comments on commit 8dc67a1

Please sign in to comment.