Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit989d23b

Browse files
committed
Detect unused steps in isolation specs and do some cleanup
This is useful for developers to find out if an isolation spec isover-engineered or if it needs more work by warning at the end of atest run if a step is not used, generating a failure with extra diffs.While on it, clean up all the specs which include steps not used in anypermutations to simplify them.Author: Michael PaquierReviewed-by: Asim Praveen, Melanie PlagemanDiscussion:https://postgr.es/m/20190819080820.GG18166@paquier.xyz
1 parent9903338 commit989d23b

9 files changed

+20
-11
lines changed

‎src/test/isolation/isolationtester.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ main(int argc, char **argv)
8181
puts("isolationtester (PostgreSQL) "PG_VERSION);
8282
exit(0);
8383
default:
84-
fprintf(stderr,"Usage: isolationtester [-n] [CONNINFO]\n");
84+
fprintf(stderr,"Usage: isolationtester [CONNINFO]\n");
8585
returnEXIT_FAILURE;
8686
}
8787
}
@@ -235,10 +235,23 @@ static int *piles;
235235
staticvoid
236236
run_testspec(TestSpec*testspec)
237237
{
238+
inti;
239+
238240
if (testspec->permutations)
239241
run_named_permutations(testspec);
240242
else
241243
run_all_permutations(testspec);
244+
245+
/*
246+
* Verify that all steps have been used, complaining about anything
247+
* defined but not used.
248+
*/
249+
for (i=0;i<testspec->nallsteps;i++)
250+
{
251+
if (!testspec->allsteps[i]->used)
252+
fprintf(stderr,"unused step name: %s\n",
253+
testspec->allsteps[i]->name);
254+
}
242255
}
243256

244257
/*
@@ -438,7 +451,11 @@ run_permutation(TestSpec *testspec, int nsteps, Step **steps)
438451

439452
printf("\nstarting permutation:");
440453
for (i=0;i<nsteps;i++)
454+
{
455+
/* Track the permutation as in-use */
456+
steps[i]->used= true;
441457
printf(" %s",steps[i]->name);
458+
}
442459
printf("\n");
443460

444461
/* Perform setup */

‎src/test/isolation/isolationtester.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ struct Session
2929
structStep
3030
{
3131
intsession;
32+
boolused;
3233
char*name;
3334
char*sql;
3435
char*errormsg;

‎src/test/isolation/specparse.y

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ step:
145145
$$ = pg_malloc(sizeof(Step));
146146
$$->name =$2;
147147
$$->sql =$3;
148+
$$->used =false;
148149
$$->errormsg =NULL;
149150
}
150151
;

‎src/test/isolation/specs/freeze-the-dead.spec

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ session "s1"
1919
step"s1_begin"{BEGIN; }
2020
step"s1_update"{UPDATEtab_freezeSETx=x+1WHEREid=3; }
2121
step"s1_commit"{COMMIT; }
22-
step"s1_vacuum"{VACUUMFREEZEtab_freeze; }
2322
step"s1_selectone"{
2423
BEGIN;
2524
SETLOCALenable_seqscan=false;
@@ -28,7 +27,6 @@ step "s1_selectone"{
2827
COMMIT;
2928
}
3029
step"s1_selectall"{SELECT*FROMtab_freezeORDERBYname,id; }
31-
step"s1_reindex"{REINDEXTABLEtab_freeze; }
3230

3331
session"s2"
3432
step"s2_begin"{BEGIN; }
@@ -40,7 +38,6 @@ session "s3"
4038
step"s3_begin"{BEGIN; }
4139
step"s3_key_share"{SELECTidFROMtab_freezeWHEREid=3FORKEYSHARE; }
4240
step"s3_commit"{COMMIT; }
43-
step"s3_vacuum"{VACUUMFREEZEtab_freeze; }
4441

4542
# This permutation verifies that a previous bug
4643
# https://postgr.es/m/E5711E62-8FDF-4DCA-A888-C200BF6B5742@amazon.com

‎src/test/isolation/specs/insert-conflict-do-nothing.spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ setup
3333
step"donothing2" {INSERTINTOints(key,val)VALUES(1,'donothing2')ONCONFLICTDONOTHING; }
3434
step"select2" {SELECT*FROMints; }
3535
step"c2" {COMMIT; }
36-
step"a2" {ABORT; }
3736

3837
# Regular case where one session block-waits on another to determine if it
3938
# should proceed with an insert or do nothing.

‎src/test/isolation/specs/insert-conflict-do-update-2.spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ setup
3232
step"insert2" {INSERTINTOupsert(key,payload)VALUES('FOOFOO','insert2')ONCONFLICT (lower(key))DOUPDATEsetkey=EXCLUDED.key,payload=upsert.payload||' updated by insert2'; }
3333
step"select2" {SELECT*FROMupsert; }
3434
step"c2" {COMMIT; }
35-
step"a2" {ABORT; }
3635

3736
# One session (session 2) block-waits on another (session 1) to determine if it
3837
# should proceed with an insert or update. The user can still usefully UPDATE

‎src/test/isolation/specs/insert-conflict-do-update.spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ setup
3030
step"insert2" {INSERTINTOupsert(key,val)VALUES(1,'insert2')ONCONFLICT (key)DOUPDATEsetval=upsert.val||' updated by insert2'; }
3131
step"select2" {SELECT*FROMupsert; }
3232
step"c2" {COMMIT; }
33-
step"a2" {ABORT; }
3433

3534
# One session (session 2) block-waits on another (session 1) to determine if it
3635
# should proceed with an insert or update. Notably, this entails updating a

‎src/test/isolation/specs/sequence-ddl.spec

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ setup { BEGIN; }
1515
step"s1alter"{ALTERSEQUENCEseq1MAXVALUE10;}
1616
step"s1alter2"{ALTERSEQUENCEseq1MAXVALUE20;}
1717
step"s1restart"{ALTERSEQUENCEseq1RESTARTWITH5;}
18-
step"s1setval"{SELECTsetval('seq1',5);}
1918
step"s1commit"{COMMIT;}
2019

2120
session"s2"

‎src/test/isolation/specs/tuplelock-upgrade-no-deadlock.spec

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ teardown
1919
session"s0"
2020
step"s0_begin" {begin; }
2121
step"s0_keyshare" {selectidfromtlu_jobwhereid=1forkeyshare;}
22-
step"s0_share" {selectidfromtlu_jobwhereid=1forshare;}
2322
step"s0_rollback" {rollback; }
2423

2524
session"s1"
@@ -28,7 +27,6 @@ step "s1_keyshare" { select id from tlu_job where id = 1 for key share;}
2827
step"s1_share" {selectidfromtlu_jobwhereid=1forshare; }
2928
step"s1_fornokeyupd" {selectidfromtlu_jobwhereid=1fornokeyupdate; }
3029
step"s1_update" {updatetlu_jobsetname='b'whereid=1; }
31-
step"s1_delete" {deletefromtlu_jobwhereid=1; }
3230
step"s1_savept_e" {savepoints1_e; }
3331
step"s1_savept_f" {savepoints1_f; }
3432
step"s1_rollback_e" {rollbacktos1_e; }
@@ -44,7 +42,6 @@ step "s2_for_update" { select id from tlu_job where id = 1 for update; }
4442
step"s2_update" {updatetlu_jobsetname='b'whereid=1; }
4543
step"s2_delete" {deletefromtlu_jobwhereid=1; }
4644
step"s2_rollback" {rollback; }
47-
step"s2_commit" {commit; }
4845

4946
session"s3"
5047
setup {begin; }

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp