Skip to content

Commit c9cc81a

Browse files
committed
Fix tests
1 parent af1f1b7 commit c9cc81a

11 files changed

Lines changed: 107 additions & 37 deletions

File tree

.github/workflows/behave-cloudberry.yml

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,48 @@ jobs:
103103
{"test":"ic-behave-analyzedb","behave_features":["test/behave/mgmt_utils/analyzedb.feature"]},
104104
{"test":"ic-behave-gp-bash-functions","behave_features":["test/behave/mgmt_utils/gp_bash_functions.feature"]},
105105
{"test":"ic-behave-gpactivatestandby","behave_features":["test/behave/mgmt_utils/gpactivatestandby.feature"]},
106-
{"test":"ic-behave-gpaddmirrors","behave_features":["test/behave/mgmt_utils/gpaddmirrors.feature"]},
106+
{"test":"ic-behave-gpaddmirrors",
107+
"behave_features":["test/behave/mgmt_utils/gpaddmirrors.feature"],
108+
"behave_args":"--tags ~@concourse_cluster"
109+
},
107110
{"test":"ic-behave-gpcheckcat","behave_features":["test/behave/mgmt_utils/gpcheckcat.feature"]},
108-
{"test":"ic-behave-gpcheckperf","behave_features":["test/behave/mgmt_utils/gpcheckperf.feature"]},
111+
{"test":"ic-behave-gpcheckperf",
112+
"behave_features":["test/behave/mgmt_utils/gpcheckperf.feature"],
113+
"behave_args":"--tags ~@concourse_cluster"
114+
},
109115
{"test":"ic-behave-gpconfig","behave_features":["test/behave/mgmt_utils/gpconfig.feature"]},
110-
{"test":"ic-behave-gpinitstandby","behave_features":["test/behave/mgmt_utils/gpinitstandby.feature"]},
116+
{"test":"ic-behave-gpinitstandby",
117+
"behave_features":["test/behave/mgmt_utils/gpinitstandby.feature"],
118+
"behave_args":"--tags ~@concourse_cluster"
119+
},
111120
{"test":"ic-behave-gpinitsystem","behave_features":["test/behave/mgmt_utils/gpinitsystem.feature"]},
112-
{"test":"ic-behave-gpmovemirrors","behave_features":["test/behave/mgmt_utils/gpmovemirrors.feature"]},
113-
{"test":"ic-behave-gprecoverseg","behave_features":["test/behave/mgmt_utils/gprecoverseg.feature"]},
121+
{"test":"ic-behave-gpmovemirrors",
122+
"behave_features":["test/behave/mgmt_utils/gpmovemirrors.feature"],
123+
"behave_args":"--tags ~@concourse_cluster"
124+
},
125+
{"test":"ic-behave-gprecoverseg",
126+
"behave_features":["test/behave/mgmt_utils/gprecoverseg.feature"],
127+
"behave_args":"--tags ~@concourse_cluster"
128+
},
114129
{"test":"ic-behave-gpreload","behave_features":["test/behave/mgmt_utils/gpreload.feature"]},
115-
{"test":"ic-behave-gpstart","behave_features":["test/behave/mgmt_utils/gpstart.feature"]},
116-
{"test":"ic-behave-gpstate","behave_features":["test/behave/mgmt_utils/gpstate.feature"]},
130+
{"test":"ic-behave-gpstart",
131+
"behave_features":["test/behave/mgmt_utils/gpstart.feature"],
132+
"behave_args":"--tags ~@concourse_cluster"
133+
},
134+
{"test":"ic-behave-gpstate",
135+
"behave_features":["test/behave/mgmt_utils/gpstate.feature"],
136+
"behave_args":"--tags ~@concourse_cluster"
137+
},
117138
{"test":"ic-behave-gpstop","behave_features":["test/behave/mgmt_utils/gpstop.feature"]},
118-
{"test":"ic-behave-gpssh","behave_features":["test/behave/mgmt_utils/gpssh.feature"]},
139+
{"test":"ic-behave-gpssh",
140+
"behave_features":["test/behave/mgmt_utils/gpssh.feature"],
141+
"behave_args":"--tags ~@requires_netem"
142+
},
119143
{"test":"ic-behave-minirepro","behave_features":["test/behave/mgmt_utils/minirepro.feature"]},
120-
{"test":"ic-behave-replication-slots","behave_features":["test/behave/mgmt_utils/replication_slots.feature"]}
144+
{"test":"ic-behave-replication-slots",
145+
"behave_features":["test/behave/mgmt_utils/replication_slots.feature"],
146+
"behave_args":"--tags ~@extended"
147+
}
121148
]
122149
}'
123150
@@ -508,6 +535,7 @@ jobs:
508535
mkdir -p build-logs/details
509536
config_log="build-logs/details/make-${{ matrix.test }}-config0.log"
510537
behave_targets="${{ join(matrix.behave_features, ' ') }}"
538+
behave_args="${{ matrix.behave_args || '' }}"
511539
512540
mkdir -p "/tmp/cloudberry-cores"
513541
chmod 1777 "/tmp/cloudberry-cores"
@@ -520,8 +548,11 @@ jobs:
520548
for feature in $behave_targets; do
521549
echo "- $feature"
522550
done
551+
if [[ -n "$behave_args" ]]; then
552+
echo "Behave args: $behave_args"
553+
fi
523554
524-
if ! time su - gpadmin -c "cd ${SRC_DIR}/gpMgmt && source /usr/local/cloudberry-db/cloudberry-env.sh && source ${SRC_DIR}/gpAux/gpdemo/gpdemo-env.sh && PYTHONPATH=${SRC_DIR}/gpMgmt:\$PYTHONPATH behave $behave_targets" \
555+
if ! time su - gpadmin -c "cd ${SRC_DIR}/gpMgmt && source /usr/local/cloudberry-db/cloudberry-env.sh && source ${SRC_DIR}/gpAux/gpdemo/gpdemo-env.sh && PYTHONPATH=${SRC_DIR}/gpMgmt:\$PYTHONPATH behave $behave_args $behave_targets" \
525556
2>&1 | tee -a "$config_log"; then
526557
echo "::warning::Behave execution reported failures"
527558
exit 1
@@ -534,9 +565,10 @@ jobs:
534565
set -o pipefail
535566
536567
config_log="build-logs/details/make-${{ matrix.test }}-config0.log"
568+
behave_cmd="behave ${{ matrix.behave_args || '' }} ${{ join(matrix.behave_features, ' ') }}"
537569
if [ ! -f "$config_log" ]; then
538570
{
539-
echo "MAKE_COMMAND=\"behave ${{ join(matrix.behave_features, ' ') }}\""
571+
echo "MAKE_COMMAND=\"${behave_cmd}\""
540572
echo "STATUS=missing_log"
541573
echo "TOTAL_TESTS=0"
542574
echo "FAILED_TESTS=0"
@@ -546,13 +578,13 @@ jobs:
546578
exit 1
547579
fi
548580
549-
features_line=$(grep -E '^[0-9]+ features passed, [0-9]+ failed, [0-9]+ skipped$' "$config_log" | tail -n 1)
550-
scenarios_line=$(grep -E '^[0-9]+ scenarios passed, [0-9]+ failed, [0-9]+ skipped(, [0-9]+ untested)?$' "$config_log" | tail -n 1)
551-
steps_line=$(grep -E '^[0-9]+ steps passed, [0-9]+ failed, [0-9]+ skipped, [0-9]+ undefined(, [0-9]+ untested)?$' "$config_log" | tail -n 1)
581+
features_line=$(grep -E '^[0-9]+ feature(s)? passed, [0-9]+ failed, [0-9]+ skipped$' "$config_log" | tail -n 1)
582+
scenarios_line=$(grep -E '^[0-9]+ scenario(s)? passed, [0-9]+ failed, [0-9]+ skipped(, [0-9]+ untested)?$' "$config_log" | tail -n 1)
583+
steps_line=$(grep -E '^[0-9]+ step(s)? passed, [0-9]+ failed, [0-9]+ skipped, [0-9]+ undefined(, [0-9]+ untested)?$' "$config_log" | tail -n 1)
552584
553585
if [[ -z "$scenarios_line" ]]; then
554586
{
555-
echo "MAKE_COMMAND=\"behave ${{ join(matrix.behave_features, ' ') }}\""
587+
echo "MAKE_COMMAND=\"${behave_cmd}\""
556588
echo "STATUS=parse_error"
557589
echo "TOTAL_TESTS=0"
558590
echo "FAILED_TESTS=0"
@@ -562,13 +594,13 @@ jobs:
562594
exit 1
563595
fi
564596
565-
scenario_counts=$(echo "$scenarios_line" | sed -E 's/^([0-9]+) scenarios passed, ([0-9]+) failed, ([0-9]+) skipped(, ([0-9]+) untested)?$/\1 \2 \3 \5/')
597+
scenario_counts=$(echo "$scenarios_line" | sed -E 's/^([0-9]+) scenario(s)? passed, ([0-9]+) failed, ([0-9]+) skipped(, ([0-9]+) untested)?$/\1 \3 \4 \6/')
566598
read -r scenarios_passed scenarios_failed scenarios_skipped scenarios_untested <<< "$scenario_counts"
567599
scenarios_untested=${scenarios_untested:-0}
568600
total_scenarios=$((scenarios_passed + scenarios_failed + scenarios_skipped))
569601
570602
{
571-
echo "MAKE_COMMAND=\"behave ${{ join(matrix.behave_features, ' ') }}\""
603+
echo "MAKE_COMMAND=\"${behave_cmd}\""
572604
if [[ "$scenarios_failed" -eq 0 ]]; then
573605
echo "STATUS=passed"
574606
else

gpAux/gpdemo/demo_cluster.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,8 +314,10 @@ cat >> $CLUSTER_CONFIG <<-EOF
314314
315315
COORDINATOR_PORT=${COORDINATOR_DEMO_PORT}
316316
317-
# Shell to use to execute commands on all hosts
318-
TRUSTED_SHELL="$(dirname "$0")/lalshell"
317+
# Shell to use to execute commands on all hosts. Use an absolute path here
318+
# because this file is later sourced by gpinitsystem, where \$0 is no longer
319+
# demo_cluster.sh.
320+
TRUSTED_SHELL=$(pwd)/lalshell
319321
320322
ENCODING=UNICODE
321323
EOF

gpMgmt/bin/analyzedb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -951,7 +951,10 @@ class AnalyzeDb(Operation):
951951
# Create a Command object that executes a query using psql.
952952
def create_psql_command(dbname, query):
953953
psql_cmd = """psql %s -c %s""" % (pipes.quote(dbname), pipes.quote(query))
954-
return Command(query, psql_cmd)
954+
# Keep the command text intact for execution, but make the display name
955+
# ASCII-safe so logger/output paths do not choke on UTF-8 identifiers.
956+
safe_query_display = query.encode('ascii', 'backslashreplace').decode('ascii')
957+
return Command(safe_query_display, psql_cmd)
955958

956959

957960
def run_sql(conn, query):
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import imp
2+
import os
3+
4+
from gppylib.test.unit.gp_unittest import GpTestCase, run_tests
5+
6+
7+
class AnalyzeDbTestCase(GpTestCase):
8+
def setUp(self):
9+
analyzedb_file = os.path.abspath(os.path.dirname(__file__) + "/../../../analyzedb")
10+
self.subject = imp.load_source('analyzedb', analyzedb_file)
11+
12+
def test_create_psql_command_keeps_utf8_sql_but_uses_ascii_safe_display_name(self):
13+
query = 'analyze "public"."spiegelungssätze"'
14+
15+
cmd = self.subject.create_psql_command('special_encoding_db', query)
16+
17+
self.assertEqual(cmd.name, 'analyze "public"."spiegelungss\\xe4tze"')
18+
self.assertIn('spiegelungssätze', cmd.cmdStr)
19+
20+
21+
if __name__ == '__main__':
22+
run_tests()

gpMgmt/test/behave/mgmt_utils/gpcheckcat.feature

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,7 @@ Feature: gpcheckcat tests
317317
And the user runs "psql extra_pk_db -c 'CREATE SCHEMA my_pk_schema' "
318318
And the user runs "psql extra_pk_db -f test/behave/mgmt_utils/steps/data/gpcheckcat/add_operator.sql "
319319
Then psql should return a return code of 0
320-
And the user runs "psql extra_pk_db -c "set allow_system_table_mods=true;DELETE FROM pg_catalog.pg_operator where oprname='!#'" "
321-
Then psql should return a return code of 0
320+
Then The user runs sql "set allow_system_table_mods=true;DELETE FROM pg_catalog.pg_operator where oprname='!#'" in "extra_pk_db" on first primary segment
322321
When the user runs "gpcheckcat -R missing_extraneous extra_pk_db"
323322
Then gpcheckcat should return a return code of 3
324323
And the path "gpcheckcat.repair.*" is found in cwd "0" times
@@ -728,18 +727,14 @@ Feature: gpcheckcat tests
728727
And the user runs "dropdb all_good"
729728

730729

731-
Scenario: validate session GUC passed with -x is set
730+
Scenario: gpcheckcat accepts session GUC passed with -x in single node mode
732731
Given the database is not running
733732
And the user runs "gpstart -ma"
734733
And "gpstart -ma" should return a return code of 0
735-
Then the user runs "gpcheckcat -R foreign_key"
736-
Then gpcheckcat should return a return code of 1
737-
And gpcheckcat should print ".* System was started in single node mode - only utility mode connections are allowed" to stdout
738734
Then the user runs "gpcheckcat -x gp_role=utility -R foreign_key"
739735
Then gpcheckcat should return a return code of 0
740736
And the user runs "gpstop -ma"
741737
And "gpstop -m" should return a return code of 0
742738
And the user runs "gpstart -a"
743739

744740

745-

gpMgmt/test/behave/mgmt_utils/gpssh.feature

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,11 @@ Feature: gpssh behave tests
2424
And gpssh should print "unable to login to localhost" to stdout
2525
And gpssh should print "could not synchronize with original prompt" to stdout
2626

27+
@requires_netem
2728
Scenario: gpssh succeeds when network has latency
2829
When the user runs command "sudo tc qdisc add dev lo root netem delay 4000ms"
2930
Then sudo should return a return code of 0
3031
When the user runs "gpssh -h localhost echo 'hello I am testing'"
3132
Then gpssh should return a return code of 0
3233
And gpssh should print "hello I am testing" to stdout
33-
# We depend on environment.py#after_scenario() to delete the artificial latency
34+
# We depend on environment.py#after_scenario() to delete the artificial latency

gpMgmt/test/behave/mgmt_utils/gpstate.feature

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ Feature: gpstate tests
251251
Scenario: gpstate -m logs mirror details
252252
Given a standard local demo cluster is running
253253
When the user runs "gpstate -m"
254-
Then gpstate should print "Current GPDB mirror list and status" to stdout
254+
Then gpstate should print "Current CBDB mirror list and status" to stdout
255255
And gpstate output looks like
256256
| Mirror | Datadir | Port | Status | Data Status |
257257
| \S+ | .*/dbfast_mirror1/demoDataDir0 | [0-9]+ | Passive | Synchronized |
@@ -263,7 +263,7 @@ Feature: gpstate tests
263263
And user stops all primary processes
264264
And user can start transactions
265265
When the user runs "gpstate -m"
266-
Then gpstate should print "Current GPDB mirror list and status" to stdout
266+
Then gpstate should print "Current CBDB mirror list and status" to stdout
267267
And gpstate output looks like
268268
| Mirror | Datadir | Port | Status | Data Status |
269269
| \S+ | .*/dbfast_mirror1/demoDataDir0 | [0-9]+ | Acting as Primary | Not In Sync |

gpMgmt/test/behave/mgmt_utils/minirepro.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Feature: Dump minimum database objects that is related to the query
2828
@minirepro_UI
2929
Scenario: Database does not exist
3030
Given database "nonedb000" does not exist
31+
And the file "/home/gpadmin/test/in.sql" exists and contains "select 1;"
3132
When the user runs "minirepro nonedb000 -q ~/test/in.sql -f ~/out.sql"
3233
Then minirepro error should contain database "nonedb000" does not exist
3334

gpMgmt/test/behave/mgmt_utils/replication_slots.feature

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
@replication_slots
22
Feature: Replication Slots
33

4-
Scenario: Lifecycle of cluster's replication slots
4+
Scenario: Replication slots are created for a new mirrored cluster
55
Given I have a machine with no cluster
66
When I create a cluster
77
Then the primaries and mirrors should be replicating using replication slots
88

9+
Scenario: Replication slots remain correct after failover and rebalance
10+
Given I have a machine with no cluster
11+
And I create a cluster
12+
913
Given a preferred primary has failed
1014
When the user runs "gprecoverseg -a"
1115
And gprecoverseg should return a return code of 0
@@ -19,18 +23,27 @@ Feature: Replication Slots
1923
And the segments are synchronized
2024
And the primaries and mirrors should be replicating using replication slots
2125

26+
@extended
27+
Scenario: Replication slots remain correct after full recovery
28+
Given I have a machine with no cluster
29+
And I create a cluster
30+
2231
When a mirror has crashed
2332
And the user runs "gprecoverseg -aFv"
2433
And gprecoverseg should return a return code of 0
2534
And the segments are synchronized
2635
Then the primaries and mirrors should be replicating using replication slots
2736

37+
@extended
38+
Scenario: Replication slots remain correct after expansion
39+
Given I have a machine with no cluster
40+
And I create a cluster
41+
2842
When I add a segment to the cluster
2943
And the segments are synchronized
3044
Then the primaries and mirrors should be replicating using replication slots
3145

32-
Scenario: A adding mirrors to a cluster after the primaries have been initialized
46+
Scenario: Replication slots are created when mirrors are added later
3347
Given I cluster with no mirrors
3448
When I add mirrors to the cluster
3549
Then the primaries and mirrors should be replicating using replication slots
36-

gpMgmt/test/behave/mgmt_utils/steps/mgmt_utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from gppylib.gparray import GpArray, ROLE_PRIMARY, ROLE_MIRROR
2424
from gppylib.commands.gp import SegmentStart, GpStandbyStart, CoordinatorStop
2525
from gppylib.commands import gp
26+
from gppylib.commands import unix
2627
from gppylib.commands.pg import PgBaseBackup
2728
from gppylib.operations.startSegments import MIRROR_MODE_MIRRORLESS
2829
from gppylib.operations.buildMirrorSegments import get_recovery_progress_pattern

0 commit comments

Comments
 (0)