《测试PostgreSQL代码的故障注入(24页).pdf》由会员分享,可在线阅读,更多相关《测试PostgreSQL代码的故障注入(24页).pdf(24页珍藏版)》请在三个皮匠报告上搜索。
1、Fault injection to test PostgreSQL codeAsim R P apraveenpivotal.io Pune,IndiaAgenda What is lacking in current testing frameworks?What is fault injection?Proposal to inject faults Tests to demonstrate proposed faultinjector patchTesting frameworks in PostgreSQL pg_regress(src/test/regress)A test is
2、written as a.sql file Expected output is saved as an answer file(.out)pg_regress runs a.sql file,compares the output with the answer isolation(src/test/isolation)tests concurrent transactions .spec file-SQL commands within each transaction and how to interleave themisolation:test that select waits f
3、or altersession“s1”setup BEGIN ISOLATION LEVEL READ COMMITTED;step“alter1”ALTER TABLE test ADD RENAME TO test2;step“commit1”COMMIT;session“s2”setup SET default_transaction_isolation=read committed;step“select2”SELECT*from test;permutation“alter1”“s2”“commit1”Testing frameworks in PostgreSQL TAP-test
4、s written in perl(Test:More)Orchestrate a cluster-master and one or more standby initdb,start/stop cluster,etc.src/test/perl/README src/test/modules(not run in CI)modular testing of a specific component,e.g.planner src/test/modules/READMEWhat is lacking in PostgreSQL tests?Test that a backend is kil
5、led after writing commit record but before updating the transaction status in pg_clog Is synchronous replication really synchronous?Was a cached plan reused?Anything comes to your mind?Fault injection Unconference discussion at PGcon 2019 in Ottawa Already being used in Greenplum Patch proposed on p
6、gsql-hackers:https:/www.postgresql.org/message-id/flat/CANXE4TdxdESX1jKw48xet-5GvBFVSq%3D4cgNeioTQff372KO45A%Fault point(./configure CPPFLAGS=-DFAULT_INJECTOR)Fault point-macro definitionSet a fault using its name CREATE EXTENSION faultinjector;Enable the“heap_insert”fault when a tuple is inserted i