mirror of
https://github.com/facebook/sapling.git
synced 2024-10-09 08:18:15 +03:00
unbundle: use live_commit_sync_config for push redirection
Summary: This diff enables `unbundle` flow to start creating `push_redirector` structs from hot-reloaded `CommitSyncConfig` (by using the `LiveCommitSyncConfig` struct). Using `LiveCommitSyncConfig` unfortunately means that we need to make sure those tests, which don't use standard fixtures, need to have both the `.toml` and the `.json` commit sync configs present, which is a little verbose. But it's not too horrible. Reviewed By: StanislavGlebik Differential Revision: D21962960 fbshipit-source-id: d355210b5dac50d1b3ad277f99af5bab56c9b62e
This commit is contained in:
parent
ed34e343c5
commit
8c50e0d870
@ -60,7 +60,7 @@ impl FastReplayDispatcher {
|
||||
false, // Don't allow pushes (we don't push)
|
||||
self.wireproto_logging.clone(),
|
||||
None, // Don't push redirect (we don't push)
|
||||
None, // Don't push redirect (we don't push)
|
||||
None, // No need to query live commit sync config
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,7 @@ context = { path = "../server/context" }
|
||||
filenodes = { path = "../filenodes" }
|
||||
getbundle_response = { path = "getbundle_response" }
|
||||
hgproto = { path = "../hgproto" }
|
||||
live_commit_sync_config = { path = "../commit_rewriting/live_commit_sync_config" }
|
||||
load_limiter = { path = "../load_limiter" }
|
||||
manifest = { path = "../manifest" }
|
||||
mercurial_bundles = { path = "../mercurial/bundles" }
|
||||
@ -22,7 +23,6 @@ mercurial_revlog = { path = "../mercurial/revlog" }
|
||||
mercurial_types = { path = "../mercurial/types" }
|
||||
metaconfig_types = { path = "../metaconfig/types" }
|
||||
mononoke_repo = { path = "mononoke_repo" }
|
||||
pushredirect_enable = { path = "../../../configerator/structs/scm/mononoke/pushredirect" }
|
||||
remotefilelog = { path = "remotefilelog" }
|
||||
repo_read_write_status = { path = "repo_read_write_status" }
|
||||
revisionstore_types = { path = "../../scm/lib/revisionstore/types" }
|
||||
@ -31,7 +31,6 @@ streaming_clone = { path = "streaming_clone" }
|
||||
tunables = { path = "../tunables" }
|
||||
unbundle = { path = "unbundle" }
|
||||
bytes_ext = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
cached_config = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
cloned = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
fbinit = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
futures_ext = { git = "https://github.com/facebookexperimental/rust-shed.git", branch = "master" }
|
||||
|
@ -16,7 +16,6 @@ use blobstore::Loadable;
|
||||
use bookmarks::{Bookmark, BookmarkName, BookmarkPrefix};
|
||||
use bytes::Bytes;
|
||||
use bytes_old::{BufMut as BufMutOld, Bytes as BytesOld, BytesMut as BytesMutOld};
|
||||
use cached_config::ConfigHandle;
|
||||
use cloned::cloned;
|
||||
use context::{CoreContext, LoggingContainer, PerfCounterType, SessionContainer};
|
||||
use filenodes::FilenodeResult;
|
||||
@ -41,6 +40,7 @@ use hgproto::{GetbundleArgs, GettreepackArgs, HgCommandRes, HgCommands};
|
||||
use hostname::get_hostname;
|
||||
use itertools::Itertools;
|
||||
use lazy_static::lazy_static;
|
||||
use live_commit_sync_config::LiveCommitSyncConfig;
|
||||
use load_limiter::Metric;
|
||||
use manifest::{Diff, Entry, ManifestOps};
|
||||
use maplit::hashmap;
|
||||
@ -54,7 +54,6 @@ use mercurial_types::{
|
||||
};
|
||||
use metaconfig_types::RepoReadOnly;
|
||||
use mononoke_repo::{MononokeRepo, SqlStreamingCloneConfig};
|
||||
use pushredirect_enable::types::MononokePushRedirectEnable;
|
||||
use rand::{self, Rng};
|
||||
use remotefilelog::{
|
||||
create_getpack_v1_blob, create_getpack_v2_blob, get_unordered_file_history_for_multiple_nodes,
|
||||
@ -356,8 +355,8 @@ pub struct RepoClient {
|
||||
cached_pull_default_bookmarks_maybe_stale: Arc<Mutex<Option<HashMap<Vec<u8>, Vec<u8>>>>>,
|
||||
wireproto_logging: Arc<WireprotoLogging>,
|
||||
maybe_push_redirector_args: Option<PushRedirectorArgs>,
|
||||
pushredirect_config: Option<ConfigHandle<MononokePushRedirectEnable>>,
|
||||
force_lfs: Arc<AtomicBool>,
|
||||
maybe_live_commit_sync_config: Option<LiveCommitSyncConfig>,
|
||||
}
|
||||
|
||||
fn get_pull_default_bookmarks_maybe_stale_raw(
|
||||
@ -415,7 +414,7 @@ impl RepoClient {
|
||||
pure_push_allowed: bool,
|
||||
wireproto_logging: Arc<WireprotoLogging>,
|
||||
maybe_push_redirector_args: Option<PushRedirectorArgs>,
|
||||
pushredirect_config: Option<ConfigHandle<MononokePushRedirectEnable>>,
|
||||
maybe_live_commit_sync_config: Option<LiveCommitSyncConfig>,
|
||||
) -> Self {
|
||||
Self {
|
||||
repo,
|
||||
@ -427,8 +426,8 @@ impl RepoClient {
|
||||
cached_pull_default_bookmarks_maybe_stale: Arc::new(Mutex::new(None)),
|
||||
wireproto_logging,
|
||||
maybe_push_redirector_args,
|
||||
pushredirect_config,
|
||||
force_lfs: Arc::new(AtomicBool::new(false)),
|
||||
maybe_live_commit_sync_config,
|
||||
}
|
||||
}
|
||||
|
||||
@ -867,27 +866,47 @@ impl RepoClient {
|
||||
) -> Result<Option<PushRedirector>> {
|
||||
let push_redirector_args = match self.maybe_push_redirector_args.clone() {
|
||||
Some(push_redirector_args) => push_redirector_args,
|
||||
None => return Ok(None),
|
||||
None => {
|
||||
debug!(
|
||||
ctx.logger(),
|
||||
"maybe_push_redirector_args are none, no push_redirector for unbundle"
|
||||
);
|
||||
return Ok(None);
|
||||
}
|
||||
};
|
||||
|
||||
let repo_id = self.repo.blobrepo().get_repoid();
|
||||
let pushredirect_config = self.pushredirect_config.as_ref();
|
||||
let maybe_config = pushredirect_config.map(|config| config.get());
|
||||
|
||||
let enabled = maybe_config.and_then(move |config| {
|
||||
config.per_repo.get(&(repo_id.id() as i64)).map(|enables| {
|
||||
match self.maybe_live_commit_sync_config {
|
||||
None => Ok(None),
|
||||
Some(ref live_commit_sync_config) => {
|
||||
use unbundle::PostResolveAction::*;
|
||||
|
||||
match action {
|
||||
InfinitePush(_) => enables.draft_push,
|
||||
Push(_) | PushRebase(_) | BookmarkOnlyPushRebase(_) => enables.public_push,
|
||||
}
|
||||
})
|
||||
});
|
||||
let repo_id = self.repo.blobrepo().get_repoid();
|
||||
let redirect = match action {
|
||||
InfinitePush(_) => {
|
||||
live_commit_sync_config.push_redirector_enabled_for_draft(repo_id)
|
||||
}
|
||||
Push(_) | PushRebase(_) | BookmarkOnlyPushRebase(_) => {
|
||||
live_commit_sync_config.push_redirector_enabled_for_public(repo_id)
|
||||
}
|
||||
};
|
||||
|
||||
match enabled {
|
||||
None | Some(false) => Ok(None),
|
||||
Some(true) => Ok(Some(push_redirector_args.into_push_redirector(ctx)?)),
|
||||
if redirect {
|
||||
debug!(
|
||||
ctx.logger(),
|
||||
"live_commit_sync_config says push redirection is on"
|
||||
);
|
||||
Ok(Some(push_redirector_args.into_push_redirector(
|
||||
ctx,
|
||||
&self.maybe_live_commit_sync_config,
|
||||
)?))
|
||||
} else {
|
||||
debug!(
|
||||
ctx.logger(),
|
||||
"live_commit_sync_config says push redirection is off"
|
||||
);
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -512,8 +512,8 @@ async fn run_and_check_if_lfs(
|
||||
false, // Don't allow pushes (we don't push)
|
||||
true, // Support bundle2_listkeys
|
||||
Arc::new(noop_wireproto),
|
||||
None, // Don't push redirect (we don't push)
|
||||
None, // Don't push redirect (we don't push)
|
||||
None, // No PushRedirectorArgs
|
||||
None, // Don't listen to LiveCommitSyncConfig
|
||||
);
|
||||
|
||||
let bytes = repo_client
|
||||
|
@ -16,4 +16,4 @@ mod errors;
|
||||
pub use client::{fetch_treepack_part_input, gettreepack_entries, RepoClient, WireprotoLogging};
|
||||
pub use mononoke_repo::{streaming_clone, MononokeRepo, MononokeRepoBuilder};
|
||||
pub use repo_read_write_status::RepoReadWriteFetcher;
|
||||
pub use unbundle::{PushRedirector, PushRedirectorArgs, CONFIGERATOR_PUSHREDIRECT_ENABLE};
|
||||
pub use unbundle::{PushRedirector, PushRedirectorArgs};
|
||||
|
@ -21,6 +21,7 @@ git_mapping_pushrebase_hook = { path = "../../bonsai_git_mapping/git_mapping_pus
|
||||
globalrev_pushrebase_hook = { path = "../../bonsai_globalrev_mapping/globalrev_pushrebase_hook" }
|
||||
hooks = { path = "../../hooks" }
|
||||
limits = { path = "../../../../configerator/structs/scm/mononoke/loadshedding" }
|
||||
live_commit_sync_config = { path = "../../commit_rewriting/live_commit_sync_config" }
|
||||
mercurial_bundles = { path = "../../mercurial/bundles" }
|
||||
mercurial_mutation = { path = "../../mercurial/mutation" }
|
||||
mercurial_revlog = { path = "../../mercurial/revlog" }
|
||||
|
@ -25,7 +25,7 @@ mod upload_changesets;
|
||||
|
||||
pub use hook_running::{run_hooks, run_remapped_hooks};
|
||||
pub use processing::{get_pushrebase_hooks, run_post_resolve_action};
|
||||
pub use push_redirector::{PushRedirector, PushRedirectorArgs, CONFIGERATOR_PUSHREDIRECT_ENABLE};
|
||||
pub use push_redirector::{PushRedirector, PushRedirectorArgs};
|
||||
pub use resolver::{
|
||||
resolve, BundleResolverError, Changesets, CommonHeads, InfiniteBookmarkPush,
|
||||
NonFastForwardPolicy, PlainBookmarkPush, PostResolveAction, PostResolveBookmarkOnlyPushRebase,
|
||||
|
@ -36,6 +36,7 @@ use futures::{
|
||||
try_join,
|
||||
};
|
||||
use futures_ext::{try_boxfuture, FutureExt as OldFutureExt};
|
||||
use live_commit_sync_config::LiveCommitSyncConfig;
|
||||
use metaconfig_types::CommitSyncConfig;
|
||||
use mononoke_repo::MononokeRepo;
|
||||
use mononoke_types::{BonsaiChangeset, ChangesetId};
|
||||
@ -47,8 +48,6 @@ use synced_commit_mapping::{SqlSyncedCommitMapping, SyncedCommitMapping};
|
||||
use topo_sort::sort_topological;
|
||||
use tunables::tunables;
|
||||
|
||||
pub const CONFIGERATOR_PUSHREDIRECT_ENABLE: &str = "scm/mononoke/pushredirect/enable";
|
||||
|
||||
/// An auxillary struct, which contains nearly
|
||||
/// everything needed to create a full `PushRedirector`
|
||||
/// This is intended to be used to create a new
|
||||
@ -81,18 +80,29 @@ impl PushRedirectorArgs {
|
||||
}
|
||||
|
||||
/// Create `PushRedirector` for a given source repo
|
||||
pub fn into_push_redirector(self, ctx: &CoreContext) -> Result<PushRedirector, Error> {
|
||||
pub fn into_push_redirector(
|
||||
self,
|
||||
ctx: &CoreContext,
|
||||
maybe_live_commit_sync_config: &Option<LiveCommitSyncConfig>,
|
||||
) -> Result<PushRedirector, Error> {
|
||||
// TODO: This function needs to be extended
|
||||
// and query configerator for the fresh
|
||||
// value of `commit_sync_config`
|
||||
let PushRedirectorArgs {
|
||||
commit_sync_config,
|
||||
commit_sync_config: original_commit_sync_config,
|
||||
target_repo,
|
||||
source_blobrepo,
|
||||
synced_commit_mapping,
|
||||
target_repo_dbs,
|
||||
} = self;
|
||||
|
||||
debug!(ctx.logger(), "Original: {:?}", original_commit_sync_config);
|
||||
let commit_sync_config = match maybe_live_commit_sync_config {
|
||||
None => original_commit_sync_config,
|
||||
Some(live_commmit_sync_config) => live_commmit_sync_config
|
||||
.get_current_commit_sync_config(&ctx, source_blobrepo.get_repoid())?,
|
||||
};
|
||||
|
||||
let small_repo = source_blobrepo;
|
||||
let large_repo = target_repo.blobrepo().clone();
|
||||
let mapping: Arc<dyn SyncedCommitMapping> = Arc::new(synced_commit_mapping);
|
||||
|
@ -19,11 +19,11 @@ hgproto = { path = "../../hgproto" }
|
||||
hooks = { path = "../../hooks" }
|
||||
hooks_content_stores = { path = "../../hooks/content-stores" }
|
||||
limits = { path = "../../../../configerator/structs/scm/mononoke/loadshedding" }
|
||||
live_commit_sync_config = { path = "../../commit_rewriting/live_commit_sync_config" }
|
||||
load_limiter = { path = "../../load_limiter" }
|
||||
metaconfig_types = { path = "../../metaconfig/types" }
|
||||
mononoke_types = { path = "../../mononoke_types" }
|
||||
permission_checker = { path = "../../permission_checker" }
|
||||
pushredirect_enable = { path = "../../../../configerator/structs/scm/mononoke/pushredirect" }
|
||||
repo_client = { path = "../../repo_client" }
|
||||
scuba_ext = { path = "../../common/scuba_ext" }
|
||||
slog_ext = { path = "../../common/rust/slog_ext" }
|
||||
|
@ -26,13 +26,13 @@ use futures_old::sync::mpsc;
|
||||
use futures_old::{future, stream, Async, Future, IntoFuture, Poll, Sink, Stream};
|
||||
use itertools::join;
|
||||
use lazy_static::lazy_static;
|
||||
use live_commit_sync_config::LiveCommitSyncConfig;
|
||||
use metaconfig_types::{AllowlistEntry, CommonConfig};
|
||||
use openssl::ssl::SslAcceptor;
|
||||
use permission_checker::{
|
||||
BoxMembershipChecker, BoxPermissionChecker, MembershipCheckerBuilder, MononokeIdentity,
|
||||
MononokeIdentitySet, PermissionCheckerBuilder,
|
||||
};
|
||||
use repo_client::CONFIGERATOR_PUSHREDIRECT_ENABLE;
|
||||
use scuba_ext::ScubaSampleBuilderExt;
|
||||
use slog::{crit, error, o, Drain, Level, Logger};
|
||||
use slog_kvfilter::KVFilter;
|
||||
@ -43,7 +43,6 @@ use tokio_openssl::SslAcceptorExt;
|
||||
|
||||
use cmdlib::monitoring::ReadyFlagService;
|
||||
use limits::types::MononokeThrottleLimits;
|
||||
use pushredirect_enable::types::MononokePushRedirectEnable;
|
||||
use sshrelay::{SenderBytesWrite, SshDecoder, SshEncoder, SshMsg, SshStream, Stdio};
|
||||
|
||||
use crate::errors::ErrorKind;
|
||||
@ -81,7 +80,7 @@ pub fn connection_acceptor(
|
||||
.expect("failed to create listener")
|
||||
.map_err(Error::from);
|
||||
|
||||
let (load_limiting_config, pushredirect_config) = match config_store {
|
||||
let (load_limiting_config, maybe_live_commit_sync_config) = match config_store {
|
||||
Some(config_store) => {
|
||||
let load_limiting_config = {
|
||||
let config_loader = config_store
|
||||
@ -95,10 +94,10 @@ pub fn connection_acceptor(
|
||||
})
|
||||
};
|
||||
|
||||
let pushredirect_config = Some(try_boxfuture!(
|
||||
config_store.get_config_handle(CONFIGERATOR_PUSHREDIRECT_ENABLE.to_string(),)
|
||||
));
|
||||
(load_limiting_config, pushredirect_config)
|
||||
let maybe_live_commit_sync_config = Some(try_boxfuture!({
|
||||
LiveCommitSyncConfig::new(&root_log, &config_store)
|
||||
}));
|
||||
(load_limiting_config, maybe_live_commit_sync_config)
|
||||
}
|
||||
None => (None, None),
|
||||
};
|
||||
@ -116,7 +115,7 @@ pub fn connection_acceptor(
|
||||
// Accept the request without blocking the listener
|
||||
cloned!(
|
||||
load_limiting_config,
|
||||
pushredirect_config,
|
||||
maybe_live_commit_sync_config,
|
||||
root_log,
|
||||
repo_handlers,
|
||||
tls_acceptor,
|
||||
@ -132,7 +131,7 @@ pub fn connection_acceptor(
|
||||
tls_acceptor,
|
||||
security_checker.clone(),
|
||||
load_limiting_config.clone(),
|
||||
pushredirect_config.clone(),
|
||||
maybe_live_commit_sync_config.clone(),
|
||||
)
|
||||
.then(|res| {
|
||||
OPEN_CONNECTIONS.fetch_sub(1, Ordering::Relaxed);
|
||||
@ -153,7 +152,7 @@ fn accept(
|
||||
tls_acceptor: Arc<SslAcceptor>,
|
||||
security_checker: Arc<ConnectionsSecurityChecker>,
|
||||
load_limiting_config: Option<(ConfigHandle<MononokeThrottleLimits>, String)>,
|
||||
pushredirect_config: Option<ConfigHandle<MononokePushRedirectEnable>>,
|
||||
maybe_live_commit_sync_config: Option<LiveCommitSyncConfig>,
|
||||
) -> impl Future<Item = (), Error = ()> {
|
||||
let addr = sock.peer_addr();
|
||||
|
||||
@ -253,8 +252,8 @@ fn accept(
|
||||
handler,
|
||||
stdio,
|
||||
load_limiting_config,
|
||||
pushredirect_config,
|
||||
addr.ip(),
|
||||
maybe_live_commit_sync_config,
|
||||
)
|
||||
.map(Ok)
|
||||
.boxed()
|
||||
|
@ -29,7 +29,7 @@ use metaconfig_types::{CommitSyncConfig, RepoConfig, WireprotoLoggingConfig};
|
||||
use mononoke_types::RepositoryId;
|
||||
use repo_client::{MononokeRepo, MononokeRepoBuilder, PushRedirectorArgs, WireprotoLogging};
|
||||
use scuba_ext::{ScubaSampleBuilder, ScubaSampleBuilderExt};
|
||||
use slog::{info, o, Logger};
|
||||
use slog::{debug, info, o, Logger};
|
||||
use sql_construct::SqlConstructFromMetadataDatabaseConfig;
|
||||
use sql_ext::facebook::MysqlOptions;
|
||||
|
||||
@ -287,12 +287,22 @@ pub fn repo_handlers(
|
||||
)
|
||||
.await?;
|
||||
|
||||
info!(logger, "Constructing incomplete push redirection args");
|
||||
let maybe_incomplete_push_redirector_args =
|
||||
commit_sync_config.and_then(move |commit_sync_config| {
|
||||
let maybe_incomplete_push_redirector_args = commit_sync_config.and_then({
|
||||
cloned!(logger);
|
||||
move |commit_sync_config| {
|
||||
if commit_sync_config.large_repo_id == blobrepo.get_repoid() {
|
||||
debug!(
|
||||
logger,
|
||||
"Not constructing push redirection args: {:?}",
|
||||
blobrepo.get_repoid()
|
||||
);
|
||||
None
|
||||
} else {
|
||||
debug!(
|
||||
logger,
|
||||
"Constructing incomplete push redirection args: {:?}",
|
||||
blobrepo.get_repoid()
|
||||
);
|
||||
Some(IncompletePushRedirectorArgs {
|
||||
commit_sync_config,
|
||||
synced_commit_mapping: sql_commit_sync_mapping,
|
||||
@ -300,7 +310,8 @@ pub fn repo_handlers(
|
||||
source_blobrepo: blobrepo,
|
||||
})
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
initial_warmup.await??;
|
||||
|
||||
|
@ -20,9 +20,9 @@ use futures_stats::TimedFutureExt;
|
||||
use hgproto::{sshproto, HgProtoHandler};
|
||||
use lazy_static::lazy_static;
|
||||
use limits::types::{MononokeThrottleLimit, MononokeThrottleLimits, RateLimits};
|
||||
use live_commit_sync_config::LiveCommitSyncConfig;
|
||||
use load_limiter::{LoadLimiterBuilder, Metric};
|
||||
use maplit::{hashmap, hashset};
|
||||
use pushredirect_enable::types::MononokePushRedirectEnable;
|
||||
use ratelimit_meter::{algorithms::LeakyBucket, DirectRateLimiter};
|
||||
use repo_client::RepoClient;
|
||||
use scuba_ext::ScubaSampleBuilderExt;
|
||||
@ -117,8 +117,8 @@ pub async fn request_handler(
|
||||
}: RepoHandler,
|
||||
stdio: Stdio,
|
||||
load_limiting_config: Option<(ConfigHandle<MononokeThrottleLimits>, String)>,
|
||||
pushredirect_config: Option<ConfigHandle<MononokePushRedirectEnable>>,
|
||||
addr: IpAddr,
|
||||
maybe_live_commit_sync_config: Option<LiveCommitSyncConfig>,
|
||||
) {
|
||||
let Stdio {
|
||||
stdin,
|
||||
@ -239,7 +239,7 @@ pub async fn request_handler(
|
||||
pure_push_allowed,
|
||||
wireproto_logging,
|
||||
maybe_push_redirector_args,
|
||||
pushredirect_config,
|
||||
maybe_live_commit_sync_config,
|
||||
),
|
||||
sshproto::HgSshCommandDecode,
|
||||
sshproto::HgSshCommandEncode,
|
||||
|
@ -0,0 +1,205 @@
|
||||
# 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
|
||||
$ REPOTYPE="blob_files"
|
||||
$ REPOID=0 REPONAME=large-mon setup_common_config $REPOTYPE
|
||||
$ REPOID=1 REPONAME=small-mon-1 setup_common_config $REPOTYPE
|
||||
$ cat >> "$TESTTMP/mononoke-config/common/commitsyncmap.toml" <<EOF
|
||||
> [megarepo_test]
|
||||
> large_repo_id = 0
|
||||
> common_pushrebase_bookmarks = ["master_bookmark"]
|
||||
> [[megarepo_test.small_repos]]
|
||||
> repoid = 1
|
||||
> bookmark_prefix = "bookprefix1/"
|
||||
> default_action = "prepend_prefix"
|
||||
> default_prefix = "smallrepofolder1"
|
||||
> direction = "large_to_small"
|
||||
> [megarepo_test.small_repos.mapping]
|
||||
> "special"="specialsmallrepofolder1"
|
||||
> EOF
|
||||
|
||||
setup configerator configs
|
||||
$ setup_configerator_configs
|
||||
$ cat > "$PUSHREDIRECT_CONF/enable" <<EOF
|
||||
> {
|
||||
> "per_repo": {
|
||||
> "1": {
|
||||
> "draft_push": false,
|
||||
> "public_push": true
|
||||
> }
|
||||
> }
|
||||
> }
|
||||
> EOF
|
||||
$ cat > "$COMMIT_SYNC_CONF/current" <<EOF
|
||||
> {
|
||||
> "repos": {
|
||||
> "megarepo_test": {
|
||||
> "large_repo_id": 0,
|
||||
> "common_pushrebase_bookmarks": [
|
||||
> "master_bookmark"
|
||||
> ],
|
||||
> "small_repos": [
|
||||
> {
|
||||
> "repoid": 1,
|
||||
> "default_action": "prepend_prefix",
|
||||
> "default_prefix": "smallrepofolder1",
|
||||
> "bookmark_prefix": "bookprefix1/",
|
||||
> "mapping": {
|
||||
> "special": "specialsmallrepofolder1"
|
||||
> },
|
||||
> "direction": "large_to_small"
|
||||
> }
|
||||
> ],
|
||||
> "version_name": "TEST_VERSION_NAME_LIVE_V1"
|
||||
> }
|
||||
> }
|
||||
> }
|
||||
> EOF
|
||||
|
||||
setup hg server repos
|
||||
$ function createfile { mkdir -p "$(dirname $1)" && echo "$1" > "$1" && hg add -q "$1"; }
|
||||
$ function create_first_post_move_commit {
|
||||
> echo 1 > "$1/filetoremove" && hg add "$1/filetoremove" && hg ci -m 'first post-move commit'
|
||||
> hg revert -r .^ "$1/filetoremove"
|
||||
> }
|
||||
|
||||
$ cd $TESTTMP
|
||||
$ hginit_treemanifest small-hg-srv-1
|
||||
$ cd "$TESTTMP/small-hg-srv-1"
|
||||
$ echo 1 > file.txt
|
||||
$ hg addremove -q && hg ci -q -m 'pre-move commit 1'
|
||||
|
||||
$ cd "$TESTTMP"
|
||||
$ cp -r small-hg-srv-1 large-hg-srv
|
||||
$ cd large-hg-srv
|
||||
$ mkdir smallrepofolder1
|
||||
$ hg mv file.txt smallrepofolder1/file.txt
|
||||
$ hg ci -m 'move commit'
|
||||
$ mkdir smallrepofolder2
|
||||
$ echo 2 > smallrepofolder2/file.txt
|
||||
$ hg addremove -q
|
||||
$ hg ci -m "move commit for repo 2"
|
||||
$ create_first_post_move_commit smallrepofolder1
|
||||
$ hg book -r . master_bookmark
|
||||
|
||||
$ cd "$TESTTMP/small-hg-srv-1"
|
||||
$ create_first_post_move_commit .
|
||||
$ hg book -r . master_bookmark
|
||||
|
||||
blobimport hg servers repos into Mononoke repos
|
||||
$ cd $TESTTMP
|
||||
$ REPOIDLARGE=0
|
||||
$ REPOIDSMALL1=1
|
||||
$ REPOID="$REPOIDLARGE" blobimport large-hg-srv/.hg large-mon
|
||||
$ REPOID="$REPOIDSMALL1" blobimport small-hg-srv-1/.hg small-mon-1
|
||||
|
||||
setup hg client repos
|
||||
$ function init_client() {
|
||||
> cd "$TESTTMP"
|
||||
> hgclone_treemanifest ssh://user@dummy/"$1" "$2" --noupdate --config extensions.remotenames=
|
||||
> cd "$TESTTMP/$2"
|
||||
> cat >> .hg/hgrc <<EOF
|
||||
> [extensions]
|
||||
> pushrebase =
|
||||
> remotenames =
|
||||
> EOF
|
||||
> }
|
||||
|
||||
$ init_client small-hg-srv-1 small-hg-client-1
|
||||
$ cd "$TESTTMP"
|
||||
$ init_client large-hg-srv large-hg-client
|
||||
|
||||
Setup helpers
|
||||
$ LARGE_MASTER_BONSAI=$(get_bonsai_bookmark $REPOIDLARGE master_bookmark)
|
||||
$ SMALL1_MASTER_BONSAI=$(get_bonsai_bookmark $REPOIDSMALL1 master_bookmark)
|
||||
|
||||
start mononoke server
|
||||
$ mononoke --local-configerator-path="$TESTTMP/configerator"
|
||||
$ wait_for_mononoke
|
||||
|
||||
Make sure mapping is set up and we know what we don't have to sync initial entries
|
||||
$ add_synced_commit_mapping_entry $REPOIDSMALL1 $SMALL1_MASTER_BONSAI $REPOIDLARGE $LARGE_MASTER_BONSAI
|
||||
$ sqlite3 "$TESTTMP/monsql/sqlite_dbs" "INSERT INTO mutable_counters (repo_id, name, value) VALUES ($REPOIDSMALL1, 'backsync_from_$REPOIDLARGE', 2)";
|
||||
|
||||
Normal pushrebase with one commit
|
||||
$ cd "$TESTTMP/small-hg-client-1"
|
||||
$ REPONAME=small-mon-1 hgmn up -q master_bookmark
|
||||
$ echo 2 > 2 && hg addremove -q && hg ci -q -m newcommit
|
||||
$ REPONAME=small-mon-1 hgmn push -r . --to master_bookmark | grep updating
|
||||
updating bookmark master_bookmark
|
||||
-- newcommit was correctly pushed to master_bookmark
|
||||
$ log -r master_bookmark
|
||||
@ newcommit [public;rev=2;6989db12d1e5] default/master_bookmark
|
||||
|
|
||||
~
|
||||
|
||||
-- newcommit is also present in the large repo (after a pull)
|
||||
$ cd "$TESTTMP"/large-hg-client
|
||||
$ log -r master_bookmark
|
||||
o first post-move commit [public;rev=3;bca7e9574548] default/master_bookmark
|
||||
|
|
||||
~
|
||||
$ REPONAME=large-mon hgmn pull -q
|
||||
$ log -r master_bookmark
|
||||
o newcommit [public;rev=4;7c9a729ceb57] default/master_bookmark
|
||||
|
|
||||
~
|
||||
|
||||
Live change of the config, without Mononoke restart
|
||||
$ cat > "$COMMIT_SYNC_CONF/current" <<EOF
|
||||
> {
|
||||
> "repos": {
|
||||
> "megarepo_test": {
|
||||
> "large_repo_id": 0,
|
||||
> "common_pushrebase_bookmarks": [
|
||||
> "master_bookmark"
|
||||
> ],
|
||||
> "small_repos": [
|
||||
> {
|
||||
> "repoid": 1,
|
||||
> "default_action": "prepend_prefix",
|
||||
> "default_prefix": "smallrepofolder1",
|
||||
> "bookmark_prefix": "bookprefix1/",
|
||||
> "mapping": {
|
||||
> "special": "specialsmallrepofolder_after_change"
|
||||
> },
|
||||
> "direction": "large_to_small"
|
||||
> }
|
||||
> ],
|
||||
> "version_name": "TEST_VERSION_NAME_LIVE_V2"
|
||||
> }
|
||||
> }
|
||||
> }
|
||||
> EOF
|
||||
-- sleep to ensure live_commit_sync_config had a chance to refresh
|
||||
$ sleep 1
|
||||
|
||||
$ sqlite3 "$TESTTMP/monsql/sqlite_dbs" "SELECT small_repo_id, large_repo_id, sync_map_version_name FROM synced_commit_mapping";
|
||||
1|0|
|
||||
1|0|TEST_VERSION_NAME_LIVE_V1
|
||||
|
||||
Again, normal pushrebase with one commit
|
||||
$ cd "$TESTTMP/small-hg-client-1"
|
||||
$ hg st
|
||||
$ REPONAME=small-mon-1 hgmn up -q master_bookmark
|
||||
$ mkdir -p special
|
||||
$ echo f > special/f && hg ci -Aqm post_config_change_commit
|
||||
$ REPONAME=small-mon-1 hgmn push -r . --to master_bookmark | grep updating
|
||||
updating bookmark master_bookmark
|
||||
|
||||
-- in the large repo, new commit touched an after_change path
|
||||
$ cd "$TESTTMP"/large-hg-client
|
||||
$ REPONAME=large-mon hgmn pull -q
|
||||
$ REPONAME=large-mon hgmn log -T "{files % '{file}\n'}" -r master_bookmark
|
||||
specialsmallrepofolder_after_change/f
|
||||
|
||||
$ sqlite3 "$TESTTMP/monsql/sqlite_dbs" "SELECT small_repo_id, large_repo_id, sync_map_version_name FROM synced_commit_mapping";
|
||||
1|0|
|
||||
1|0|TEST_VERSION_NAME_LIVE_V1
|
||||
1|0|TEST_VERSION_NAME_LIVE_V2
|
@ -45,6 +45,41 @@ setup configerator configs
|
||||
> }
|
||||
> }
|
||||
> EOF
|
||||
$ cat > "$COMMIT_SYNC_CONF/current" <<EOF
|
||||
> {
|
||||
> "repos": {
|
||||
> "megarepo_test": {
|
||||
> "large_repo_id": 0,
|
||||
> "common_pushrebase_bookmarks": [
|
||||
> "master_bookmark"
|
||||
> ],
|
||||
> "small_repos": [
|
||||
> {
|
||||
> "repoid": 1,
|
||||
> "default_action": "prepend_prefix",
|
||||
> "default_prefix": "smallrepofolder1",
|
||||
> "bookmark_prefix": "bookprefix1/",
|
||||
> "mapping": {
|
||||
> "special": "specialsmallrepofolder1"
|
||||
> },
|
||||
> "direction": "large_to_small"
|
||||
> },
|
||||
> {
|
||||
> "repoid": 2,
|
||||
> "default_action": "prepend_prefix",
|
||||
> "default_prefix": "smallrepofolder2",
|
||||
> "bookmark_prefix": "bookprefix2/",
|
||||
> "mapping": {
|
||||
> "special": "specialsmallrepofolder2"
|
||||
> },
|
||||
> "direction": "small_to_large"
|
||||
> }
|
||||
> ],
|
||||
> "version_name": "TEST_VERSION_NAME_LIVE"
|
||||
> }
|
||||
> }
|
||||
> }
|
||||
> EOF
|
||||
|
||||
Verification function
|
||||
$ function verify_wc() {
|
||||
|
Loading…
Reference in New Issue
Block a user