public void BuildPendingReplicasForRepositoryTest() { string srcBranch = "br:/main/task-001"; string srcRepo = "default"; string srcServer = "JAIR:8087"; List <string> filteredRepos = new List <string>(); List <string> dstServers = new List <string>() { "ssl://myserver.mydomain.com:9095", "calavera.home:7074" }; List <RepoMapping> repoMappings = new List <RepoMapping>(); List <Replica> pendingReplicas = Replica.BuildPendingReplicas( srcBranch, srcRepo, srcServer, filteredRepos, dstServers, repoMappings); Assert.AreEqual(2, pendingReplicas.Count); Replica firstExpectedReplica = new Replica( srcBranch, srcRepo, srcServer, srcRepo, dstServers[0]); Replica secondExpectedReplica = new Replica( srcBranch, srcRepo, srcServer, srcRepo, dstServers[1]); AssertReplicasEqual(firstExpectedReplica, pendingReplicas[0]); AssertReplicasEqual(secondExpectedReplica, pendingReplicas[1]); }
public void BuildPendingReplicasForFilteredRepoTest() { string srcBranch = "br:/main/task-001"; string srcRepo = "default"; string srcServer = "JAIR:8087"; List <string> filteredRepos = new List <string>() { "default" }; List <string> dstServers = new List <string>() { "ssl://myserver.mydomain.com:9095", "calavera.home:7074" }; List <RepoMapping> repoMappings = new List <RepoMapping>(); List <Replica> pendingReplicas = Replica.BuildPendingReplicas( srcBranch, srcRepo, srcServer, filteredRepos, dstServers, repoMappings); Assert.AreEqual(0, pendingReplicas.Count); }
static void RunAfterMakeLabel( List <string> filteredRepos, List <string> dstServers, List <RepoMapping> mappings, string labelName, string repoName, string serverName, ErrorEmailSender emailSender) { Logger.LogInfo("Running as after-makelabel trigger..."); Branch branchToReplicate = null; if (!FindBranchForLabel( labelName, repoName, serverName, out branchToReplicate)) { return; } List <Replica> pendingReplicas = Replica.BuildPendingReplicas( branchToReplicate.BranchName, branchToReplicate.RepositoryName, branchToReplicate.ServerName, filteredRepos, dstServers, mappings); Logger.LogInfo( $"Found {pendingReplicas.Count} destinations to replicate to."); List <Replica> failedReplicas = new List <Replica>(); foreach (Replica pendingReplica in pendingReplicas) { if (!Replicate(pendingReplica)) { failedReplicas.Add(pendingReplica); } } NotifyFailedReplicas( "after-makelabel", failedReplicas, emailSender); }
static void RunAfterCheckin( List <string> filteredRepos, List <string> dstServers, List <RepoMapping> mappings, string csetSpecs, ErrorEmailSender emailSender) { Logger.LogInfo("Running as after-checkin trigger..."); List <Changeset> csets = Changeset.ParsePlasticChangesetEnvironVar(csetSpecs); List <Replica> pendingReplicas = new List <Replica>(); foreach (Changeset cset in csets) { pendingReplicas.AddRange( Replica.BuildPendingReplicas( cset.BranchName, cset.RepositoryName, cset.ServerName, filteredRepos, dstServers, mappings)); } Logger.LogInfo( $"Found {pendingReplicas.Count} destinations to replicate to."); List <Replica> failedReplicas = new List <Replica>(); foreach (Replica pendingReplica in pendingReplicas) { if (!Replicate(pendingReplica)) { failedReplicas.Add(pendingReplica); } } NotifyFailedReplicas( "after-checkin", failedReplicas, emailSender); }
static void RunAfterReplicationWrite( List <string> filteredRepos, List <string> dstServers, List <RepoMapping> mappings, string branchSpec, ErrorEmailSender emailSender) { Logger.LogInfo("Running as after-replicationwrite trigger..."); Branch branchToReplicate = Branch.ParsePlasticBranchEnvironVar(branchSpec); List <Replica> pendingReplicas = Replica.BuildPendingReplicas( branchToReplicate.BranchName, branchToReplicate.RepositoryName, branchToReplicate.ServerName, filteredRepos, dstServers, mappings); Logger.LogInfo( $"Found {pendingReplicas.Count} destinations to replicate to."); List <Replica> failedReplicas = new List <Replica>(); foreach (Replica pendingReplica in pendingReplicas) { if (!Replicate(pendingReplica)) { failedReplicas.Add(pendingReplica); } } NotifyFailedReplicas( "after-replicationwrite", failedReplicas, emailSender); }
static void RunAfterChangeAttributeValue( List <string> filteredRepos, List <string> dstServers, List <RepoMapping> mappings, string triggerStdIn, string repoName, string serverName, ErrorEmailSender emailSender) { Logger.LogInfo("Running as after-chattvalue trigger..."); string objectSpec = triggerStdIn.Substring( startIndex: 0, length: triggerStdIn.IndexOf("attribute:")).Trim(); string objectName = objectSpec.Substring( objectSpec.IndexOf(':') + 1); Branch branchToReplicate = null; if (objectSpec.StartsWith("br:")) { branchToReplicate = new Branch( objectName, repoName, serverName); } if (objectSpec.StartsWith("lb:")) { if (!FindBranchForLabel( objectName, repoName, serverName, out branchToReplicate)) { return; } } if (objectSpec.StartsWith("cs:")) { if (!FindBranchForChangeset( objectName, repoName, serverName, out branchToReplicate)) { return; } } List <Replica> pendingReplicas = Replica.BuildPendingReplicas( branchToReplicate.BranchName, branchToReplicate.RepositoryName, branchToReplicate.ServerName, filteredRepos, dstServers, mappings); Logger.LogInfo( $"Found {pendingReplicas.Count} destinations to replicate to."); List <Replica> failedReplicas = new List <Replica>(); foreach (Replica pendingReplica in pendingReplicas) { if (!Replicate(pendingReplica)) { failedReplicas.Add(pendingReplica); } } NotifyFailedReplicas( "after-chattvalue", failedReplicas, emailSender); }