protected void InitBuildSource(string InProjectName, FileReference InProjectPath, DirectoryReference InUnrealPath, bool InUsesSharedBuildType, string InBuildArgument, Func <string, string> ResolutionDelegate) { UnrealPath = InUnrealPath; UsesSharedBuildType = InUsesSharedBuildType; ProjectPath = InProjectPath; ProjectName = InProjectName; // Resolve the build argument into something meaningful string ResolvedBuildName; IEnumerable <string> ResolvedPaths = null; if (!ResolveBuildReference(InBuildArgument, ResolutionDelegate, out ResolvedPaths, out ResolvedBuildName)) { throw new AutomationException("Unable to resolve {0} to a valid build", InBuildArgument); } BuildName = ResolvedBuildName; BuildPaths = ResolvedPaths; DiscoveredBuilds = DiscoverBuilds(); if (DiscoveredBuilds.Count() == 0) { throw new AutomationException("No builds were discovered from resolved build argument {0}", InBuildArgument); } // any Branch/CL info? Match M = Regex.Match(BuildName, @"(\+\+.+)-CL-(\d+)"); if (M.Success) { Branch = M.Groups[1].Value.Replace("+", "/"); Changelist = Convert.ToInt32(M.Groups[2].Value); } else { Branch = ""; Changelist = 0; } // allow user overrides (TODO - centralize all this!) Branch = Globals.Params.ParseValue("branch", Branch); Changelist = Convert.ToInt32(Globals.Params.ParseValue("changelist", Changelist.ToString())); }
public void SetStreamTest() { bool unicode = false; string uri = "localhost:6666"; string user = "******"; string pass = string.Empty; string ws_client = "admin_space"; for (int i = 0; i < 1; i++) // run once for ascii, once for unicode { Process p4d = Utilities.DeployP4TestServer(TestDir, 6, unicode); Server server = new Server(new ServerAddress(uri)); try { Repository rep = new Repository(server); using (Connection con = rep.Connection) { con.UserName = user; con.Client = new Client(); con.Client.Name = ws_client; Changelist change = new Changelist(); change.initialize(con); // Add Stream field change.Stream = "//test/stream1"; // Convert change object to string string changeString = change.ToString(); Assert.AreEqual(changeString, "Change:\tnew\n\nDate:\t\n\nClient:\t\n\nUser:\t\n\nStatus:\tnew\n\nStream:\t//test/stream1\n\nDescription:\n\t\n\nJobs:\n\n\nFiles:\n"); } } finally { Utilities.RemoveTestServer(p4d, TestDir); } unicode = !unicode; } }
public void ToStringTest() { Changelist target = new Changelist(); string spec = testChangelistSpec; bool expected = true; bool actual; actual = target.Parse(spec); Assert.AreEqual(expected, actual); Changelist target2 = new Changelist(); string newSpec = target.ToString(); expected = true; actual = target2.Parse(newSpec); Assert.AreEqual(expected, actual); Assert.AreEqual(target.Id, target2.Id); Assert.AreEqual(target.Description, target2.Description); Assert.AreEqual(target.ClientId, target2.ClientId); Assert.AreEqual(target.Jobs.Count, target2.Jobs.Count); Assert.AreEqual(target.Files.Count, target2.Files.Count); }
private string Deployment2GceArgs(string tag = "", string MachineType = "n1-standard-16", string Zone = "us-central1-a", string Region = "NA", int InstanceSize = 1, int InstanceSizeMin = 1, int InstanceSizeMax = 6, string AutoscalerId = "default", string ExtraCliArgs = "", string AppNameStringOverride = "", string HubServerName = "") { int LocalCpuBudget = CpuBudget; UnrealTournamentBuild.UnrealTournamentAppName LocalAppName = AppName; if (!String.IsNullOrEmpty(AppNameStringOverride)) { if (!Enum.IsDefined(typeof(UnrealTournamentBuild.UnrealTournamentAppName), AppNameStringOverride)) { throw new AutomationException("Trying to override AppName to non-existant type: " + AppNameStringOverride); } LocalAppName = (UnrealTournamentBuild.UnrealTournamentAppName)Enum.Parse(typeof(UnrealTournamentBuild.UnrealTournamentAppName), AppNameStringOverride); CommandUtils.Log("Overriding AppName from {0} to {1}", AppName, LocalAppName); } string NetworkId = "default"; string CredentialsFile = "GceUtDevCredentials.txt"; /* This is very confusing. UnrealTournament's live lable is UnrealTournamentDev. */ if (LocalAppName == UnrealTournamentBuild.UnrealTournamentAppName.UnrealTournamentDev) { NetworkId = "unreal-tournament"; CredentialsFile = "GceUtLiveCredentials.txt"; } if (InstanceSize == 0) { InstanceSizeMin = 0; InstanceSizeMax = 0; } else if (InstanceSizeMin > InstanceSize) { InstanceSize = InstanceSizeMin; } string CredentialsFilePath = GetUtilitiesFilePath(CredentialsFile); string CredentialsFileContentsBase64 = ReadFileContents(CredentialsFilePath); string CredentialsFileContents = ConvertFromBase64(CredentialsFileContentsBase64); GceCredentials gceCredentials = GceCredentialsFromJson(CredentialsFileContents); string HTTPCredentialsFilePath = GetUtilitiesFilePath("DeployerAuthBase64.txt"); if (File.Exists(HTTPCredentialsFilePath)) { string HTTPCredentialsFileContentsBase64 = ReadFileContents(HTTPCredentialsFilePath); HTTPAuthBase64 = HTTPCredentialsFileContentsBase64; } Byte[] CliArgBytes; if (HubServerName != "") { CliArgBytes = System.Text.Encoding.UTF8.GetBytes("UnrealTournament ut-entry?game=lobby?ServerName=\"" + HubServerName + "\" -nocore -epicapp=" + LocalAppName.ToString() + " " + ExtraCliArgs); LocalCpuBudget = 32000; } else { CliArgBytes = System.Text.Encoding.UTF8.GetBytes("UnrealTournament ut-entry?game=empty?region=" + Region + " -epicapp=" + LocalAppName.ToString() + " " + ExtraCliArgs); } Byte[] BuildStringBytes = System.Text.Encoding.UTF8.GetBytes(BuildString); string CloudArgs = "epic_game_name=" + GameNameShort + "&" + "epic_game_binary=" + this.GameBinary + "&" + "epic_game_binary_path=" + this.GameBinaryPath + "&" + "epic_game_log_path=" + this.GameLogPath + "&" + "epic_game_saved_path=" + this.GameSavedPath + "&" + "epic_game_max_match_length=" + this.MaxMatchLength.ToString() + "&" + "epic_game_ttl_interval=" + this.TtlInterval.ToString() + "&" + "epic_install_sumo=" + this.InstallSumo + "&" + "epic_game_tag=" + GetTag(LocalAppName, Region, tag) + "&" + "epic_game_version=" + Changelist.ToString() + "&" + "epic_game_region=" + Region + "&" + "epic_game_cpu_budget=" + LocalCpuBudget + "&" + "epic_game_ram_budget=" + RamBudget + "&" + "epic_game_buildstr_base64=" + System.Convert.ToBase64String(BuildStringBytes) + "&" + "epic_game_environment=" + LocalAppName.ToString() + "&" + "epic_instance_size=" + InstanceSize.ToString() + "&" + "epic_instance_min=" + InstanceSizeMin.ToString() + "&" + "epic_instance_max=" + InstanceSizeMax.ToString() + "&" + "epic_autoscaler_id=" + AutoscalerId + "&" + "epic_gce_project_id=" + gceCredentials.project_id + "&" + "epic_gce_base64_credentials=" + CredentialsFileContentsBase64 + "&" + "epic_gce_machine_type=" + MachineType + "&" + "epic_gce_network=" + NetworkId + "&" + "epic_gce_zone=" + Zone + "&" + "epic_game_base64_cli_args=" + System.Convert.ToBase64String(CliArgBytes); return(CloudArgs); }
private string Deployment2AwsArgs(string tag = "", string InstanceType = "c4.4xlarge", string AwsRegion = "us-east-1", /* AU ap-southeast-2. KR ap-northeast-2 */ string Region = "NA", /* KR South Korea. AU Australia */ int InstanceSize = 1, int InstanceSizeMin = 1, int InstanceSizeMax = 6, string AutoscalerId = "default", string ExtraCliArgs = "", string HubServerName = "") { string AwsCredentialsFile = "AwsDedicatedServerCredentialsDecoded.txt"; int LocalCpuBudget = CpuBudget; if (InstanceSize == 0) { InstanceSizeMin = 0; InstanceSizeMax = 0; } else if (InstanceSizeMin > InstanceSize) { InstanceSize = InstanceSizeMin; } string CredentialsFilePath = GetUtilitiesFilePath(AwsCredentialsFile); string AwsCredentials = ReadFileContents(CredentialsFilePath); string[] AwsCredentialsList = AwsCredentials.Split(':'); if (AwsCredentialsList.Length != 2) { throw new AutomationException("Unable to parse credentials from file {0} {1}", AwsCredentialsFile, AwsCredentials); } string AwsAccessKey = AwsCredentialsList[0]; Byte[] AwsAccessSecretKeyBytes = System.Text.Encoding.UTF8.GetBytes(AwsCredentialsList[1]); Byte[] CliArgBytes; if (HubServerName != "") { CliArgBytes = System.Text.Encoding.UTF8.GetBytes("UnrealTournament ut-entry?game=lobby?ServerName=\"" + HubServerName + "\" -nocore -epicapp=" + AppName.ToString() + " " + ExtraCliArgs); LocalCpuBudget = 32000; } else { CliArgBytes = System.Text.Encoding.UTF8.GetBytes("UnrealTournament ut-entry?game=empty?region=" + Region + " -epicapp=" + AppName.ToString() + " " + ExtraCliArgs); } Byte[] BuildStringBytes = System.Text.Encoding.UTF8.GetBytes(BuildString); string CloudArgs = "epic_game_name=" + GameNameShort + "&" + "epic_game_binary=" + this.GameBinary + "&" + "epic_game_binary_path=" + this.GameBinaryPath + "&" + "epic_game_log_path=" + this.GameLogPath + "&" + "epic_game_saved_path=" + this.GameSavedPath + "&" + "epic_game_max_match_length=" + this.MaxMatchLength.ToString() + "&" + "epic_game_ttl_interval=" + this.TtlInterval.ToString() + "&" + "epic_install_sumo=" + this.InstallSumo + "&" + "epic_game_tag=" + GetTag(AppName, Region, tag) + "&" + "epic_game_version=" + Changelist.ToString() + "&" + "epic_game_buildstr_base64=" + System.Convert.ToBase64String(BuildStringBytes) + "&" + "epic_game_cpu_budget=" + LocalCpuBudget + "&" + "epic_game_ram_budget=" + RamBudget + "&" + "epic_game_environment=" + AppName.ToString() + "&" + "epic_instance_size=" + InstanceSize.ToString() + "&" + "epic_instance_min=" + InstanceSizeMin.ToString() + "&" + "epic_instance_max=" + InstanceSizeMax.ToString() + "&" + "epic_autoscaler_id=" + AutoscalerId + "&" + "epic_aws_access_key=" + AwsAccessKey + "&" + "epic_aws_base64_secret_key=" + System.Convert.ToBase64String(AwsAccessSecretKeyBytes) + "&" + "epic_aws_instance_type=" + InstanceType + "&" + "epic_aws_region=" + AwsRegion + "&" + "epic_game_base64_cli_args=" + System.Convert.ToBase64String(CliArgBytes); return(CloudArgs); }
protected void InitBuildSource(string InProjectName, bool InUsesSharedBuildType, string InUnrealPath, string InBuildArgument, Func <string, string> ResolutionDelegate) { if (InBuildArgument.Equals("AutoP4", StringComparison.InvariantCultureIgnoreCase)) { if (!CommandUtils.P4Enabled) { throw new AutomationException("-Build=AutoP4 requires -P4"); } if (CommandUtils.P4Env.Changelist < 1000) { throw new AutomationException("-Build=AutoP4 requires a CL from P4 and we have {0}", CommandUtils.P4Env.Changelist); } string BuildRoot = CommandUtils.CombinePaths(CommandUtils.RootBuildStorageDirectory()); string CachePath = InternalUtils.GetEnvironmentVariable("UE-BuildCachePath", ""); string SrcBuildPath = CommandUtils.CombinePaths(BuildRoot, InProjectName); string SrcBuildPath2 = CommandUtils.CombinePaths(BuildRoot, InProjectName.Replace("Game", "").Replace("game", "")); string SrcBuildPath_Cache = CommandUtils.CombinePaths(CachePath, InProjectName); string SrcBuildPath2_Cache = CommandUtils.CombinePaths(CachePath, InProjectName.Replace("Game", "").Replace("game", "")); if (!InternalUtils.SafeDirectoryExists(SrcBuildPath)) { if (!InternalUtils.SafeDirectoryExists(SrcBuildPath2)) { throw new AutomationException("-Build=AutoP4: Neither {0} nor {1} exists.", SrcBuildPath, SrcBuildPath2); } SrcBuildPath = SrcBuildPath2; SrcBuildPath_Cache = SrcBuildPath2_Cache; } string SrcCLPath = CommandUtils.CombinePaths(SrcBuildPath, CommandUtils.EscapePath(CommandUtils.P4Env.Branch) + "-CL-" + CommandUtils.P4Env.Changelist.ToString()); string SrcCLPath_Cache = CommandUtils.CombinePaths(SrcBuildPath_Cache, CommandUtils.EscapePath(CommandUtils.P4Env.Branch) + "-CL-" + CommandUtils.P4Env.Changelist.ToString()); if (!InternalUtils.SafeDirectoryExists(SrcCLPath)) { throw new AutomationException("-Build=AutoP4: {0} does not exist.", SrcCLPath); } if (InternalUtils.SafeDirectoryExists(SrcCLPath_Cache)) { InBuildArgument = SrcCLPath_Cache; } else { InBuildArgument = SrcCLPath; } Log.Verbose("Using AutoP4 path {0}", InBuildArgument); } UnrealPath = InUnrealPath; UsesSharedBuildType = InUsesSharedBuildType; ResolveProjectName(InProjectName); // Resolve the build argument into something meaningful string ResolvedBuildPath, ResolvedBuildName; if (!ResolveBuildReference(InBuildArgument, ResolutionDelegate, out ResolvedBuildPath, out ResolvedBuildName)) { throw new AutomationException("Unable to resolve {0} to a valid build", InBuildArgument); } BuildName = ResolvedBuildName; BuildPath = ResolvedBuildPath; DiscoveredBuilds = DiscoverBuilds(); if (DiscoveredBuilds.Count() == 0) { throw new AutomationException("No builds were discovered from resolved build argument {0}", InBuildArgument); } // any Branch/CL info? Match M = Regex.Match(BuildName, @"(\+\+.+)-CL-(\d+)"); if (M.Success) { Branch = M.Groups[1].Value.Replace("+", "/"); Changelist = Convert.ToInt32(M.Groups[2].Value); } else { Branch = ""; Changelist = 0; } // allow user overrides (TODO - centralize all this!) Branch = Globals.Params.ParseValue("branch", Branch); Changelist = Convert.ToInt32(Globals.Params.ParseValue("changelist", Changelist.ToString())); }