commit_validator: validate according to recorded sync config version

Summary: `commit_validator` cannot just use latest `CommitSyncConfig` to validate how a commit was synced between large and small repos. Instead, when querying `synced_commit_mapping`, it needs to pay attention to `version_name` used to create the mapping. Then it needs to query `LiveCommitSyncConfig` for a config of this version and use it as a validation basis.

Reviewed By: StanislavGlebik

Differential Revision: D22525606

fbshipit-source-id: 6c32063b18461d592d931316aec7fd041bcc1ae4
This commit is contained in:
Kostia Balytskyi 2020-07-21 10:17:02 -07:00 committed by Facebook GitHub Bot
parent 661d31bd21
commit dd4fcd7aee
5 changed files with 26 additions and 66 deletions

View File

@ -32,7 +32,7 @@
"direction": "small_to_large"
}
],
"version_name": "TEST_VERSION_NAME_LIVE"
"version_name": "TEST_VERSION_NAME"
},
{
"large_repo_id": 0,
@ -64,10 +64,10 @@
"direction": "small_to_large"
}
],
"version_name": "TEST_VERSION_NAME_LIVE_OLD"
"version_name": "TEST_VERSION_NAME_OLD"
}
],
"current_version": "TEST_VERSION_NAME_LIVE"
"current_version": "TEST_VERSION_NAME"
}
}
}

View File

@ -30,7 +30,7 @@
"direction": "small_to_large"
}
],
"version_name": "TEST_VERSION_NAME_LIVE"
"version_name": "TEST_VERSION_NAME"
}
}
}

View File

@ -22,6 +22,8 @@ function validate_commit_sync() {
shift
"$COMMIT_VALIDATOR" "${COMMON_ARGS[@]}" --debug --repo-id "$REPOIDLARGE" \
--mononoke-config-path "$TESTTMP/mononoke-config" \
--test-instance \
--local-configerator-path="$TESTTMP/configerator" \
--master-bookmark=master_bookmark \
once --entry-id "$entry_id" "$@"
}

View File

@ -24,6 +24,7 @@ Disable bookmarks cache because bookmarks are modified by two separate processes
> EOF
$ setup_commitsyncmap
$ setup_configerator_configs
-- setup hg server repos
@ -179,60 +180,16 @@ Disable bookmarks cache because bookmarks are modified by two separate processes
e0cb430152c2dcc47b93a516344e3814ece60d4b fbsource commit 10
-- Validate the synced entries
$ REPOIDLARGE=0 validate_commit_sync 17
* enabled stdlog * (glob)
* using repo * (glob)
* using repo * (glob)
* using repo * (glob)
* Validation helpers are: * (glob)
* BookmarkUpdateLogEntry 17 has been expanded into 1 commits (glob)
* Mapping small cs_ids * (glob)
* Commit * is rewritten as follows:* (glob)
* Preparing entry Entry 17(0/1); book: master_bookmark; cs_id: ChangesetId(Blake2(*)); remaining queue: 0 (glob)
* validating topological order * (glob)
* done validating topological order * (glob)
$ REPOIDLARGE=0 validate_commit_sync 17 |& grep "Validated entry"
* Validated entry: Entry 17(0/1) (glob)
$ REPOIDLARGE=0 validate_commit_sync 18
* enabled stdlog * (glob)
* using repo * (glob)
* using repo * (glob)
* using repo * (glob)
* Validation helpers are: * (glob)
* BookmarkUpdateLogEntry 18 has been expanded into 1 commits (glob)
* Mapping small cs_ids * (glob)
* Commit * is rewritten as follows: * (glob)
* Preparing entry Entry 18(0/1); book: fbsource/somebook; cs_id: ChangesetId(Blake2(*)); remaining queue: 0 (glob)
* validating topological order * (glob)
* done validating topological order * (glob)
$ REPOIDLARGE=0 validate_commit_sync 18 |& grep "Validated entry"
* Validated entry: Entry 18(0/1) (glob)
$ REPOIDLARGE=0 validate_commit_sync 19
* enabled stdlog * (glob)
* using repo * (glob)
* using repo * (glob)
* using repo * (glob)
* Validation helpers are: * (glob)
* BookmarkUpdateLogEntry 19 has been expanded into 1 commits (glob)
* Mapping small cs_ids * (glob)
* Commit * is rewritten as follows: * (glob)
* Preparing entry Entry 19(0/1); book: master_bookmark; cs_id: ChangesetId(Blake2(*)); remaining queue: 0 (glob)
* validating topological order * (glob)
* done validating topological order * (glob)
$ REPOIDLARGE=0 validate_commit_sync 19 |& grep "Validated entry"
* Validated entry: Entry 19(0/1) (glob)
$ REPOIDLARGE=0 validate_commit_sync 21
* enabled stdlog * (glob)
* using repo * (glob)
* using repo * (glob)
* using repo * (glob)
* Validation helpers are: * (glob)
* BookmarkUpdateLogEntry 21 has been expanded into 1 commits (glob)
* Mapping small cs_ids * (glob)
* Commit * is rewritten as follows: * (glob)
* Preparing entry Entry 21(0/1); book: master_bookmark; cs_id: ChangesetId(Blake2(*)); remaining queue: 0 (glob)
* validating topological order for *<->* (glob)
* done validating topological order for *<->* (glob)
$ REPOIDLARGE=0 validate_commit_sync 21 |& grep "Validated entry"
* Validated entry: Entry 21(0/1) (glob)
Query synced commit mapping, check that automatically inserted mappings have version_name

View File

@ -24,6 +24,7 @@ Disable bookmarks cache because bookmarks are modified by two separate processes
> EOF
$ setup_commitsyncmap
$ setup_configerator_configs
-- setup hg server repos
@ -191,7 +192,7 @@ Check that we pay attention to missing files in large repo, but present in small
$ FBSOURCE_MISSING_IN_LARGE_BONSAI=$(get_bonsai_bookmark 1 missing_in_large)
-- fake a commit sync mapping between fbsource master and corrupted commit
$ sqlite3 "$TESTTMP/monsql/sqlite_dbs" "INSERT INTO synced_commit_mapping (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id) VALUES (1, X'$FBSOURCE_MISSING_IN_LARGE_BONSAI', 0, X'$MEGAREPO_MISSING_IN_LARGE_BONSAI')"
$ sqlite3 "$TESTTMP/monsql/sqlite_dbs" "INSERT INTO synced_commit_mapping (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id, sync_map_version_name) VALUES (1, X'$FBSOURCE_MISSING_IN_LARGE_BONSAI', 0, X'$MEGAREPO_MISSING_IN_LARGE_BONSAI', 'TEST_VERSION_NAME')"
-- run the validator one more time, expect to fail and say it's because of contents
$ REPOIDLARGE=0 validate_commit_sync 10 |& grep "present in fbs-mon, but missing in meg-mon"
@ -233,11 +234,11 @@ attention to more than just the last commit (successful validation of many commi
-- fake a commit sync mapping between the new commits
$ sqlite3 "$TESTTMP/monsql/sqlite_dbs" << ENDOFINSERT
> INSERT INTO synced_commit_mapping
> (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id)
> (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id, sync_map_version_name)
> VALUES
> (1, X'$FBSOURCE_C1_BONSAI', 0, X'$MEGAREPO_C1_BONSAI'),
> (1, X'$FBSOURCE_C2_BONSAI', 0, X'$MEGAREPO_C2_BONSAI'),
> (1, X'$FBSOURCE_C3_BONSAI', 0, X'$MEGAREPO_C3_BONSAI');
> (1, X'$FBSOURCE_C1_BONSAI', 0, X'$MEGAREPO_C1_BONSAI', 'TEST_VERSION_NAME'),
> (1, X'$FBSOURCE_C2_BONSAI', 0, X'$MEGAREPO_C2_BONSAI', 'TEST_VERSION_NAME'),
> (1, X'$FBSOURCE_C3_BONSAI', 0, X'$MEGAREPO_C3_BONSAI', 'TEST_VERSION_NAME');
> ENDOFINSERT
-- run the validator, check that commits are eqiuvalent
@ -282,11 +283,11 @@ attention to more than just the last commit (failed validation of inner commit)
-- fake a commit sync mapping between the new commits
$ sqlite3 "$TESTTMP/monsql/sqlite_dbs" << ENDOFINSERT
> INSERT INTO synced_commit_mapping
> (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id)
> (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id, sync_map_version_name)
> VALUES
> (1, X'$FBSOURCE_C1_BONSAI', 0, X'$MEGAREPO_C1_BONSAI'),
> (1, X'$FBSOURCE_C2_BONSAI', 0, X'$MEGAREPO_C2_BONSAI'),
> (1, X'$FBSOURCE_C3_BONSAI', 0, X'$MEGAREPO_C3_BONSAI');
> (1, X'$FBSOURCE_C1_BONSAI', 0, X'$MEGAREPO_C1_BONSAI', 'TEST_VERSION_NAME'),
> (1, X'$FBSOURCE_C2_BONSAI', 0, X'$MEGAREPO_C2_BONSAI', 'TEST_VERSION_NAME'),
> (1, X'$FBSOURCE_C3_BONSAI', 0, X'$MEGAREPO_C3_BONSAI', 'TEST_VERSION_NAME');
> ENDOFINSERT
-- run the validator, check that commits are eqiuvalent
@ -320,10 +321,10 @@ Check that we validate the topological order
-- fake a commit sync mapping between the new commits
$ sqlite3 "$TESTTMP/monsql/sqlite_dbs" << ENDOFINSERT
> INSERT INTO synced_commit_mapping
> (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id)
> (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id, sync_map_version_name)
> VALUES
> (1, X'$FBSOURCE_C1_BONSAI', 0, X'$MEGAREPO_C2_BONSAI'),
> (1, X'$FBSOURCE_C2_BONSAI', 0, X'$MEGAREPO_C1_BONSAI');
> (1, X'$FBSOURCE_C1_BONSAI', 0, X'$MEGAREPO_C2_BONSAI', 'TEST_VERSION_NAME'),
> (1, X'$FBSOURCE_C2_BONSAI', 0, X'$MEGAREPO_C1_BONSAI', 'TEST_VERSION_NAME');
> ENDOFINSERT
-- run the validator, check that commits are eqiuvalent
@ -350,9 +351,9 @@ Check that we validate the newly-added root commits
-- fake a commit sync mapping between the new commits
$ sqlite3 "$TESTTMP/monsql/sqlite_dbs" << ENDOFINSERT
> INSERT INTO synced_commit_mapping
> (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id)
> (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id, sync_map_version_name)
> VALUES
> (1, X'$FBSOURCE_NEWROOT_BONSAI', 0, X'$MEGAREPO_NEWROOT_BONSAI');
> (1, X'$FBSOURCE_NEWROOT_BONSAI', 0, X'$MEGAREPO_NEWROOT_BONSAI', 'TEST_VERSION_NAME');
> ENDOFINSERT
-- run the validator, check that commits are (1) validated (2) different