public static (int, string) StartRpcMaster( string host, List <string> agents, string user, string password, int sshPort, string logPath, string serviceType, string transportType, string hubProtocol, string scenario, int connection, int concurrentConnection, int duration, int interval, List <string> pipeLine, int groupNum, int groupOverlap, int combineFactor, string messageSize, string serverUrl, string suffix, string masterRoot, string sendToFixedClient, bool enableGroupJoinLeave, bool stopSendIfLatencyBig, bool stopSendIfConnectionErrorBig, string connectionString) { Util.Log($"service type: {serviceType}, transport type: {transportType}, hub protocol: {hubProtocol}, scenario: {scenario}"); var errCode = 0; var result = ""; var cmd = ""; (errCode, result) = RemoteBash(user, host, sshPort, password, "cd ~; pwd;"); var userRoot = result.Substring(0, result.Length - 1); Util.Log($"user root: {userRoot}"); var agentList = ""; for (var i = 0; i < agents.Count; i++) { agentList += agents[i]; if (i < agents.Count - 1) { agentList += ";"; } } var clear = "false"; var outputCounterFile = ""; // todo var outputCounterDir = Path.Join(userRoot, $"results/{Environment.GetEnvironmentVariable("result_root")}/{suffix}/"); outputCounterFile = outputCounterDir + $"counters.txt"; var connectionStringOpt = ""; var serverOption = ""; if (connectionString != null) { if (!connectionString.StartsWith('\'') && !connectionString.StartsWith('"')) { connectionStringOpt = $"--connectionString '{connectionString}'"; } else { connectionStringOpt = $"--connectionString {connectionString}"; } } else { serverOption = $"--serverUrl '{serverUrl}'"; } var concatPipeline = string.Join(";", pipeLine); cmd = $"cd {masterRoot}; "; cmd += $"mkdir -p {outputCounterDir} || true;"; cmd += $"dotnet run -- " + $"--rpcPort 5555 " + $"--duration {duration} --connections {connection} --interval {interval} --agents {agents.Count} {serverOption} --pipeLine '{string.Join(";", pipeLine)}' " + $"-v {serviceType} -t {transportType} -p {hubProtocol} -s {scenario} " + $" --agentList '{agentList}' " + $" --retry {0} " + $" --clear {clear} " + $" --concurrentConnection {concurrentConnection} " + $" --groupNum {groupNum} " + $" --groupOverlap {groupOverlap} " + $" --combineFactor {combineFactor} " + $"--messageSize {messageSize} " + $"--sendToFixedClient {sendToFixedClient} " + $"--enableGroupJoinLeave {enableGroupJoinLeave} " + $"--stopSendIfLatencyBig {stopSendIfLatencyBig} " + $"--stopSendIfConnectionErrorBig {stopSendIfConnectionErrorBig} " + $"{connectionStringOpt} " + // this option is only for RestAPI scenario test $" -o '{outputCounterFile}' | tee {logPath}"; Util.Log($"CMD: {user}@{host}: {cmd}"); (errCode, result) = ShellHelper.RemoteBash(user, host, sshPort, password, cmd, captureConsole: true); if (errCode != 0) { Util.Log($"ERR {errCode}: {result}"); } return(errCode, result); }
public static (int, string) CreateSignalrService(ArgsOption argsOption, int unitCount) { var errCode = 0; var result = ""; var cmd = ""; var content = AzureBlobReader.ReadBlob("SignalrConfigFileName"); Console.WriteLine($"content: {content}"); var config = AzureBlobReader.ParseYaml <SignalrConfig>(content); // login to azure cmd = $"az login --service-principal --username {config.AppId} --password {config.Password} --tenant {config.Tenant}"; Util.Log($"CMD: signalr service: az login"); (errCode, result) = ShellHelper.Bash(cmd, handleRes: true); // change subscription cmd = $"az account set --subscription {config.Subscription}"; Util.Log($"CMD: az account set --subscription"); (errCode, result) = ShellHelper.Bash(cmd, handleRes: true); // var groupName = Util.GenResourceGroupName(config.BaseName); // var srName = Util.GenSignalRServiceName(config.BaseName); var rnd = new Random(); var SrRndNum = (rnd.Next(10000) * rnd.Next(10000)).ToString(); var groupName = config.BaseName + "Group"; var srName = config.BaseName + SrRndNum + "SR"; cmd = $" az extension add -n signalr || true"; Util.Log($"CMD: signalr service: {cmd}"); (errCode, result) = ShellHelper.Bash(cmd, handleRes: true); // create resource group cmd = $" az group create --name {groupName} --location {config.Location}"; Util.Log($"CMD: signalr service: {cmd}"); (errCode, result) = ShellHelper.Bash(cmd, handleRes: true); //create signalr service cmd = $"az signalr create --name {srName} --resource-group {groupName} --sku {config.Sku} --unit-count {unitCount} --query hostName -o tsv"; Util.Log($"CMD: signalr service: {cmd}"); (errCode, result) = ShellHelper.Bash(cmd, handleRes: true); var signalrHostName = result; Console.WriteLine($"signalrHostName: {signalrHostName}"); // get access key cmd = $"az signalr key list --name {srName} --resource-group {groupName} --query primaryKey -o tsv"; Util.Log($"CMD: signalr service: {cmd}"); (errCode, result) = ShellHelper.Bash(cmd, handleRes: true); var signalrPrimaryKey = result; Console.WriteLine($"signalrPrimaryKey: {signalrPrimaryKey}"); // combine to connection string signalrHostName = signalrHostName.Substring(0, signalrHostName.Length - 1); signalrPrimaryKey = signalrPrimaryKey.Substring(0, signalrPrimaryKey.Length - 1); var connectionString = $"Endpoint=https://{signalrHostName};AccessKey={signalrPrimaryKey};"; Console.WriteLine($"connection string: {connectionString}"); ShellHelper.Bash($"export AzureSignalRConnectionString='{connectionString}'", handleRes: true); return(errCode, connectionString); }
public static (int, string) StartRpcMaster(AgentConfig agentConfig, ArgsOption argsOption, string serviceType, string transportType, string hubProtocol, string scenario, int connection, int duration, int interval, string pipeLine, int mixEchoConnection, int mixBroadcastConnection, int mixGroupConnection, string mixGroupName, int groupNum, string serverUrl, string repoRoot = "/home/wanl/signalr_auto_test_framework") { Util.Log($"service type: {serviceType}, transport type: {transportType}, hub protocol: {hubProtocol}, scenario: {scenario}"); var errCode = 0; var result = ""; var cmd = ""; var maxRetry = 1; var slaveList = ""; for (var i = 0; i < agentConfig.Slaves.Count; i++) { slaveList += agentConfig.Slaves[i]; if (i < agentConfig.Slaves.Count - 1) { slaveList += ";"; } } for (var i = 0; i < 1; i++) { var clear = "false"; var outputCounterDir = ""; var outputCounterFile = ""; cmd = $"cd {repoRoot}/signalr_bench/Rpc/Bench.Client/; "; if (scenario == "echo" || scenario == "broadcast") { outputCounterDir = $"{repoRoot}/signalr_bench/Report/public/results/{Environment.GetEnvironmentVariable("result_root")}/{serviceType}_{transportType}_{hubProtocol}_{scenario}_{connection}_{groupNum}/"; } else if (scenario == "group") { outputCounterDir = $"{repoRoot}/signalr_bench/Report/public/results/{Environment.GetEnvironmentVariable("result_root")}/{serviceType}_{transportType}_{hubProtocol}_{scenario}_{connection}_{groupNum}/"; } outputCounterFile = outputCounterDir + $"counters.txt"; cmd += $"rm -rf {outputCounterFile} || true;"; cmd += $" mkdir log/{Environment.GetEnvironmentVariable("result_root")}/; "; cmd += $"dotnet build; dotnet run -- " + $"--rpcPort 5555 " + $"--duration {duration} --connections {connection} --interval {interval} --slaves {agentConfig.Slaves.Count} --serverUrl 'http://{serverUrl}:5050/signalrbench' --pipeLine '{string.Join(";", pipeLine)}' " + $"-v {serviceType} -t {transportType} -p {hubProtocol} -s {scenario} " + $" --slaveList '{slaveList}' " + $" --retry {0} " + $" --clear {clear} " + $" --mixEchoConnection {mixEchoConnection} " + $" --mixBroadcastConnection {mixBroadcastConnection} " + $" --mixGroupConnection {mixGroupConnection} " + $" --mixGroupName {mixGroupName} " + $" --concurrentConnection 1 " + $" --groupConnection {connection} " + $" --groupNum {groupNum} " + $" -o '{outputCounterFile}' > log/{Environment.GetEnvironmentVariable("result_root")}/log_rpcmaster_{serviceType}_{transportType}_{hubProtocol}_{scenario}_{connection}.txt"; Util.Log($"CMD: {agentConfig.User}@{agentConfig.Master}: {cmd}"); (errCode, result) = ShellHelper.RemoteBash(agentConfig.User, agentConfig.Master, agentConfig.SshPort, agentConfig.Password, cmd); if (errCode == 0) { break; } Util.Log($"retry {i}th time"); if (errCode != 0) { Util.Log($"ERR {errCode}: {result}"); } } return(errCode, result); }