File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Generate Test Fixtures
2+
3+ on :
4+ workflow_dispatch :
5+ schedule :
6+ - cron : ' 0 6 * * 1' # weekly Monday 06:00 UTC
7+
8+ env :
9+ CACHE_IMAGE : ghcr.io/${{ github.repository_owner }}/openlogreplicator:ci
10+
11+ jobs :
12+ generate :
13+ runs-on : ubuntu-latest
14+ timeout-minutes : 45
15+ permissions :
16+ packages : write
17+ steps :
18+ - uses : actions/checkout@v4
19+
20+ - uses : docker/setup-buildx-action@v3
21+
22+ - name : Log in to ghcr.io
23+ uses : docker/login-action@v3
24+ with :
25+ registry : ghcr.io
26+ username : ${{ github.actor }}
27+ password : ${{ secrets.GITHUB_TOKEN }}
28+
29+ - name : Build OLR image
30+ uses : docker/build-push-action@v6
31+ with :
32+ context : .
33+ file : Dockerfile.dev
34+ load : true
35+ tags : olr-dev:latest
36+ cache-from : type=registry,ref=${{ env.CACHE_IMAGE }}
37+ cache-to : type=registry,ref=${{ env.CACHE_IMAGE }},mode=max
38+ build-args : |
39+ BUILD_TYPE=Debug
40+ UIDOLR=1001
41+ GIDOLR=1001
42+ WITHORACLE=1
43+ WITHKAFKA=1
44+ WITHPROTOBUF=1
45+ WITHPROMETHEUS=1
46+ WITHTESTS=1
47+
48+ - name : Start containers
49+ run : make up
50+
51+ - name : Generate all fixtures
52+ run : make testdata
53+
54+ - name : Upload test fixtures
55+ uses : actions/upload-artifact@v4
56+ with :
57+ name : test-fixtures
58+ path : |
59+ tests/1-schema/
60+ tests/2-redo/
61+ tests/3-expected/
62+ retention-days : 90
Original file line number Diff line number Diff line change 1+ name : Run Tests
2+
3+ on :
4+ push :
5+ branches : [master]
6+ pull_request :
7+ branches : [master]
8+
9+ env :
10+ CACHE_IMAGE : ghcr.io/${{ github.repository_owner }}/openlogreplicator:ci
11+
12+ jobs :
13+ test :
14+ runs-on : ubuntu-latest
15+ timeout-minutes : 15
16+ permissions :
17+ packages : write
18+ steps :
19+ - uses : actions/checkout@v4
20+
21+ - uses : docker/setup-buildx-action@v3
22+
23+ - name : Log in to ghcr.io
24+ uses : docker/login-action@v3
25+ with :
26+ registry : ghcr.io
27+ username : ${{ github.actor }}
28+ password : ${{ secrets.GITHUB_TOKEN }}
29+
30+ - name : Build OLR image
31+ uses : docker/build-push-action@v6
32+ with :
33+ context : .
34+ file : Dockerfile.dev
35+ load : true
36+ tags : olr-dev:latest
37+ cache-from : type=registry,ref=${{ env.CACHE_IMAGE }}
38+ cache-to : type=registry,ref=${{ env.CACHE_IMAGE }},mode=max
39+ build-args : |
40+ BUILD_TYPE=Debug
41+ UIDOLR=1001
42+ GIDOLR=1001
43+ WITHORACLE=1
44+ WITHKAFKA=1
45+ WITHPROTOBUF=1
46+ WITHPROMETHEUS=1
47+ WITHTESTS=1
48+
49+ - name : Download test fixtures
50+ uses : dawidd6/action-download-artifact@v6
51+ with :
52+ workflow : generate-fixtures.yaml
53+ name : test-fixtures
54+ path : tests/
55+
56+ - name : Run tests
57+ run : |
58+ docker compose up -d olr --wait
59+ make test
Original file line number Diff line number Diff line change @@ -127,6 +127,10 @@ if (WITH_PROTOBUF)
127127endif ()
128128
129129add_subdirectory (src )
130+ if (WITH_TESTS)
131+ enable_testing ()
132+ add_subdirectory (tests )
133+ endif ()
130134
131135target_link_libraries (OpenLogReplicator Threads::Threads )
132136
Original file line number Diff line number Diff line change 1+ -- basic-crud.sql: Simple INSERT/UPDATE/DELETE scenario for fixture generation.
2+ -- Run as PDB user (e.g., olr_test/olr_test@//localhost:1521/FREEPDB1)
3+ --
4+ -- Outputs: FIXTURE_SCN_START: <scn> and FIXTURE_SCN_END: <scn>
5+ -- The orchestrator script parses these and handles log switches separately
6+ -- (ALTER SYSTEM SWITCH LOGFILE must run from CDB root, not PDB).
7+
8+ SET SERVEROUTPUT ON
9+ SET FEEDBACK OFF
10+ SET ECHO OFF
11+
12+ -- Setup: drop and recreate table
13+ DECLARE
14+ v_table_exists NUMBER ;
15+ BEGIN
16+ SELECT COUNT (* ) INTO v_table_exists
17+ FROM user_tables WHERE table_name = ' TEST_CDC' ;
18+ IF v_table_exists > 0 THEN
19+ EXECUTE IMMEDIATE ' DROP TABLE TEST_CDC PURGE' ;
20+ END IF;
21+ END;
22+ /
23+
24+ CREATE TABLE TEST_CDC (
25+ id NUMBER PRIMARY KEY ,
26+ name VARCHAR2 (100 ),
27+ val NUMBER
28+ );
29+
30+ ALTER TABLE TEST_CDC ADD SUPPLEMENTAL LOG DATA (ALL) COLUMNS;
31+
32+ -- Record start SCN
33+ DECLARE
34+ v_start_scn NUMBER ;
35+ BEGIN
36+ SELECT current_scn INTO v_start_scn FROM v$database;
37+ DBMS_OUTPUT .PUT_LINE (' FIXTURE_SCN_START: ' || v_start_scn);
38+ END;
39+ /
40+
41+ -- DML: INSERTs
42+ INSERT INTO TEST_CDC VALUES (1 , ' Alice' , 100 );
43+ INSERT INTO TEST_CDC VALUES (2 , ' Bob' , 200 );
44+ INSERT INTO TEST_CDC VALUES (3 , ' Charlie' , 300 );
45+ COMMIT ;
46+
47+ -- DML: UPDATE
48+ UPDATE TEST_CDC SET val = 150 , name = ' Alice Updated' WHERE id = 1 ;
49+ COMMIT ;
50+
51+ -- DML: DELETE
52+ DELETE FROM TEST_CDC WHERE id = 2 ;
53+ COMMIT ;
54+
55+ -- Record end SCN
56+ DECLARE
57+ v_end_scn NUMBER ;
58+ BEGIN
59+ SELECT current_scn INTO v_end_scn FROM v$database;
60+ DBMS_OUTPUT .PUT_LINE (' FIXTURE_SCN_END: ' || v_end_scn);
61+ END;
62+ /
63+
64+ EXIT
Original file line number Diff line number Diff line change 1+ include (FetchContent )
2+ FetchContent_Declare (
3+ googletest
4+ URL https://github.com/google/googletest/releases/download/v1.15.2/googletest-1.15.2.tar.gz
5+ URL_HASH SHA256=7b42b4d6ed48810c5362c265a17faebe90dc2373c885e5216439d37927f02926
6+ DOWNLOAD_EXTRACT_TIMESTAMP TRUE
7+ )
8+ set (gtest_force_shared_crt ON CACHE BOOL "" FORCE )
9+ set (INSTALL_GTEST OFF CACHE BOOL "" FORCE )
10+ FetchContent_MakeAvailable (googletest)
11+
12+ add_executable (olr_tests
13+ test_pipeline.cpp
14+ )
15+
16+ target_compile_definitions (olr_tests PRIVATE
17+ OLR_BINARY_PATH= "$<TARGET_FILE :OpenLogReplicator >"
18+ OLR_TEST_DATA_DIR= "${CMAKE_CURRENT_SOURCE_DIR} "
19+ )
20+
21+ target_link_libraries (olr_tests PRIVATE GTest::gtest_main )
22+ add_dependencies (olr_tests OpenLogReplicator )
23+
24+ include (GoogleTest )
25+ gtest_discover_tests (olr_tests DISCOVERY_MODE PRE_TEST )
You can’t perform that action at this time.
0 commit comments