From 1bd0adebd651dfe9d9c55af41ac01398a043519e Mon Sep 17 00:00:00 2001 From: Lukas Piatkowski Date: Fri, 25 Sep 2020 00:05:49 -0700 Subject: [PATCH] mononoke/integration tests: publicize hook and megarepo tests (#61) Summary: Pull Request resolved: https://github.com/facebookexperimental/eden/pull/61 Differential Revision: D23818467 fbshipit-source-id: c5e788ca002cdfbcbd0311e98ed5db16965afe14 --- .../test-hook-block-empty-commit.t | 41 ++ .../integration/test-hook-check-nocommit.t | 50 +++ .../integration/test-hook-conflict-markers.t | 142 +++++++ .../test-hook-limit-commit-message-length.t | 75 ++++ .../integration/test-hook-limit-commitsize.t | 109 ++++++ .../integration/test-hook-limit-filesize.t | 61 +++ .../test-hook-limit-path-component-length.t | 58 +++ .../integration/test-hook-limit-path-length.t | 75 ++++ .../test-hook-no-insecure-filenames.t | 240 ++++++++++++ .../test-hook-no-questionable-filenames.t | 97 +++++ .../tests/integration/test-megarepo-catchup.t | 201 ++++++++++ .../test-megarepo-invisible-merge.t | 355 ++++++++++++++++++ .../test-megarepo-tool-sync-diamond-merge.t | 350 +++++++++++++++++ .../integration/test-security-whitelist.t | 60 +++ 14 files changed, 1914 insertions(+) create mode 100644 eden/mononoke/tests/integration/test-hook-block-empty-commit.t create mode 100644 eden/mononoke/tests/integration/test-hook-check-nocommit.t create mode 100644 eden/mononoke/tests/integration/test-hook-conflict-markers.t create mode 100644 eden/mononoke/tests/integration/test-hook-limit-commit-message-length.t create mode 100644 eden/mononoke/tests/integration/test-hook-limit-commitsize.t create mode 100644 eden/mononoke/tests/integration/test-hook-limit-filesize.t create mode 100644 eden/mononoke/tests/integration/test-hook-limit-path-component-length.t create mode 100644 eden/mononoke/tests/integration/test-hook-limit-path-length.t create mode 100644 eden/mononoke/tests/integration/test-hook-no-insecure-filenames.t create mode 100644 eden/mononoke/tests/integration/test-hook-no-questionable-filenames.t create mode 100644 eden/mononoke/tests/integration/test-megarepo-catchup.t create mode 100644 eden/mononoke/tests/integration/test-megarepo-invisible-merge.t create mode 100644 eden/mononoke/tests/integration/test-megarepo-tool-sync-diamond-merge.t create mode 100644 eden/mononoke/tests/integration/test-security-whitelist.t diff --git a/eden/mononoke/tests/integration/test-hook-block-empty-commit.t b/eden/mononoke/tests/integration/test-hook-block-empty-commit.t new file mode 100644 index 0000000000000..a1fef88d5ec86 --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-block-empty-commit.t @@ -0,0 +1,41 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + $ hook_test_setup \ + > block_empty_commit + + $ hg up -q tip + + $ echo 1 > 1 && hg -q addremove && hg ci -m empty + $ hg revert -r ".^" 1 && hg commit --amend + $ hgmn push -r . --to master_bookmark + pushing rev afd5c05eb235 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: block_empty_commit for afd5c05eb235daf088b93d9cbc0dfecbb267a01a: You must include file changes in your commit for it to land + remote: + remote: Root cause: + remote: hooks failed: + remote: block_empty_commit for afd5c05eb235daf088b93d9cbc0dfecbb267a01a: You must include file changes in your commit for it to land + remote: + remote: Debug context: + remote: "hooks failed:\nblock_empty_commit for afd5c05eb235daf088b93d9cbc0dfecbb267a01a: You must include file changes in your commit for it to land" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + + $ echo 1 > 1 && hg addremove && hg ci --amend -m nonempty + adding 1 + $ hgmn push -r . --to master_bookmark + pushing rev d2f8add702e6 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 0 changesets with 0 changes to 0 files + updating bookmark master_bookmark diff --git a/eden/mononoke/tests/integration/test-hook-check-nocommit.t b/eden/mononoke/tests/integration/test-hook-check-nocommit.t new file mode 100644 index 0000000000000..8ae8d212ca35e --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-check-nocommit.t @@ -0,0 +1,50 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + +# This tests @nocommit, so we need to suppress the lint +# @lint-ignore-every NOCOMMIT + + $ . "${TEST_FIXTURES}/library.sh" + + $ hook_test_setup check_nocommit <() + + $ hg up tip + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + +No @nocommit, should work + + $ echo "foo" > foo + $ hg ci -Aqm 1 + $ hgmn push -r . --to master_bookmark + pushing rev 8b8214d70c17 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 0 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Has @nocommit, should fail + + $ hg up -q 0 + $ echo "bar @nocommit" > foo + $ hg ci -Aqm 1 + $ hgmn push -r . --to master_bookmark + pushing rev 2a4a4062249a to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: check_nocommit for 2a4a4062249a2c8175ec17dc89a27ed30580ace2: File contains a @nocommit marker: foo + remote: + remote: Root cause: + remote: hooks failed: + remote: check_nocommit for 2a4a4062249a2c8175ec17dc89a27ed30580ace2: File contains a @nocommit marker: foo + remote: + remote: Debug context: + remote: "hooks failed:\ncheck_nocommit for 2a4a4062249a2c8175ec17dc89a27ed30580ace2: File contains a @nocommit marker: foo" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] diff --git a/eden/mononoke/tests/integration/test-hook-conflict-markers.t b/eden/mononoke/tests/integration/test-hook-conflict-markers.t new file mode 100644 index 0000000000000..44288cdc98ea2 --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-conflict-markers.t @@ -0,0 +1,142 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + + $ hook_test_setup \ + > conflict_markers <( + > echo 'bypass_commit_string="@ignore-conflict-markers"' + > ) + +Negative testing + $ markers_good=('<<<<<<<' + > '<<<<<<<<<<' + > '>>>>>>>' + > '<<<<<<<' + > '>>>>>>>>>>' + > '=====' + > '===============') + $ hg up -q 0 + + $ i=0 + $ for input in "${markers_good[@]}"; do + > i=$((i+1)) + > printf "$input" > "file$i" + > done + $ hg ci -Aqm 1 + $ hgmn push -r . --to master_bookmark + pushing rev 069fca863ff8 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Positive testing + $ hg up -q 0 + $ echo '>>>>>>> 123' > 1 && hg add 1 && hg ci -m 1 + $ hgmn push -r . --to master_bookmark + pushing rev 17a746afd78e to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: conflict_markers for 17a746afd78ed3f7f06d1d5396fa89adf656ae51: Conflict markers were found in file '1' + remote: + remote: Root cause: + remote: hooks failed: + remote: conflict_markers for 17a746afd78ed3f7f06d1d5396fa89adf656ae51: Conflict markers were found in file '1' + remote: + remote: Debug context: + remote: "hooks failed:\nconflict_markers for 17a746afd78ed3f7f06d1d5396fa89adf656ae51: Conflict markers were found in file \'1\'" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + + $ hg up -q 0 + $ echo '<<<<<<< 123' > 1 && hg add 1 && hg ci -m 1 + $ hgmn push -r . --to master_bookmark + pushing rev 948f2ceaf570 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: conflict_markers for 948f2ceaf570f89539966000cf65d4a56dc4ec37: Conflict markers were found in file '1' + remote: + remote: Root cause: + remote: hooks failed: + remote: conflict_markers for 948f2ceaf570f89539966000cf65d4a56dc4ec37: Conflict markers were found in file '1' + remote: + remote: Debug context: + remote: "hooks failed:\nconflict_markers for 948f2ceaf570f89539966000cf65d4a56dc4ec37: Conflict markers were found in file \'1\'" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Negative testing +Files with bad markers should be accepted with these suffixes + $ hg up -q 0 + $ suffixes=('.md' '.markdown' '.rdoc' '.rst') + $ for suffix in "${suffixes[@]}"; do + $ echo ">>>>>>> " > "file$suffix" + $ done + $ hg ci -Aqm 'markdowns' + $ hgmn push -r . --to master_bookmark + pushing rev ced9269b0dde to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Negative Testing +Files with bad markers should be accepted if they are binary. +File is considered binary if it contains \0 + $ hg up -q 0 + $ echo -e ">>>>>>> \0" > file + $ hg ci -Aqm binary + $ hgmn push -r . --to master_bookmark + pushing rev e913daf3ef9f to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Test bypass + $ hg up -q 0 + $ echo -e ">>>>>>> " > largefile + $ hg ci -Aqm '@ignore-conflict-markers' + $ hgmn push -r . --to master_bookmark + pushing rev a45fdf76c250 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Test markers not on the first line + $ hg up -q 0 + $ echo -e "ololo\nonemore\n\n>>>>>>> " > notfirstline + $ hg ci -Aqm notfirstline + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: conflict_markers for be491e50f4868f90970fb2267d7724d8580780af: Conflict markers were found in file 'notfirstline' + remote: + remote: Root cause: + remote: hooks failed: + remote: conflict_markers for be491e50f4868f90970fb2267d7724d8580780af: Conflict markers were found in file 'notfirstline' + remote: + remote: Debug context: + remote: "hooks failed:\nconflict_markers for be491e50f4868f90970fb2267d7724d8580780af: Conflict markers were found in file \'notfirstline\'" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] diff --git a/eden/mononoke/tests/integration/test-hook-limit-commit-message-length.t b/eden/mononoke/tests/integration/test-hook-limit-commit-message-length.t new file mode 100644 index 0000000000000..235ec271019bf --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-limit-commit-message-length.t @@ -0,0 +1,75 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + + + $ hook_test_setup \ + > limit_commit_message_length <( + > cat < config_strings={length_limit="10"} + > CONF + > ) + + $ hg up tip + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + +Ok commit message - should pass + + $ touch file1 + $ hg ci -Aqm 123456789 + $ hgmn push -r . --to master_bookmark + pushing rev f95217ebe3a8 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 0 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Commit message too long - should fail + + $ hg up -q 0 + $ touch file2 + $ hg ci -Aqm "$(printf "%s\n%s" "foo" "123456")" + $ hgmn push -r . --to master_bookmark + pushing rev 6ef9fe6a13fa to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: limit_commit_message_length for 6ef9fe6a13fa92ed3a2fdc0843441c0511cd47f6: Commit message length for 'foo' (10) exceeds length limit (>= 10) + remote: + remote: Root cause: + remote: hooks failed: + remote: limit_commit_message_length for 6ef9fe6a13fa92ed3a2fdc0843441c0511cd47f6: Commit message length for 'foo' (10) exceeds length limit (>= 10) + remote: + remote: Debug context: + remote: "hooks failed:\nlimit_commit_message_length for 6ef9fe6a13fa92ed3a2fdc0843441c0511cd47f6: Commit message length for \'foo\' (10) exceeds length limit (>= 10)" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Commit message too long (UTF-8 multibyte characters) - should fail + + $ hg up -q 0 + $ touch file3 + $ hg ci -Aqm "$(printf "%s\n%s" "foo" "1234€")" + $ hgmn push -r . --to master_bookmark + pushing rev 0531ec587487 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: limit_commit_message_length for 0531ec5874870ef2b56c302d7844038e71efce54: Commit message length for 'foo' (11) exceeds length limit (>= 10) + remote: + remote: Root cause: + remote: hooks failed: + remote: limit_commit_message_length for 0531ec5874870ef2b56c302d7844038e71efce54: Commit message length for 'foo' (11) exceeds length limit (>= 10) + remote: + remote: Debug context: + remote: "hooks failed:\nlimit_commit_message_length for 0531ec5874870ef2b56c302d7844038e71efce54: Commit message length for \'foo\' (11) exceeds length limit (>= 10)" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] diff --git a/eden/mononoke/tests/integration/test-hook-limit-commitsize.t b/eden/mononoke/tests/integration/test-hook-limit-commitsize.t new file mode 100644 index 0000000000000..ece44889a2555 --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-limit-commitsize.t @@ -0,0 +1,109 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + + $ BYTE_LIMIT=10 + $ hook_test_setup \ + > limit_commitsize <( + > cat < bypass_commit_string="@allow-large-files" + > config_ints={commitsizelimit=${BYTE_LIMIT}} + > CONF + > ) + +Small commit + $ hg up -q 0 + $ for x in $(seq $BYTE_LIMIT); do echo -n 1 > $x; done + $ hg ci -Aqm 1 + $ hgmn push -r . --to master_bookmark + pushing rev e6f2d01a954a to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Large file + $ LARGE_CONTENT=$(for _ in $(seq $(( $BYTE_LIMIT + 1 ))); do echo -n 1; done) + $ hg up -q 0 + $ echo -n "$LARGE_CONTENT" > largefile + $ hg ci -Aqm largefile + $ hgmn push -r . --to master_bookmark + pushing rev b4b4dcaa16f9 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: limit_commitsize for b4b4dcaa16f97662c6a6e70b6eb8c3af1aea8253: Commit size limit is 10 bytes. You tried to push commit that is over the limit. See https://fburl.com/landing_big_diffs for instructions. + remote: + remote: Root cause: + remote: hooks failed: + remote: limit_commitsize for b4b4dcaa16f97662c6a6e70b6eb8c3af1aea8253: Commit size limit is 10 bytes. You tried to push commit that is over the limit. See https://fburl.com/landing_big_diffs for instructions. + remote: + remote: Debug context: + remote: "hooks failed:\nlimit_commitsize for b4b4dcaa16f97662c6a6e70b6eb8c3af1aea8253: Commit size limit is 10 bytes. You tried to push commit that is over the limit. See https://fburl.com/landing_big_diffs for instructions." + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Large commit + $ hg up -q 0 + $ for x in $(seq $(( $BYTE_LIMIT + 1))); do echo -n 1 > "${x}_b"; done + $ hg ci -Aqm largecommit + $ hgmn push -r . --to master_bookmark + pushing rev 0d437325fdc4 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: limit_commitsize for 0d437325fdc4006bbd174b823446331bfa53a68d: Commit size limit is 10 bytes. You tried to push commit that is over the limit. See https://fburl.com/landing_big_diffs for instructions. + remote: + remote: Root cause: + remote: hooks failed: + remote: limit_commitsize for 0d437325fdc4006bbd174b823446331bfa53a68d: Commit size limit is 10 bytes. You tried to push commit that is over the limit. See https://fburl.com/landing_big_diffs for instructions. + remote: + remote: Debug context: + remote: "hooks failed:\nlimit_commitsize for 0d437325fdc4006bbd174b823446331bfa53a68d: Commit size limit is 10 bytes. You tried to push commit that is over the limit. See https://fburl.com/landing_big_diffs for instructions." + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Bypass + $ hg commit --amend -m "@allow-large-files" + $ hgmn push -r . --to master_bookmark + pushing rev dcf66a8e39a7 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Removing files whose total size is large should work + $ hgmn up master_bookmark + 12 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ for x in $(seq $(( $BYTE_LIMIT + 1))); do rm "${x}_b"; done + $ hg ci -Aqm largeremove + $ hg status --rev ".^::." + R 10_b + R 11_b + R 1_b + R 2_b + R 3_b + R 4_b + R 5_b + R 6_b + R 7_b + R 8_b + R 9_b + $ hgmn push -r . --to master_bookmark + pushing rev f4021c22aa2d to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 0 changesets with 0 changes to 0 files + updating bookmark master_bookmark diff --git a/eden/mononoke/tests/integration/test-hook-limit-filesize.t b/eden/mononoke/tests/integration/test-hook-limit-filesize.t new file mode 100644 index 0000000000000..2f37e92f51313 --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-limit-filesize.t @@ -0,0 +1,61 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + + $ hook_test_setup \ + > limit_filesize <( + > cat < bypass_commit_string="@allow-large-files" + > config_ints={filesizelimit=10} + > CONF + > ) + +Small file + $ hg up -q 0 + $ echo 1 > 1 + $ hg ci -Aqm 1 + $ hgmn push -r . --to master_bookmark + pushing rev a0c9c5791058 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Large file + $ LARGE_CONTENT=11111111111 + $ hg up -q 0 + $ echo "$LARGE_CONTENT" > largefile + $ hg ci -Aqm largefile + $ hgmn push -r . --to master_bookmark + pushing rev 328ac95dcdf8 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: limit_filesize for 328ac95dcdf83d6268a174267b666bfefafdfc0b: File size limit is 10 bytes. You tried to push file largefile that is over the limit (12 bytes). See https://fburl.com/landing_big_diffs for instructions. + remote: + remote: Root cause: + remote: hooks failed: + remote: limit_filesize for 328ac95dcdf83d6268a174267b666bfefafdfc0b: File size limit is 10 bytes. You tried to push file largefile that is over the limit (12 bytes). See https://fburl.com/landing_big_diffs for instructions. + remote: + remote: Debug context: + remote: "hooks failed:\nlimit_filesize for 328ac95dcdf83d6268a174267b666bfefafdfc0b: File size limit is 10 bytes. You tried to push file largefile that is over the limit (12 bytes). See https://fburl.com/landing_big_diffs for instructions." + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Bypass + $ hg commit --amend -m "@allow-large-files" + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark diff --git a/eden/mononoke/tests/integration/test-hook-limit-path-component-length.t b/eden/mononoke/tests/integration/test-hook-limit-path-component-length.t new file mode 100644 index 0000000000000..43e6660e5ae80 --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-limit-path-component-length.t @@ -0,0 +1,58 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + + + $ hook_test_setup \ + > limit_path_length <( + > cat < config_strings={length_limit="490"} + > CONF + > ) + + $ hg up tip + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + +Ok file path - should work +S200449 + $ DIR="flib/intern/__generated__/GraphQLMeerkatStep/flib/intern/entschema/generated/entity/profile_plus/EntPlatformToolViewerContextCallsiteMigrationRuleAction.php" + $ NOT_TOO_LARGE_FILE="GQLG_Intern__PlatformToolViewerContextCallsiteMigrationRuleChangeRuleApiMappingResponsePayload__EntPlatformToolViewerContextCallsiteMigrationRuleAction__genPerformGraphQLPlatformToolViewerContextCallsiteMigrationRuleChangeRuleApiMappingMutationType.php" + $ TOO_LARGE_FILE="GQLG_Intern__PlatformToolViewerContextCallsiteMigrationRuleChangeRuleDescriptionResponsePayload__EntPlatformToolViewerContextCallsiteMigrationRuleAction__genPerformGraphQLPlatformToolViewerContextCallsiteMigrationRuleChangeRuleDescriptionMutationType.php" + + $ hg up -q master_bookmark + $ mkdir -p "$DIR" + $ touch "$DIR/$TOO_LARGE_FILE" + $ hg ci -Aqm too_large + $ hgmn push -r . --to master_bookmark + pushing rev 9af0f6fef03e to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: limit_path_length for 9af0f6fef03e3490dddf78cc54e01e787d8a0046: Path component length for "GQLG:Intern::PlatformToolViewerContextCallsiteMigrationRuleChangeRuleDescriptionResponsePayload::EntPlatformToolViewerContextCallsiteMigrationRuleAction::genPerformGraphQLPlatformToolViewerContextCallsiteMigrationRuleChangeRuleDescriptionMutationType.php.i" (256) exceeds length limit (>= 255) + remote: + remote: Root cause: + remote: hooks failed: + remote: limit_path_length for 9af0f6fef03e3490dddf78cc54e01e787d8a0046: Path component length for "GQLG:Intern::PlatformToolViewerContextCallsiteMigrationRuleChangeRuleDescriptionResponsePayload::EntPlatformToolViewerContextCallsiteMigrationRuleAction::genPerformGraphQLPlatformToolViewerContextCallsiteMigrationRuleChangeRuleDescriptionMutationType.php.i" (256) exceeds length limit (>= 255) + remote: + remote: Debug context: + remote: "hooks failed:\nlimit_path_length for 9af0f6fef03e3490dddf78cc54e01e787d8a0046: Path component length for \"GQLG:Intern::PlatformToolViewerContextCallsiteMigrationRuleChangeRuleDescriptionResponsePayload::EntPlatformToolViewerContextCallsiteMigrationRuleAction::genPerformGraphQLPlatformToolViewerContextCallsiteMigrationRuleChangeRuleDescriptionMutationType.php.i\" (256) exceeds length limit (>= 255)" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + + $ hg up -q master_bookmark + $ mkdir -p "$DIR" + $ touch "$DIR/$NOT_TOO_LARGE_FILE" + $ hg ci -Aqm not_too_large + $ hgmn push -r . --to master_bookmark + pushing rev 7dfdeae7524e to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 0 changesets with 0 changes to 0 files + updating bookmark master_bookmark diff --git a/eden/mononoke/tests/integration/test-hook-limit-path-length.t b/eden/mononoke/tests/integration/test-hook-limit-path-length.t new file mode 100644 index 0000000000000..6870b3b4ff2f0 --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-limit-path-length.t @@ -0,0 +1,75 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + $ export LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 + + $ hook_test_setup \ + > limit_path_length <( + > cat < config_strings={length_limit="10"} + > CONF + > ) + + $ hg up tip + 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + +Ok file path - should work + + $ touch 123456789 + $ hg ci -Aqm 1 + $ hgmn push -r . --to master_bookmark + pushing rev 2f6ac546dc81 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + adding changesets + adding manifests + adding file changes + added 0 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +File path too long - should fail + + $ hg up -q 0 + $ touch 1234567890 + $ hg ci -Aqm 1 + $ hgmn push -r . --to master_bookmark + pushing rev 56fa24a52883 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: limit_path_length for 56fa24a5288379b752543077df52a8da6d6113ec: Path length for '1234567890' (10) exceeds length limit (>= 10) + remote: + remote: Root cause: + remote: hooks failed: + remote: limit_path_length for 56fa24a5288379b752543077df52a8da6d6113ec: Path length for '1234567890' (10) exceeds length limit (>= 10) + remote: + remote: Debug context: + remote: "hooks failed:\nlimit_path_length for 56fa24a5288379b752543077df52a8da6d6113ec: Path length for \'1234567890\' (10) exceeds length limit (>= 10)" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +File path too long (UTF-8 multibyte characters) - should fail + + $ hg up -q 0 + $ touch 12345678€ + $ hg ci -Aqm 1 + $ hgmn push -r . --to master_bookmark + pushing rev 2aa9727c0ca2 to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: limit_path_length for 2aa9727c0ca277205aedda2a1acf9d077eafc9d5: Path length for '12345678\xe2\x82\xac' (11) exceeds length limit (>= 10) (esc) + remote: + remote: Root cause: + remote: hooks failed: + remote: limit_path_length for 2aa9727c0ca277205aedda2a1acf9d077eafc9d5: Path length for '12345678\xe2\x82\xac' (11) exceeds length limit (>= 10) (esc) + remote: + remote: Debug context: + remote: "hooks failed:\\nlimit_path_length for 2aa9727c0ca277205aedda2a1acf9d077eafc9d5: Path length for \\'12345678\xe2\x82\xac\\' (11) exceeds length limit (>= 10)" (esc) + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] diff --git a/eden/mononoke/tests/integration/test-hook-no-insecure-filenames.t b/eden/mononoke/tests/integration/test-hook-no-insecure-filenames.t new file mode 100644 index 0000000000000..6ee8d661105f4 --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-no-insecure-filenames.t @@ -0,0 +1,240 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + $ export LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 LANGUAGE=en_US.UTF-8 + + $ hook_test_setup no_insecure_filenames + +Add a .hg(sub|tags|substate) file + $ hg up -q 0 + $ echo "bad" > .hgtags + $ hg ci -Aqm failure + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_insecure_filenames for 42be02defdeedc5825555cc9adbbf537b1bf1c49: ABORT: Illegal filename: .hgtags + remote: + remote: Root cause: + remote: hooks failed: + remote: no_insecure_filenames for 42be02defdeedc5825555cc9adbbf537b1bf1c49: ABORT: Illegal filename: .hgtags + remote: + remote: Debug context: + remote: "hooks failed:\nno_insecure_filenames for 42be02defdeedc5825555cc9adbbf537b1bf1c49: ABORT: Illegal filename: .hgtags" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Add a legitimate file with hg in its name + $ hg up -q 0 + $ echo "good" > .hgsubstatefoo + $ hg ci -Aqm good + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Add a dir with a naughty .Git directory inside + $ hg up -q 0 + $ mkdir -p test/.Git/ + $ echo "bad" > test/.Git/test.py + $ hg ci -Aqm failure + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_insecure_filenames for 63a821ce8ce6d0e38385bb41f49a77b46d1d81a1: ABORT: Illegal insecure name: test/.Git/test.py + remote: + remote: Root cause: + remote: hooks failed: + remote: no_insecure_filenames for 63a821ce8ce6d0e38385bb41f49a77b46d1d81a1: ABORT: Illegal insecure name: test/.Git/test.py + remote: + remote: Debug context: + remote: "hooks failed:\nno_insecure_filenames for 63a821ce8ce6d0e38385bb41f49a77b46d1d81a1: ABORT: Illegal insecure name: test/.Git/test.py" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Add a dir with a naughty .git directory inside + $ hg up -q 0 + $ mkdir -p test/.git/ + $ echo "bad" > test/.git/test.py + $ hg ci -Aqm failure + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_insecure_filenames for 214bf1e67d4847fabd9a134bae0a1bf466fea704: ABORT: Illegal insecure name: test/.git/test.py + remote: + remote: Root cause: + remote: hooks failed: + remote: no_insecure_filenames for 214bf1e67d4847fabd9a134bae0a1bf466fea704: ABORT: Illegal insecure name: test/.git/test.py + remote: + remote: Debug context: + remote: "hooks failed:\nno_insecure_filenames for 214bf1e67d4847fabd9a134bae0a1bf466fea704: ABORT: Illegal insecure name: test/.git/test.py" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Add a dir with a naughty .git directory inside that includes a ~1 + $ hg up -q 0 + $ mkdir -p test/.Git~1/ + $ echo "bad" > test/.Git~1/test.py + $ hg ci -Aqm failure + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_insecure_filenames for 7800fe789a874b225e4974fa09a25a051ea3d1e0: ABORT: Illegal insecure name: test/.Git~1/test.py + remote: + remote: Root cause: + remote: hooks failed: + remote: no_insecure_filenames for 7800fe789a874b225e4974fa09a25a051ea3d1e0: ABORT: Illegal insecure name: test/.Git~1/test.py + remote: + remote: Debug context: + remote: "hooks failed:\nno_insecure_filenames for 7800fe789a874b225e4974fa09a25a051ea3d1e0: ABORT: Illegal insecure name: test/.Git~1/test.py" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Add a dir with a naughty .git directory inside that includes a ~1234 + $ hg up -q 0 + $ mkdir -p test/.Git~1234/test + $ echo "bad" > test/.Git~1234/test/test.py + $ hg ci -Aqm failure + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_insecure_filenames for 8e508312f2d6a7f354ee17bc46a9dc618da9ded3: ABORT: Illegal insecure name: test/.Git~1234/test/test.py + remote: + remote: Root cause: + remote: hooks failed: + remote: no_insecure_filenames for 8e508312f2d6a7f354ee17bc46a9dc618da9ded3: ABORT: Illegal insecure name: test/.Git~1234/test/test.py + remote: + remote: Debug context: + remote: "hooks failed:\nno_insecure_filenames for 8e508312f2d6a7f354ee17bc46a9dc618da9ded3: ABORT: Illegal insecure name: test/.Git~1234/test/test.py" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Add a bad dir + $ hg up -q 0 + $ mkdir -p dir1/.Git8B6C~2 + $ echo "bad" > dir1/.Git8B6C~2/file1 + $ hg ci -Aqm failure + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_insecure_filenames for 695a2a5c3e7ce0fdccefa1945c8bd8868027248b: ABORT: Illegal insecure name: dir1/.Git8B6C~2/file1 + remote: + remote: Root cause: + remote: hooks failed: + remote: no_insecure_filenames for 695a2a5c3e7ce0fdccefa1945c8bd8868027248b: ABORT: Illegal insecure name: dir1/.Git8B6C~2/file1 + remote: + remote: Debug context: + remote: "hooks failed:\nno_insecure_filenames for 695a2a5c3e7ce0fdccefa1945c8bd8868027248b: ABORT: Illegal insecure name: dir1/.Git8B6C~2/file1" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Add a dir with a naughty .git directory inside that includes 2 ~1 + $ hg up -q 0 + $ mkdir -p test~1/.Git~1/test + $ echo "bad" > test~1/.Git~1/test/test.py + $ hg ci -Aqm failure + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_insecure_filenames for 014b76ac58ed568649b5308bece3aa75aefceca8: ABORT: Illegal insecure name: test~1/.Git~1/test/test.py + remote: + remote: Root cause: + remote: hooks failed: + remote: no_insecure_filenames for 014b76ac58ed568649b5308bece3aa75aefceca8: ABORT: Illegal insecure name: test~1/.Git~1/test/test.py + remote: + remote: Debug context: + remote: "hooks failed:\nno_insecure_filenames for 014b76ac58ed568649b5308bece3aa75aefceca8: ABORT: Illegal insecure name: test~1/.Git~1/test/test.py" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Add a legitimate dir with git in its name + $ hg up -q 0 + $ mkdir -p test/git/ + $ echo "good" > test/git/test.py + $ hg ci -Aqm good + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Add a legitimate dir with jgit in its name + $ hg up -q 0 + $ echo "good" > jgit + $ hg ci -Aqm good + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Add a legitimate dir with xGit in its name + $ hg up -q 0 + $ mkdir -p test/xGit/ + $ echo "good" > test/xGit/test.py + $ hg ci -Aqm good + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files + updating bookmark master_bookmark + +Add a file with an ignorable unicode char in it + $ hg up -q 0 + $ bad=$(printf "\xe2\x80\x8c") + $ mkdir test + $ echo "bad" > "test/.git${bad}" + $ hg ci -Aqm failure + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_insecure_filenames for 673dc62e3d09668ca2ef53b04d2527dd3c8e0b2e: ABORT: Illegal insecure name: test/.git\xe2\x80\x8c (esc) + remote: + remote: Root cause: + remote: hooks failed: + remote: no_insecure_filenames for 673dc62e3d09668ca2ef53b04d2527dd3c8e0b2e: ABORT: Illegal insecure name: test/.git\xe2\x80\x8c (esc) + remote: + remote: Debug context: + remote: "hooks failed:\nno_insecure_filenames for 673dc62e3d09668ca2ef53b04d2527dd3c8e0b2e: ABORT: Illegal insecure name: test/.git\u{200c}" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] diff --git a/eden/mononoke/tests/integration/test-hook-no-questionable-filenames.t b/eden/mononoke/tests/integration/test-hook-no-questionable-filenames.t new file mode 100644 index 0000000000000..66ec9a30656c0 --- /dev/null +++ b/eden/mononoke/tests/integration/test-hook-no-questionable-filenames.t @@ -0,0 +1,97 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + + $ hook_test_setup no_questionable_filenames <( \ + > echo 'bypass_pushvar="ALLOW_CRAZY_FILENAMES=true"' + > ) + +Attempt to add a filename with spaces in it + $ hg up -q 0 + $ mkdir -p "test" + $ echo "bad" > "test/foo bar" + $ hg ci -Aqm success + $ hgmn push -r . --to master_bookmark + pushing rev c60235ea2c7f to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_questionable_filenames for c60235ea2c7ff0fbb5fd0e1e9906fb712b7853d0: ABORT: Illegal filename: test/foo bar + remote: + remote: Root cause: + remote: hooks failed: + remote: no_questionable_filenames for c60235ea2c7ff0fbb5fd0e1e9906fb712b7853d0: ABORT: Illegal filename: test/foo bar + remote: + remote: Debug context: + remote: "hooks failed:\nno_questionable_filenames for c60235ea2c7ff0fbb5fd0e1e9906fb712b7853d0: ABORT: Illegal filename: test/foo bar" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Attempt to add a filename with braces in it + $ hg up -q 0 + $ mkdir -p "test" + $ echo "bad" > "test/{foobar}" + $ hg ci -Aqm success + $ hgmn push -r . --to master_bookmark + pushing rev 8d7d42b0b3af to destination ssh://user@dummy/repo bookmark master_bookmark + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_questionable_filenames for 8d7d42b0b3afdb18551c0e69751d044c68e1906b: ABORT: Illegal filename: test/{foobar} + remote: + remote: Root cause: + remote: hooks failed: + remote: no_questionable_filenames for 8d7d42b0b3afdb18551c0e69751d044c68e1906b: ABORT: Illegal filename: test/{foobar} + remote: + remote: Debug context: + remote: "hooks failed:\nno_questionable_filenames for 8d7d42b0b3afdb18551c0e69751d044c68e1906b: ABORT: Illegal filename: test/{foobar}" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Attempt to add a filename with a hypen at the start + $ hg up -q 0 + $ echo "good" > -testfile + $ hg ci -Aqm good + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_questionable_filenames for b2b56d66a7073312c059555f1193c5183cf8d37f: ABORT: Illegal filename: -testfile + remote: + remote: Root cause: + remote: hooks failed: + remote: no_questionable_filenames for b2b56d66a7073312c059555f1193c5183cf8d37f: ABORT: Illegal filename: -testfile + remote: + remote: Debug context: + remote: "hooks failed:\nno_questionable_filenames for b2b56d66a7073312c059555f1193c5183cf8d37f: ABORT: Illegal filename: -testfile" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] + +Attempt to add a filename with an apostrophe in it + $ hg up -q 0 + $ echo "bad" > "test'file" + $ hg ci -Aqm failure + $ hgmn push -r . --to master_bookmark + pushing rev * to destination ssh://user@dummy/repo bookmark master_bookmark (glob) + searching for changes + remote: Command failed + remote: Error: + remote: hooks failed: + remote: no_questionable_filenames for 11ee725a331757675c477522b172ab35967903ef: ABORT: Illegal filename: test'file + remote: + remote: Root cause: + remote: hooks failed: + remote: no_questionable_filenames for 11ee725a331757675c477522b172ab35967903ef: ABORT: Illegal filename: test'file + remote: + remote: Debug context: + remote: "hooks failed:\nno_questionable_filenames for 11ee725a331757675c477522b172ab35967903ef: ABORT: Illegal filename: test\'file" + abort: stream ended unexpectedly (got 0 bytes, expected 4) + [255] diff --git a/eden/mononoke/tests/integration/test-megarepo-catchup.t b/eden/mononoke/tests/integration/test-megarepo-catchup.t new file mode 100644 index 0000000000000..f15c71e69ea16 --- /dev/null +++ b/eden/mononoke/tests/integration/test-megarepo-catchup.t @@ -0,0 +1,201 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + $ REPOTYPE="blob_files" + $ setup_common_config $REPOTYPE + + $ cd "$TESTTMP" + $ hginit_treemanifest repo-hg + $ cd repo-hg + $ echo a > a && hg add a && hg ci -m 'large repo first commit' + $ echo b > b && hg add b && hg ci -m 'large repo second commit' + $ hg book -r . pre_merge_head_bookmark + $ hg book -r . head_bookmark + + $ hg up -q null + $ mkdir smallrepofiles + $ cd smallrepofiles + $ mkdir unchanged_files + $ cd unchanged_files + $ for i in `seq 1 3`; do echo "$i" > "$i.out"; done + $ cd .. + $ mkdir to_change_files + $ cd to_change_files + $ for i in `seq 1 3`; do echo "$i" > "$i.out"; done + $ cd .. + $ mkdir to_move_files + $ cd to_move_files + $ for i in `seq 1 3`; do echo "$i" > "$i.out"; done + $ cd .. + $ hg addremove -q + $ hg ci -m 'small repo first commit' + $ hg book -r . small_repo_head_bookmark + $ cd "$TESTTMP/repo-hg" + + $ hg up -q head_bookmark + $ hg merge -q small_repo_head_bookmark + $ hg ci -m 'invisible merge' + + $ echo "ab" > "ab" + $ hg addremove -q + $ hg commit -m "new commit in large repo" + $ ls + a + ab + b + smallrepofiles + + + $ hg up -q small_repo_head_bookmark + $ cd smallrepofiles + $ hg mv -q to_move_files moved_files + $ hg ci -m "move files in small repo" + $ cd to_change_files + $ for i in `seq 1 3`; do echo "changed $i" > "$i.out"; done + $ hg ci -m 'change files' + $ cd .. + $ ls + moved_files + to_change_files + unchanged_files + + $ hg log -G + @ commit: f910c17f2a72 + | bookmark: small_repo_head_bookmark + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: change files + | + o commit: 83c4b83dcc37 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: move files in small repo + | + | o commit: b662a919caea + | | bookmark: head_bookmark + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: new commit in large repo + | | + | o commit: 8eb1f2b968a3 + |/| user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: invisible merge + | | + o | commit: 70b0bf7fe816 + / user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: small repo first commit + | + o commit: 78a7e5a52cc8 + | bookmark: pre_merge_head_bookmark + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: large repo second commit + | + o commit: 63d5c6ae8a3d + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: large repo first commit + + + $ cd "$TESTTMP" + $ hgclone_treemanifest ssh://user@dummy/repo-hg repo-client --noupdate --config extensions.remotenames= -q + +blobimport + $ blobimport repo-hg/.hg repo + + $ megarepo_tool create-catchup-head-deletion-commits \ + > --head-bookmark head_bookmark \ + > --to-merge-cs-id small_repo_head_bookmark \ + > --path-regex "^smallrepofiles.*" \ + > --deletion-chunk-size 3 \ + > user "deletion commit" + * using repo "repo" repoid RepositoryId(0) (glob) + * changeset resolved as: ChangesetId(Blake2(*)) (glob) + * total files to delete is 6 (glob) + * created bonsai #0. Deriving hg changeset for it to verify its correctness (glob) + * derived *, pushrebasing... (glob) + * Pushrebased to * (glob) + * created bonsai #1. Deriving hg changeset for it to verify its correctness (glob) + * derived *, pushrebasing... (glob) + * Pushrebased to * (glob) + $ mononoke + $ wait_for_mononoke + $ cd "$TESTTMP/repo-client" + $ hgmn pull + pulling from ssh://user@dummy/repo + searching for changes + adding changesets + adding manifests + adding file changes + added 2 changesets with 0 changes to 0 files + adding remote bookmark head_bookmark + adding remote bookmark pre_merge_head_bookmark + adding remote bookmark small_repo_head_bookmark + $ hgmn up head_bookmark + 6 files updated, 0 files merged, 0 files removed, 0 files unresolved + (activating bookmark head_bookmark) + $ ls + a + ab + b + smallrepofiles + $ ls smallrepofiles + unchanged_files + $ hg log -G + @ commit: * (glob) + | bookmark: head_bookmark + | user: user + | date: * (glob) + | summary: [MEGAREPO CATCHUP DELETE] deletion commit (1) + | + o commit: * (glob) + | user: user + | date: * (glob) + | summary: [MEGAREPO CATCHUP DELETE] deletion commit (0) + | + | o commit: f910c17f2a72 + | | bookmark: small_repo_head_bookmark + | | bookmark: default/small_repo_head_bookmark + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: change files + | | + | o commit: 83c4b83dcc37 + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: move files in small repo + | | + o | commit: b662a919caea + | | bookmark: default/head_bookmark + | | user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: new commit in large repo + | | + o | commit: 8eb1f2b968a3 + |\| user: test + | | date: Thu Jan 01 00:00:00 1970 +0000 + | | summary: invisible merge + | | + | o commit: 70b0bf7fe816 + | user: test + | date: Thu Jan 01 00:00:00 1970 +0000 + | summary: small repo first commit + | + o commit: * (glob) + | bookmark: pre_merge_head_bookmark + | bookmark: default/pre_merge_head_bookmark + | user: test + | date: * (glob) + | summary: large repo second commit + | + o commit: * (glob) + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: large repo first commit + diff --git a/eden/mononoke/tests/integration/test-megarepo-invisible-merge.t b/eden/mononoke/tests/integration/test-megarepo-invisible-merge.t new file mode 100644 index 0000000000000..1cd25b52d75f5 --- /dev/null +++ b/eden/mononoke/tests/integration/test-megarepo-invisible-merge.t @@ -0,0 +1,355 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + $ . "${TEST_FIXTURES}/library-push-redirector.sh" + +Setup repositories + $ REPOTYPE="blob_files" + $ MEG_REPOID=0 + $ FBS_REPOID=1 + $ OVR_REPOID=2 + + $ NO_BOOKMARKS_CACHE=1 REPOID=$MEG_REPOID REPONAME=meg-mon setup_common_config $REPOTYPE + $ NO_BOOKMARKS_CACHE=1 REPOID=$FBS_REPOID REPONAME=fbs-mon setup_common_config $REPOTYPE + $ NO_BOOKMARKS_CACHE=1 REPOID=$OVR_REPOID REPONAME=ovr-mon setup_common_config $REPOTYPE + + $ setup_commitsyncmap + $ setup_configerator_configs +-- initial push-redirection setup redirects ovrsource into megarepo, +-- which is the large repo at this point + $ cat > "$PUSHREDIRECT_CONF/enable" < { + > "per_repo": { + > "2": { + > "draft_push": false, + > "public_push": true + > } + > } + > } + > EOF + + $ cat >> "$HGRCPATH" < [ui] + > ssh="$DUMMYSSH" + > [extensions] + > amend= + > pushrebase= + > remotenames= + > EOF + + $ function createfile { mkdir -p "$(dirname $1)" && echo "$1" > "$1" && hg add -q "$1"; } + $ function createfile_with_content { mkdir -p "$(dirname $1)" && echo "$2" > "$1" && hg add -q "$1"; } + +-- init hg fbsource server repo + $ cd $TESTTMP + $ hginit_treemanifest fbs-hg-srv + $ cd fbs-hg-srv +-- create an initial commit, which will be the last_synced_commit + $ createfile fbcode/fbcodefile_fbsource + $ createfile arvr/arvrfile_fbsource + $ createfile otherfile_fbsource + $ hg -q ci -m "fbsource commit 1" && hg book -ir . master_bookmark + +-- init hg ovrsource server repo + $ cd $TESTTMP + $ hginit_treemanifest ovr-hg-srv + $ cd ovr-hg-srv + $ createfile fbcode/fbcodefile_ovrsource + $ createfile arvr/arvrfile_ovrsource + $ createfile otherfile_ovrsource + $ createfile Research/researchfile_ovrsource + $ hg -q ci -m "ovrsource commit 1" && hg book -r . master_bookmark + +-- init hg megarepo server repo + $ cd $TESTTMP + $ hginit_treemanifest meg-hg-srv + $ cd meg-hg-srv + $ createfile fbcode/fbcodefile_fbsource + $ createfile_with_content .fbsource-rest/arvr/arvrfile_fbsource arvr/arvrfile_fbsource + $ createfile otherfile_fbsource + $ createfile_with_content .ovrsource-rest/fbcode/fbcodefile_ovrsource fbcode/fbcodefile_ovrsource + $ createfile arvr/arvrfile_ovrsource + $ createfile_with_content arvr-legacy/otherfile_ovrsource otherfile_ovrsource + $ createfile_with_content arvr-legacy/Research/researchfile_ovrsource Research/researchfile_ovrsource + $ hg -q ci -m "megarepo commit 1" + $ hg book -r . master_bookmark + +-- blobimport hg server repos into Mononoke repos + $ cd "$TESTTMP" + $ REPOID=$MEG_REPOID blobimport meg-hg-srv/.hg meg-mon + $ REPOID=$FBS_REPOID blobimport fbs-hg-srv/.hg fbs-mon + $ REPOID=$OVR_REPOID blobimport ovr-hg-srv/.hg ovr-mon + +-- setup hg client repos + $ cd "$TESTTMP" + $ hgclone_treemanifest ssh://user@dummy/fbs-hg-srv fbs-hg-cnt --noupdate + $ hgclone_treemanifest ssh://user@dummy/ovr-hg-srv ovr-hg-cnt --noupdate + $ hgclone_treemanifest ssh://user@dummy/meg-hg-srv meg-hg-cnt --noupdate + + +Start mononoke server + $ mononoke --local-configerator-path="$TESTTMP/configerator" + $ wait_for_mononoke + + +Setup commit sync mapping +-- get some bonsai hashes to avoid magic strings later + $ FBSOURCE_MASTER_BONSAI=$(get_bonsai_bookmark $FBS_REPOID master_bookmark) + $ OVRSOURCE_MASTER_BONSAI=$(get_bonsai_bookmark $OVR_REPOID master_bookmark) + $ MEGAREPO_MERGE_BONSAI=$(get_bonsai_bookmark $MEG_REPOID master_bookmark) + +-- insert sync mapping entry + $ add_synced_commit_mapping_entry $FBS_REPOID $FBSOURCE_MASTER_BONSAI $MEG_REPOID $MEGAREPO_MERGE_BONSAI + $ add_synced_commit_mapping_entry $OVR_REPOID $OVRSOURCE_MASTER_BONSAI $MEG_REPOID $MEGAREPO_MERGE_BONSAI +-- tell backsyncer that we're all caught up in ovrsource + $ sqlite3 "$TESTTMP/monsql/sqlite_dbs" "INSERT INTO mutable_counters (repo_id, name, value) VALUES ($OVR_REPOID, 'backsync_from_$MEG_REPOID', 3)"; + + +Perform ovrsource pushrebase, make sure it is push-redirected into Megarepo + $ cd "$TESTTMP/ovr-hg-cnt" + $ REPONAME=ovr-mon hgmn up -q master_bookmark + $ echo 1 > pushredirected_1 && hg addremove -q && hg ci -q -m pushredirected_1 + $ REPONAME=ovr-mon hgmn push -r . --to master_bookmark | grep updating + updating bookmark master_bookmark +-- pushredirected_1 was correctly pushed to master_bookmark in ovrsource + $ log -r master_bookmark + @ pushredirected_1 [public;rev=1;bb12ff0dc64f] default/master_bookmark + | + ~ +-- pushredirected_1 is also present in megarepo + $ cd "$TESTTMP"/meg-hg-cnt + $ REPONAME=meg-mon hgmn pull -q + $ log -r master_bookmark + o pushredirected_1 [public;rev=1;4358fa9b678c] default/master_bookmark + | + ~ +-- ensure that ovrsource root path ends up in megarepo's arvr-legacy + $ REPONAME=meg-mon hgmn up master_bookmark -q + $ ls arvr-legacy | grep pushredirected + pushredirected_1 +- compare the working copies + $ REPOIDLARGE=$MEG_REPOID REPOIDSMALL=$OVR_REPOID verify_wc master_bookmark + +Add a new config version to "all" configs, but do not mark it as current +This new version has fbsource as large repo. Ensure that having such version +in "all" configs does not cause any undesired effects for push-rebases + $ cp "$TEST_FIXTURES/commitsync/all_with_flipped_config.json" "$COMMIT_SYNC_CONF/all" + + $ cd "$TESTTMP/ovr-hg-cnt" + $ REPONAME=ovr-mon hgmn up -q master_bookmark + $ echo 2 > pushredirected_2 && hg addremove -q && hg ci -q -m pushredirected_2 + $ REPONAME=ovr-mon hgmn push -r . --to master_bookmark | grep updating + updating bookmark master_bookmark +-- pushredirected_2 was correctly pushed to master_bookmark + $ log -r master_bookmark + @ pushredirected_2 [public;rev=2;2d72ff1821dd] default/master_bookmark + | + ~ +-- pushredirected_2 is also present in the megarepo + $ cd "$TESTTMP"/meg-hg-cnt + $ REPONAME=meg-mon hgmn pull -q + $ log -r master_bookmark + o pushredirected_2 [public;rev=2;538143697725] default/master_bookmark + | + ~ +-- let's see what's where in megarepo + $ REPONAME=meg-mon hgmn up master_bookmark -q + $ ls arvr-legacy | grep pushredirected + pushredirected_1 + pushredirected_2 +- compare the working copies + $ REPOIDLARGE=$MEG_REPOID REPOIDSMALL=$OVR_REPOID verify_wc master_bookmark + + +Set current version of CommitSyncConfig to have fbsource as large repo, +but disable push-redirection until invisible merge is done +-- stop mononoke before changing config with large repo change + $ kill $MONONOKE_PID + +-- This is an expected state of our configs at the last restart before +-- the invisible merge + $ cp "$TEST_FIXTURES/commitsync/flipped_config.json" "$COMMIT_SYNC_CONF/current" + $ cat > "$PUSHREDIRECT_CONF/enable" < { + > "per_repo": { + > "2": { + > "draft_push": false, + > "public_push": false + > } + > } + > } + > EOF + $ cp "$TEST_FIXTURES/commitsync/flipped_config.toml" "$TESTTMP/mononoke-config/common/commitsyncmap.toml" +-- start mononoke + $ mononoke --local-configerator-path="$TESTTMP/configerator" + $ wait_for_mononoke + + +Prepare for the invisible merge +1. Create an independent ovrsource DAG in fbsource + $ cd "$TESTTMP/ovr-hg-cnt" + $ REPONAME=fbs-mon hgmn push -q \ + > --config extensions.pushrebase=! \ + > --to ovrsource/pre_move_master \ + > --create --force -r . \ + > ssh://user@dummy/fbs-mon + warning: repository is unrelated +1.5. Mark independent ovrsource DAG in fbsource as preserved + $ cd "$TESTTMP" + $ hg log -T "{node}\n" --cwd "ovr-hg-cnt" \ + > | xargs -I {} sqlite3 monsql/sqlite_dbs "SELECT HEX(bcs_id) FROM bonsai_hg_mapping WHERE hg_cs_id = X'{}'" \ + > | sort \ + > | uniq \ + > | xargs -I {} sqlite3 monsql/sqlite_dbs "INSERT INTO synced_commit_mapping (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id) VALUES ($OVR_REPOID, X'{}', $FBS_REPOID, X'{}')" + +2. Move files on top of the intermediate DAG + $ cd "$TESTTMP/fbs-hg-cnt" + $ REPONAME=fbs-mon hgmn pull -q + $ REPONAME=fbs-mon hgmn up -q ovrsource/pre_move_master + $ mkdir arvr-legacy .ovrsource-rest + $ hg mv fbcode .ovrsource-rest/ + moving fbcode/fbcodefile_ovrsource to .ovrsource-rest/fbcode/fbcodefile_ovrsource + $ hg mv arvr otherfile_ovrsource pushredirected_1 pushredirected_2 Research arvr-legacy/ + moving arvr/arvrfile_ovrsource to arvr-legacy/arvr/arvrfile_ovrsource + moving Research/researchfile_ovrsource to arvr-legacy/Research/researchfile_ovrsource + $ REPONAME=fbs-mon hgmn ci -m "move ovrsource files into place" + $ REPONAME=fbs-mon hgmn -q push --to ovrsource/moved_master --create +3. Implement a gradual merge policy + $ COMMIT_DATE="1985-09-04T00:00:00.00Z" + $ cd "$TESTTMP" + $ REPOID=$FBS_REPOID megarepo_tool pre-merge-delete \ + > 2>/dev/null \ + > ovrsource/moved_master \ + > author "merge preparation" \ + > --even-chunk-size 2 \ + > --commit-date-rfc3339 "$COMMIT_DATE" + 96c5d4ac7927effbb86cc5cc1048651a6f37caf5d47666287120e1f33700c5ad + 6fad885af2b0655d790af5445143b58bff4558e1c3bbf027d16b03fd377479b8 +-- a list of commits we want to merge also includes the pre-delete commit + $ TOMERGES=(96c5d4ac7927effbb86cc5cc1048651a6f37caf5d47666287120e1f33700c5ad 6fad885af2b0655d790af5445143b58bff4558e1c3bbf027d16b03fd377479b8 7f5e9b8381acf8700510064e07abd84b3d6ce4fc7e6fab856825fe0e8ed2e69f) +-- calculate to-merge working copy sizes, they should be gradually increasing + $ cd "$TESTTMP/fbs-hg-cnt" + $ for TOMERGE in "${TOMERGES[@]}"; do + > HGHASH=$(REPOID=$FBS_REPOID mononoke_admin --log-level=ERROR convert --from bonsai --to hg $TOMERGE) + > REPONAME=fbs-mon hgmn up -q $HGHASH + > FILECOUNT=$(find . -path ./.hg -prune -o -type f -print | wc -l) + > echo "$HGHASH: $FILECOUNT files" + > done + dd96f681ce82f3fda524178888e34707647f1465: 2 files + 32d48855146d243f170429ced87f41f80be9440f: 4 files + da4ae8f4415fdf04bb05ed946f9638879dad74fa: 6 files + + +Do the invisible merge by gradually merging TOMERGES into master + $ cd "$TESTTMP/fbs-hg-cnt" + $ REPONAME=fbs-mon hgmn up -q master_bookmark + $ MASTER_BEFORE_MERGES=$(hg log -r . -T "{node}") + $ for TOMERGE in "${TOMERGES[@]}"; do + > CURRENT=$(hg log -r . -T "{node}") + > echo "Current: $CURRENT" + > echo "To merge: $TOMERGE" + > MERGE=$(REPOID=$FBS_REPOID megarepo_tool --log-level=ERROR bonsai-merge $CURRENT $TOMERGE author "merge execution" --commit-date-rfc3339 "$COMMIT_DATE") + > HGMERGE=$(REPOID=$FBS_REPOID mononoke_admin --log-level=ERROR convert --from bonsai --to hg $MERGE) + > echo "Merged as (bonsai): $MERGE" + > echo "Merged as (hg): $HGMERGE" + > REPONAME=fbs-mon hgmn up -q $HGMERGE + > FILECOUNT_1=$([ -d ./.ovrsource-rest ] && find ./.ovrsource-rest -type f | wc -l) + > FILECOUNT_2=$([ -d ./arvr-legacy ] && find ./arvr-legacy -type f | wc -l) + > FILECOUNT=$(($FILECOUNT_1 + $FILECOUNT_2)) + > echo "file count is: $FILECOUNT" + > REPOID=$FBS_REPOID mononoke_admin --log-level=ERROR bookmarks set master_bookmark $HGMERGE + > echo "intermediate" >> fbcode/fbcodefile_fbsource + > REPONAME=fbs-mon hgmn ci -qm "intermediate commit between gradual merge commits" + > REPONAME=fbs-mon hgmn push -q --to master_bookmark + > done + Current: cb536a1a0bd5e1e5226a09530ab95ae790b717d7 + To merge: 96c5d4ac7927effbb86cc5cc1048651a6f37caf5d47666287120e1f33700c5ad + Merged as (bonsai): 6fe1e00b3e16c34436bdcba8014ede14407d250acf6426ecf74726f87b1a416a + Merged as (hg): 569337bca1df19dd9a1c1224c34577304fb1637f + file count is: 2 + Current: 7fdc0628cdab039b45aac6f335217fc8c156e218 + To merge: 6fad885af2b0655d790af5445143b58bff4558e1c3bbf027d16b03fd377479b8 + Merged as (bonsai): 6c928f74d3c2f14e91b60da58e7b9b382f100caca2a3168724acb4e8e6314756 + Merged as (hg): b9bdf53b26f4213a50f724942dad9be7b0b8bd0f + file count is: 4 + Current: 40bc30e1b51ba4ebb545e231803a0e0c7b0ffdfc + To merge: 7f5e9b8381acf8700510064e07abd84b3d6ce4fc7e6fab856825fe0e8ed2e69f + Merged as (bonsai): dd2fd320ef5e6b28eff0071f42df538b10d6c656fa6098d25b7a39bcfd8557ea + Merged as (hg): 2b7f7638e7303188954c50e79a68c93340abd01e + file count is: 6 + $ REPONAME=fbs-mon hgmn pull -q |& grep -v 'devel-warn' + [1] + $ hg log -r "$MASTER_BEFORE_MERGES::master_bookmark" -T "{phase} {desc|firstline}\n" + public fbsource commit 1 + public merge execution + public intermediate commit between gradual merge commits + public merge execution + public intermediate commit between gradual merge commits + public merge execution + public intermediate commit between gradual merge commits + + +Create special marker commits in both repos, which can be just marked as rewritten into each other + $ cd "$TESTTMP/ovr-hg-cnt" + $ hg ci -qm "pre push-redirection marker" --config ui.allowemptycommit=True + $ REPONAME=ovr-mon hgmn push -r . --to master_bookmark | grep updating + updating bookmark master_bookmark + $ cd "$TESTTMP/fbs-hg-cnt" + $ hg ci -qm "pre push-redirection marker" --config ui.allowemptycommit=True + $ REPONAME=fbs-mon hgmn push -r . --to master_bookmark | grep updating + updating bookmark master_bookmark + +Set mutable counter for the backsyncer (we've synced everything up until now) + $ LATEST_LOG_ENTRY_ID=$(sqlite3 $TESTTMP/monsql/sqlite_dbs "SELECT MAX(id) FROM bookmarks_update_log WHERE repo_id = $FBS_REPOID") + $ sqlite3 $TESTTMP/monsql/sqlite_dbs "INSERT INTO mutable_counters (repo_id, name, value) VALUES ($OVR_REPOID, 'backsync_from_$FBS_REPOID', $LATEST_LOG_ENTRY_ID)" + +Set working copy equivalence between ovrsource master and fbsource master + $ FBSOURCE_MASTER_BONSAI=$(get_bonsai_bookmark $FBS_REPOID master_bookmark) + $ OVRSOURCE_MASTER_BONSAI=$(get_bonsai_bookmark $OVR_REPOID master_bookmark) + $ sqlite3 $TESTTMP/monsql/sqlite_dbs \ + > "INSERT INTO synced_working_copy_equivalence \ + > (small_repo_id, small_bcs_id, large_repo_id, large_bcs_id) \ + > VALUES \ + > ($OVR_REPOID, X'$OVRSOURCE_MASTER_BONSAI', $FBS_REPOID, X'$FBSOURCE_MASTER_BONSAI')" + +Set current version of CommitSyncConfig to be push-redirecting ovrsource +into fbsource + $ cat > "$PUSHREDIRECT_CONF/enable" < { + > "per_repo": { + > "2": { + > "draft_push": false, + > "public_push": true + > } + > } + > } + > EOF + +Perform ovrsource pushrebase, make sure it is push-redirected into Fbsource + $ cd "$TESTTMP/ovr-hg-cnt" + $ REPONAME=ovr-mon hgmn up -q master_bookmark + $ echo 1 > pushredirected_3 && hg addremove -q && hg ci -q -m pushredirected_3 + $ REPONAME=ovr-mon hgmn push -r . --to master_bookmark | grep updating + updating bookmark master_bookmark +-- pushredirected_3 was correctly pushed to master_bookmark in ovrsource + $ log -r master_bookmark + @ pushredirected_3 [public;rev=4;4355e6b9eafb] default/master_bookmark + | + ~ +-- pushredirected_3 is also present in megarepo + $ cd "$TESTTMP"/fbs-hg-cnt + $ REPONAME=fbs-mon hgmn pull -q + $ log -r master_bookmark + o pushredirected_3 [public;rev=14;4fa1e867d4ae] default/master_bookmark + | + ~ +-- ensure that ovrsource root path ends up in megarepo's arvr-legacy + $ REPONAME=fbs-mon hgmn up master_bookmark -q + $ ls arvr-legacy | grep pushredirected_3 + pushredirected_3 +- compare the working copies + $ REPOIDLARGE=$FBS_REPOID REPOIDSMALL=$OVR_REPOID verify_wc master_bookmark diff --git a/eden/mononoke/tests/integration/test-megarepo-tool-sync-diamond-merge.t b/eden/mononoke/tests/integration/test-megarepo-tool-sync-diamond-merge.t new file mode 100644 index 0000000000000..a4ec52e25a3e1 --- /dev/null +++ b/eden/mononoke/tests/integration/test-megarepo-tool-sync-diamond-merge.t @@ -0,0 +1,350 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + + $ cat >> $HGRCPATH < [extensions] + > rebase= + > pushrebase= + > remotenames= + > EOF + +setup configuration + + $ REPOTYPE="blob_files" + $ REPOID=0 REPONAME=meg_mon setup_common_config $REPOTYPE + $ REPOID=1 REPONAME=with_merge_mon setup_common_config $REPOTYPE + $ REPOID=2 REPONAME=another_mon setup_common_config $REPOTYPE + $ setup_commitsyncmap + $ setup_configerator_configs + + $ cd "$TESTTMP" + $ hginit_treemanifest with_merge + $ cd with_merge + $ echo 1 > somefilebeforemerge + $ hg add somefilebeforemerge + $ hg ci -m 'first commit in small repo with merge' + $ hg book -i -r . with_merge_master + $ echo 2 > someotherfilebeforemerge + $ hg add someotherfilebeforemerge + $ hg ci -m "commit, supposed to be preserved" + $ hg book -ir . with_merge_pre_big_merge + $ hg up with_merge_master -q + + $ cd "$TESTTMP" + $ hginit_treemanifest another + $ cd another + $ echo 1 > file.txt + $ hg add file.txt + $ hg ci -m 'first commit in another small repo' + $ hg book -r . another_master + +Setup client repos + $ cd "$TESTTMP" + $ hgclone_treemanifest ssh://user@dummy/with_merge with_merge_hg --noupdate + $ hgclone_treemanifest ssh://user@dummy/another another_hg --noupdate + $ hgclone_treemanifest ssh://user@dummy/with_merge meg_hg --noupdate + +blobimport hg servers repos into Mononoke repos + $ cd "$TESTTMP" + $ REPOID=0 blobimport with_merge/.hg meg_mon + $ REPOID=0 blobimport another/.hg meg_mon --no-create + + $ REPOID=1 blobimport with_merge/.hg with_merge_mon + $ REPOID=2 blobimport another/.hg another_mon + + $ export COMMIT_DATE="1985-09-04T00:00:00.00Z" +move things in small repo with merge + $ megarepo_tool move 1 with_merge_master user "with merge move" --mark-public --commit-date-rfc3339 "$COMMIT_DATE" --bookmark with_merge_move &> /dev/null + +move things in another small repo + $ megarepo_tool move 2 another_master user "another move" --mark-public --commit-date-rfc3339 "$COMMIT_DATE" --bookmark another_move &> /dev/null + +merge things in both repos + $ megarepo_tool merge with_merge_move another_move user "megarepo merge" --mark-public --commit-date-rfc3339 "$COMMIT_DATE" --bookmark master_bookmark &> /dev/null + +start mononoke server + $ mononoke + $ wait_for_mononoke + +Record current master and the first commit in the preserved stack + $ WITH_MERGE_PRE_MERGE_PRESERVED=$(get_bonsai_bookmark 1 with_merge_pre_big_merge) + $ WITH_MERGE_C1=$(get_bonsai_bookmark 1 with_merge_master) + +Create marker commits, so that we don't have to add $WITH_MERGE_C1 and $MEGAREPO_MERGE to the mapping +(as it's not correct: $WITH_MERGE_C1 is supposed to be preserved) + $ cd "$TESTTMP/with_merge_hg" + $ REPONAME=with_merge_mon hgmn pull -q + devel-warn:* (glob) + $ REPONAME=with_merge_mon hgmn up -q with_merge_master + $ hgmn ci -m "marker commit" --config ui.allowemptycommit=True + $ REPONAME=with_merge_mon hgmn push -r . --to with_merge_master -q + $ WITH_MERGE_MARKER=$(get_bonsai_bookmark 1 with_merge_master) + + $ cd "$TESTTMP/meg_hg" + $ REPONAME=meg_mon hgmn pull -q + $ REPONAME=meg_mon hgmn up -q master_bookmark + $ hgmn ci -m "marker commit" --config ui.allowemptycommit=True + $ REPONAME=meg_mon hgmn push -r . --to master_bookmark -q + $ MEGAREPO_MARKER=$(get_bonsai_bookmark 0 master_bookmark) + +insert sync mapping entry + $ ANOTHER_C1=$(get_bonsai_bookmark 2 another_master) + $ MEGAREPO_MERGE=$(get_bonsai_bookmark 0 master_bookmark) + $ add_synced_commit_mapping_entry 2 $ANOTHER_C1 0 $MEGAREPO_MERGE + $ add_synced_commit_mapping_entry 1 $WITH_MERGE_MARKER 0 $MEGAREPO_MARKER + +Preserve commits from with_merge + $ add_synced_commit_mapping_entry 1 $WITH_MERGE_C1 0 $WITH_MERGE_C1 + $ add_synced_commit_mapping_entry 1 $WITH_MERGE_PRE_MERGE_PRESERVED 0 $WITH_MERGE_PRE_MERGE_PRESERVED + +Do a test pull + $ cd "$TESTTMP"/meg_hg + $ REPONAME=meg_mon hgmn pull -q + devel-warn:* (glob) + $ REPONAME=meg_mon hgmn up -q master_bookmark + $ ls + arvr-legacy + somefilebeforemerge + $ ls arvr-legacy + file.txt + +Create a branch merge in a small repo + $ cd "$TESTTMP"/with_merge_hg + $ drawdag <<'EOF' + > D + > |\ + > | C + > | | + > Y B + > |/ + > A + > EOF + $ hg rebase -s $A -d with_merge_master -q + + $ hg log -G -T '{node|short}' + o 62dba675d1b3 + |\ + | o 23aa3f5a6de2 + | | + o | be5140c7bfcc + | | + o | 7a7632995e68 + |/ + o 68360e2c98f0 + | + @ a35acba7f331 + | + | o 9aaf98d9f7d2 + |/ + o 2fa76efd599c + + + + $ hg log -r 68360e2c98f0 + commit: 68360e2c98f0 + user: test + date: Thu Jan 01 00:00:00 1970 +0000 + summary: A + + + + $ cd "$TESTTMP"/with_merge_hg + $ REPONAME=with_merge_mon hgmn up -q tip + $ ls -R + .: + A + B + C + Y + somefilebeforemerge + +Push a single premerge commit and sync it to megarepo + $ REPONAME=with_merge_mon hgmn push -r 68360e2c98f0 --to with_merge_master -q + $ mononoke_x_repo_sync 1 0 once --target-bookmark master_bookmark --commit with_merge_master &> /dev/null + +Push a commit from another small repo that modifies existing file + $ cd "$TESTTMP"/another_hg + $ hg up -q another_master + $ echo 2 > file.txt + $ hg ci -m 'modify file.txt' + $ REPONAME=another_mon hgmn push -r . --to another_master -q + + $ mononoke_x_repo_sync 2 0 once --target-bookmark master_bookmark --commit another_master &> /dev/null + + $ cd "$TESTTMP"/with_merge_hg +Push and sync commits before a diamond commit + $ REPONAME=with_merge_mon hgmn push -r 7a7632995e68 --to with_merge_master -q + $ mononoke_x_repo_sync 1 0 once --target-bookmark master_bookmark --commit with_merge_master &> /dev/null + $ REPONAME=with_merge_mon hgmn push -r be5140c7bfcc --to with_merge_master -q + $ mononoke_x_repo_sync 1 0 once --target-bookmark master_bookmark --commit with_merge_master &> /dev/null + +Push one more commit from another small repo + $ cd "$TESTTMP"/another_hg + $ hg up -q another_master + $ echo 3 > file.txt + $ hg ci -m 'second modification of file.txt' + $ REPONAME=another_mon hgmn push -r . --to another_master -q + + $ mononoke_x_repo_sync 2 0 once --target-bookmark master_bookmark --commit another_master &> /dev/null + +Push diamond commit + $ cd "$TESTTMP"/with_merge_hg + $ hg log -r 62dba675d1b3 -T '{p1node|short} {p2node|short}' + be5140c7bfcc 23aa3f5a6de2 (no-eol) + $ REPONAME=with_merge_mon hgmn push -r 62dba675d1b3 --to with_merge_master -q &> /dev/null + +Try to sync it automatically, it's expected to fail + $ mononoke_x_repo_sync 1 0 once --target-bookmark master_bookmark --commit with_merge_master 2>&1 | grep 'unsupported merge' + * unsupported merge - only merges of new repos are supported (glob) + * unsupported merge - only merges of new repos are supported (glob) + +Now sync with the tool + $ cd "$TESTTMP" + $ megarepo_tool_multirepo --source-repo-id 1 --target-repo-id 0 sync-diamond-merge with_merge_master --bookmark master_bookmark |& grep -v "using repo" + * changeset resolved as: ChangesetId(Blake2(46c0f70c6300f4168cb70321839ac0079c74b6d3295adb81eeb1932be4f80e9d)) (glob) + * Initializing CfgrLiveCommitSyncConfig (glob) + * Done initializing CfgrLiveCommitSyncConfig (glob) + * Preparing to sync a merge commit 46c0f70c6300f4168cb70321839ac0079c74b6d3295adb81eeb1932be4f80e9d... (glob) + * 1 new commits are going to be merged in (glob) + * syncing commit from new branch 0feeed653ec98bb533a2ad7fc8940ce07c4105326f07b20fcc68ebac0607abf2 (glob) + * uploading merge commit f38496fbd160eaf1bf6ebad1f317635ea818000bb3d634bba6eefa2c80b9666a (glob) + * It is recommended to run 'mononoke_admin crossrepo verify-wc' for f38496fbd160eaf1bf6ebad1f317635ea818000bb3d634bba6eefa2c80b9666a! (glob) +-- a mapping should've been created for the synced merge commit + $ mononoke_admin_source_target 0 1 crossrepo map master_bookmark |& grep -v "using repo" + * Initializing CfgrLiveCommitSyncConfig (glob) + * Done initializing CfgrLiveCommitSyncConfig (glob) + * changeset resolved as: ChangesetId(Blake2(f38496fbd160eaf1bf6ebad1f317635ea818000bb3d634bba6eefa2c80b9666a)) (glob) + Hash f38496fbd160eaf1bf6ebad1f317635ea818000bb3d634bba6eefa2c80b9666a maps to 46c0f70c6300f4168cb70321839ac0079c74b6d3295adb81eeb1932be4f80e9d, used CommitSyncConfigVersion("TEST_VERSION_NAME") + + +Pull from megarepo + $ cd "$TESTTMP"/meg_hg + $ REPONAME=meg_mon hgmn pull -q + $ REPONAME=meg_mon hgmn up -q master_bookmark + $ ls -R + .: + A + B + C + Y + arvr-legacy + somefilebeforemerge + + ./arvr-legacy: + file.txt + + + $ cat arvr-legacy/file.txt + 3 + +Make sure that we have correct parents + $ hg log -r 'parents(master_bookmark)' -T '{node} {desc}\n' + 5d847b3916ac8084ef15846268fb0d9a25d35406 Y + 5ce263ccda875529fde8209141ceaded95b95e68 second modification of file.txt + +Merge with preserved ancestors + $ cd "$TESTTMP"/with_merge_hg + +-- check the mapping for p2's parent + $ mononoke_admin_source_target 1 0 crossrepo map $(hg log -T "{node}" -r with_merge_pre_big_merge) + * Initializing CfgrLiveCommitSyncConfig (glob) + * Done initializing CfgrLiveCommitSyncConfig (glob) + * using repo "with_merge_mon" repoid RepositoryId(1) (glob) + * using repo "meg_mon" repoid RepositoryId(0) (glob) + * changeset resolved as: ChangesetId(Blake2(d27a299389c7bedbe3e4dc01b7d4e7ac2162d935401c5d8462b7e1663dfee0e4)) (glob) + Hash d27a299389c7bedbe3e4dc01b7d4e7ac2162d935401c5d8462b7e1663dfee0e4 maps to d27a299389c7bedbe3e4dc01b7d4e7ac2162d935401c5d8462b7e1663dfee0e4 + +-- create a p2, based on a pre-merge commit + $ REPONAME=with_merge_mon hgmn up with_merge_pre_big_merge -q + $ echo preserved_pre_big_merge_file > preserved_pre_big_merge_file + $ hg ci -Aqm "preserved_pre_big_merge_file" + $ hg book -r . pre_merge_p2 + +-- create a p1, based on a master + $ REPONAME=with_merge_mon hgmn up with_merge_master -q + $ echo ababagalamaga > ababagalamaga + $ hg ci -Aqm "ababagalamaga" + $ hg book -r . pre_merge_p1 + +-- create a merge commit + $ hg merge pre_merge_p2 -q + $ hg ci -qm "merge with preserved p2" + $ hg log -r . -T "{node} {desc}\np1: {p1node}\np2: {p2node}\n" + 18f03e551cee2ec38449f0960a586adcb869cb7a merge with preserved p2 + p1: b5bdb045c12bcaf8b2645438285a4512d7cf823d + p2: 67d0696c2845433765c450939263a8a128fec229 + $ hg book -r . merge_with_preserved + +-- push these folks to the server-side repo + $ REPONAME=with_merge_mon hgmn push --to with_merge_master | grep updating + updating bookmark with_merge_master + +-- sync p1 + $ cd "$TESTTMP" + $ mononoke_x_repo_sync 1 0 once --target-bookmark master_bookmark --commit $(hg log -T "{node}" -r pre_merge_p1 --cwd "$TESTTMP/with_merge_hg") |& grep -v "using repo" + * Initializing CfgrLiveCommitSyncConfig (glob) + * Done initializing CfgrLiveCommitSyncConfig (glob) + * changeset resolved as: ChangesetId(Blake2(87924512f63d088d5b6bb5368bfef8016246e59927fe9d06d8ea657bc94e993d)) (glob) + * Checking if 87924512f63d088d5b6bb5368bfef8016246e59927fe9d06d8ea657bc94e993d is already synced 1->0 (glob) + * syncing via pushrebase (glob) + * syncing 87924512f63d088d5b6bb5368bfef8016246e59927fe9d06d8ea657bc94e993d via pushrebase for master_bookmark (glob) + * changeset 87924512f63d088d5b6bb5368bfef8016246e59927fe9d06d8ea657bc94e993d synced as 283f929b3e2c7d299920a8ee18b0928191fb3f5d9cc530f9fb7c0eb578e45d70 in * (glob) + * successful sync (glob) + $ mononoke_admin_source_target 1 0 crossrepo map 87924512f63d088d5b6bb5368bfef8016246e59927fe9d06d8ea657bc94e993d + * Initializing CfgrLiveCommitSyncConfig (glob) + * Done initializing CfgrLiveCommitSyncConfig (glob) + * using repo "with_merge_mon" repoid RepositoryId(1) (glob) + * using repo "meg_mon" repoid RepositoryId(0) (glob) + * changeset resolved as: ChangesetId(Blake2(87924512f63d088d5b6bb5368bfef8016246e59927fe9d06d8ea657bc94e993d)) (glob) + Hash 87924512f63d088d5b6bb5368bfef8016246e59927fe9d06d8ea657bc94e993d maps to 283f929b3e2c7d299920a8ee18b0928191fb3f5d9cc530f9fb7c0eb578e45d70, used CommitSyncConfigVersion("TEST_VERSION_NAME") + +-- sync the merge + $ cd "$TESTTMP" + $ megarepo_tool_multirepo --source-repo-id 1 --target-repo-id 0 sync-diamond-merge with_merge_master --bookmark master_bookmark + * using repo "with_merge_mon" repoid RepositoryId(1) (glob) + * using repo "meg_mon" repoid RepositoryId(0) (glob) + * changeset resolved as: ChangesetId(Blake2(3f71f093fcfbebcc47c981c847cd80c7d0bf063c5022aba53fab95244e4c4f1c)) (glob) + * Initializing CfgrLiveCommitSyncConfig (glob) + * Done initializing CfgrLiveCommitSyncConfig (glob) + * Preparing to sync a merge commit 3f71f093fcfbebcc47c981c847cd80c7d0bf063c5022aba53fab95244e4c4f1c... (glob) + * 2 new commits are going to be merged in (glob) + * syncing commit from new branch d27a299389c7bedbe3e4dc01b7d4e7ac2162d935401c5d8462b7e1663dfee0e4 (glob) + * syncing commit from new branch 89c0603366c60ae4bf8d8dca6da7581c741b7e89a6fcc3f49a44fdd248de3b1d (glob) + * uploading merge commit a530e2a1eb7ed81c57328f1c0b8fb20656190c5c272d94f7bf768a689c83670d (glob) + * It is recommended to run 'mononoke_admin crossrepo verify-wc' for a530e2a1eb7ed81c57328f1c0b8fb20656190c5c272d94f7bf768a689c83670d! (glob) + +-- check that p2 was synced as preserved (note identical hashes) + $ mononoke_admin_source_target 1 0 crossrepo map $(hg log -r pre_merge_p2 -T "{node}" --cwd "$TESTTMP/with_merge_hg") + * Initializing CfgrLiveCommitSyncConfig (glob) + * Done initializing CfgrLiveCommitSyncConfig (glob) + * using repo "with_merge_mon" repoid RepositoryId(1) (glob) + * using repo "meg_mon" repoid RepositoryId(0) (glob) + * changeset resolved as: ChangesetId(Blake2(89c0603366c60ae4bf8d8dca6da7581c741b7e89a6fcc3f49a44fdd248de3b1d)) (glob) + Hash 89c0603366c60ae4bf8d8dca6da7581c741b7e89a6fcc3f49a44fdd248de3b1d maps to 89c0603366c60ae4bf8d8dca6da7581c741b7e89a6fcc3f49a44fdd248de3b1d + +-- check that merge was synced + $ mononoke_admin_source_target 1 0 crossrepo map with_merge_master + * Initializing CfgrLiveCommitSyncConfig (glob) + * Done initializing CfgrLiveCommitSyncConfig (glob) + * using repo "with_merge_mon" repoid RepositoryId(1) (glob) + * using repo "meg_mon" repoid RepositoryId(0) (glob) + * changeset resolved as: ChangesetId(Blake2(3f71f093fcfbebcc47c981c847cd80c7d0bf063c5022aba53fab95244e4c4f1c)) (glob) + Hash 3f71f093fcfbebcc47c981c847cd80c7d0bf063c5022aba53fab95244e4c4f1c maps to a530e2a1eb7ed81c57328f1c0b8fb20656190c5c272d94f7bf768a689c83670d, used CommitSyncConfigVersion("TEST_VERSION_NAME") + +--verify the working copy + $ mononoke_admin_source_target 1 0 crossrepo verify-wc master_bookmark + * Initializing CfgrLiveCommitSyncConfig (glob) + * Done initializing CfgrLiveCommitSyncConfig (glob) + * using repo "with_merge_mon" repoid RepositoryId(1) (glob) + * using repo "meg_mon" repoid RepositoryId(0) (glob) + * changeset resolved as: ChangesetId(Blake2(a530e2a1eb7ed81c57328f1c0b8fb20656190c5c272d94f7bf768a689c83670d)) (glob) + * target repo cs id: 3f71f093fcfbebcc47c981c847cd80c7d0bf063c5022aba53fab95244e4c4f1c (glob) + * fetching filenode ids for * in * (glob) + * fetching filenode ids for * in * (glob) + * found 0 filenodes that are different, checking content... (glob) + * all is well! (glob) diff --git a/eden/mononoke/tests/integration/test-security-whitelist.t b/eden/mononoke/tests/integration/test-security-whitelist.t new file mode 100644 index 0000000000000..64b21345ecf21 --- /dev/null +++ b/eden/mononoke/tests/integration/test-security-whitelist.t @@ -0,0 +1,60 @@ +# Copyright (c) Facebook, Inc. and its affiliates. +# +# This software may be used and distributed according to the terms of the +# GNU General Public License found in the LICENSE file in the root +# directory of this source tree. + + $ . "${TEST_FIXTURES}/library.sh" + +setup configuration, use incorrect name to make sure pull fails + $ OVERRIDE_ALLOWED_IDDATA=badusername setup_common_config "blob_files" + $ cd $TESTTMP + +setup common configuration + $ cat >> $HGRCPATH < [ui] + > ssh="$DUMMYSSH" + > [extensions] + > amend= + > EOF + +setup repo + $ hg init repo-hg + $ cd repo-hg + $ setup_hg_server + $ hg debugdrawdag < C + > | + > B + > | + > A + > EOF + +create master bookmark + + $ hg bookmark master_bookmark -r tip + +blobimport them into Mononoke storage and start Mononoke + $ cd .. + $ blobimport repo-hg/.hg repo + +start mononoke + $ mononoke + $ wait_for_mononoke + +Clone the repo + $ hgclone_treemanifest ssh://user@dummy/repo-hg repo2 --noupdate --config extensions.remotenames= -q + $ cd repo2 + $ setup_hg_client + $ cat >> .hg/hgrc < [extensions] + > pushrebase = + > remotenames = + > EOF + +Pull from Mononoke, make sure it fails + $ hgmn pull + pulling from ssh://user@dummy/repo + remote: Authorization failed: Unauthorized access, permission denied + abort: no suitable response from remote hg! + [255]