public void Batch_Queue_SBMSource_ByConcurrencyType_Success(string batchMethod, string settingsFile, ConcurrencyType concurType, int concurrency) { settingsFile = Path.GetFullPath(settingsFile); string sbmFileName = Path.GetFullPath("SimpleSelect.sbm"); if (!File.Exists(sbmFileName)) { File.WriteAllBytes(sbmFileName, Properties.Resources.SimpleSelect); } string jobName = GetUniqueBatchJobName("batch-sbm"); int startingLine = LogFileCurrentLineCount(); var args = new string[] { "batch", "enqueue", "--settingsfile", settingsFile, "--settingsfilekey", this.settingsFileKeyPath, "--override", this.overrideFilePath, "--concurrencytype", concurType.ToString(), "--jobname", jobName }; RootCommand rootCommand = CommandLineBuilder.SetUp(); Task <int> val = rootCommand.InvokeAsync(args); val.Wait(); var result = val.Result; var logFileContents = ReleventLogFileContents(startingLine); Assert.AreEqual(0, result, StandardExecutionErrorMessage(logFileContents)); args = new string[] { "batch", batchMethod, "--settingsfile", settingsFile, "--settingsfilekey", this.settingsFileKeyPath, "--override", this.overrideFilePath, "--packagename", sbmFileName, "--concurrencytype", concurType.ToString(), "--concurrency", concurrency.ToString(), "--jobname", jobName, "--unittest", "--monitor", "--stream" }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; logFileContents = ReleventLogFileContents(startingLine); Assert.AreEqual(0, result, StandardExecutionErrorMessage(logFileContents)); }
public void WriteXml(XmlTextWriter w) { w.WriteStartElement("ClassObject"); w.WriteAttributeString("Name", name); w.WriteAttributeString("NameSpace", _namespace); w.WriteElementString("OutputPath", outputpath); w.WriteElementString("WebOutputPath", webOutputPath); w.WriteElementString("DefaultTableName", defaultTableName); w.WriteElementString("DefaultTableNameHardCoded", isTableCoded.ToString()); w.WriteElementString("Caption", caption); w.WriteElementString("Description", description); w.WriteElementString("Summary", summary); w.WriteElementString("IsCachingEnabled", isCachingEnabled.ToString()); w.WriteElementString("CacheClass", cacheClass); w.WriteElementString("CacheName", cacheName); w.WriteElementString("CacheLifetime", cacheLifetime.ToString()); w.WriteElementString("IsCollectionCachingEnabled", isCollectionCachingEnabled.ToString()); w.WriteElementString("CollectionCacheLifetime", collectionCacheLifetime.ToString()); w.WriteElementString("Concurrency", concurrency.ToString()); w.WriteElementString("IsThreadSafe", isThreadSafe.ToString()); w.WriteElementString("Interfaces", interfaces); w.WriteElementString("ToStringOverride", toStringOverride); w.WriteElementString("SimpleQueryEnabled", simpleQueryEnabled.ToString()); w.WriteStartElement("ClassFolders"); foreach (ClassFolder folder in folders) { folder.WriteXml(w); } w.WriteEndElement(); // Folders w.WriteStartElement("OutputPlugins"); foreach (OutputExtensionConnector connector in outputConnectors) { connector.WriteXml(w); } w.WriteEndElement(); w.WriteStartElement("MetaAttributes"); if (attributes != null) { foreach (MetaAttribute attribute in attributes) { attribute.WriteXml(w); } } w.WriteEndElement(); w.WriteStartElement("Extensions"); foreach (ModelClassExtension extension in extended.Values) { extension.writeXml(w); } w.WriteEndElement(); w.WriteEndElement(); // ClassObject }
public void ACI_Queue_SBMSource_KeyVault_Secrets_Success(string settingsFile, string imageTag, int containerCount, int concurrency, ConcurrencyType concurrencyType) { settingsFile = Path.GetFullPath(settingsFile); var overrideFile = Path.GetFullPath("TestConfig/databasetargets.cfg"); var sbmFileName = Path.GetFullPath("SimpleSelect.sbm"); if (!File.Exists(sbmFileName)) { File.WriteAllBytes(sbmFileName, Properties.Resources.SimpleSelect); } //get the size of the log file before we start int startingLine = TestHelper.LogFileCurrentLineCount(); RootCommand rootCommand = CommandLineBuilder.SetUp(); string jobName = TestHelper.GetUniqueJobName("aci"); string outputFile = Path.Combine(Directory.GetCurrentDirectory(), jobName + ".json"); //Prep the build var args = new string[] { "aci", "prep", "--settingsfile", settingsFile, "--tag", imageTag, "--jobname", jobName, "--packagename", sbmFileName, "--outputfile", outputFile, "--containercount", containerCount.ToString(), "--concurrencytype", concurrencyType.ToString(), "--concurrency", concurrency.ToString() }; var val = rootCommand.InvokeAsync(args); val.Wait(); int result = val.Result; Assert.AreEqual(0, result); //enqueue the topic messages args = new string[] { "aci", "enqueue", "--settingsfile", settingsFile, "--jobname", jobName, "--concurrencytype", concurrencyType.ToString(), "--override", overrideFile }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); //monitor for completion args = new string[] { "aci", "deploy", "--settingsfile", settingsFile, "--templatefile", outputFile, "--override", overrideFile, "--unittest", "true", "--monitor", "true" }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); }
public void ACI_Queue_DacpacSource_ForceApplyCustom_eyVault_Secrets_Success(string settingsFile, string imageTag, int containerCount, int concurrency, ConcurrencyType concurrencyType) { settingsFile = Path.GetFullPath(settingsFile); var overrideFile = Path.GetFullPath("TestConfig/databasetargets.cfg"); int removeCount = 1; string server, database; var overrideFileContents = File.ReadAllLines(overrideFile).ToList(); string firstOverride = overrideFileContents.First(); (server, database) = DatabaseHelper.ExtractServerAndDbFromLine(firstOverride); string server2, database2; string thirdOverride = overrideFileContents.ElementAt(2); (server2, database2) = DatabaseHelper.ExtractServerAndDbFromLine(thirdOverride); string minusFirst = Path.GetFullPath("TestConfig/minusFirst.cfg"); File.WriteAllLines(minusFirst, DatabaseHelper.ModifyTargetList(overrideFileContents, removeCount)); //Get the creds locally from the K8s file var secretsFile = Path.GetFullPath("TestConfig/secrets.yaml"); var ymlD = new ydn.Deserializer(); var obj = ymlD.Deserialize <dynamic>(File.ReadAllText(secretsFile)); var pw = Encoding.UTF8.GetString(Convert.FromBase64String(obj["data"]["Password"])); var un = Encoding.UTF8.GetString(Convert.FromBase64String(obj["data"]["UserName"])); var cmdLine = new CommandLineArgs() { UserName = un, Password = pw }; DatabaseHelper.CreateRandomTable(cmdLine, new List <string>() { firstOverride, thirdOverride }); string dacpacName = DatabaseHelper.CreateDacpac(cmdLine, server, database); //get the size of the log file before we start int startingLine = TestHelper.LogFileCurrentLineCount(); RootCommand rootCommand = CommandLineBuilder.SetUp(); string jobName = TestHelper.GetUniqueJobName("aci"); string outputFile = Path.Combine(Directory.GetCurrentDirectory(), jobName + ".json"); //Prep the build var args = new string[] { "aci", "prep", "--settingsfile", settingsFile, "--tag", imageTag, "--jobname", jobName, "--platinumdacpac", dacpacName, "--outputfile", outputFile, "--containercount", containerCount.ToString(), "--concurrencytype", concurrencyType.ToString(), "--concurrency", concurrency.ToString(), "--override", minusFirst }; var val = rootCommand.InvokeAsync(args); val.Wait(); int result = val.Result; Assert.AreEqual(0, result); //Create another table in the first that will be applied when the custom DACPAC is created DatabaseHelper.CreateRandomTable(cmdLine, firstOverride); //enqueue the topic messages args = new string[] { "aci", "enqueue", "--settingsfile", settingsFile, "--jobname", jobName, "--concurrencytype", concurrencyType.ToString(), "--override", minusFirst }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); //monitor for completion args = new string[] { "aci", "deploy", "--settingsfile", settingsFile, "--templatefile", outputFile, "--override", minusFirst, "--unittest", "true", "--monitor", "true", "--stream", "true" }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); var logFileContents = TestHelper.ReleventLogFileContents(startingLine); Assert.IsTrue(logFileContents.Contains("Committed - With Custom Dacpac"), "A custom DACPAC should have been required for a database"); }
public void Batch_Queue_SBMSource_MissingEventHubConnection_Success(string batchMethod, string settingsFile, ConcurrencyType concurType, int concurrency) { settingsFile = Path.GetFullPath(settingsFile); string sbmFileName = Path.GetFullPath("SimpleSelect.sbm"); if (!File.Exists(sbmFileName)) { File.WriteAllBytes(sbmFileName, Properties.Resources.SimpleSelect); } string settingFileNoEventHub = Path.Combine(Path.GetDirectoryName(settingsFile), "settingsfile-no-eventhub.json"); CommandLineArgs cmdLine = new CommandLineArgs() { FileInfoSettingsFile = new FileInfo(settingFileNoEventHub) }; cmdLine.ConnectionArgs.EventHubConnectionString = null; var updatedJson = JsonConvert.SerializeObject(cmdLine, Formatting.Indented, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }); File.WriteAllText(settingFileNoEventHub, updatedJson); RootCommand rootCommand = CommandLineBuilder.SetUp(); string jobName = GetUniqueBatchJobName("batch-sbm"); int startingLine = LogFileCurrentLineCount(); var args = new string[] { "batch", "enqueue", "--settingsfile", settingFileNoEventHub, "--settingsfilekey", this.settingsFileKeyPath, "--override", this.overrideFilePath, "--concurrencytype", concurType.ToString(), "--jobname", jobName }; var val = rootCommand.InvokeAsync(args); val.Wait(); var result = val.Result; var logFileContents = ReleventLogFileContents(startingLine); Assert.AreEqual(0, result, StandardExecutionErrorMessage(logFileContents)); args = new string[] { "batch", batchMethod, "--settingsfile", settingFileNoEventHub, "--settingsfilekey", this.settingsFileKeyPath, "--override", this.overrideFilePath, "--packagename", sbmFileName, "--concurrencytype", concurType.ToString(), "--concurrency", concurrency.ToString(), "--jobname", jobName, "--unittest", "--monitor", "--stream" }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; logFileContents = ReleventLogFileContents(startingLine); Assert.AreEqual(0, result, StandardExecutionErrorMessage(logFileContents)); }
public void ContainerApp_Queue_DacpacSource_ForceApplyCustom_Success(string settingsFile, string imageTag, int containerCount, int concurrency, ConcurrencyType concurrencyType) { settingsFile = Path.GetFullPath(settingsFile); var overrideFile = Path.GetFullPath("TestConfig/databasetargets.cfg"); int removeCount = 1; string server, database; var overrideFileContents = File.ReadAllLines(overrideFile).ToList(); string firstOverride = overrideFileContents.First(); (server, database) = DatabaseHelper.ExtractServerAndDbFromLine(firstOverride); string server2, database2; string thirdOverride = overrideFileContents.ElementAt(2); (server2, database2) = DatabaseHelper.ExtractServerAndDbFromLine(thirdOverride); string minusFirst = Path.GetFullPath("TestConfig/minusFirst.cfg"); File.WriteAllLines(minusFirst, DatabaseHelper.ModifyTargetList(overrideFileContents, removeCount)); var cmdLine = new CommandLineArgs(); cmdLine.SettingsFileKey = this.settingsFileKeyPath; cmdLine.FileInfoSettingsFile = new FileInfo(settingsFile); bool decryptSuccess; (decryptSuccess, cmdLine) = Cryptography.DecryptSensitiveFields(cmdLine); if (!decryptSuccess) { Assert.Fail("There was an error decrypting one or more value from the --settingsfile. Please check that you are using the correct --settingsfilekey value"); } bool tmp; (tmp, cmdLine) = KeyVaultHelper.GetSecrets(cmdLine); //First and 3rd will already be in sync, which will cause an SBM failure and force a new custom SBM to be created from the Platinum DACPAC DatabaseHelper.CreateRandomTable(cmdLine, new List <string>() { firstOverride, thirdOverride }); string dacpacName = DatabaseHelper.CreateDacpac(cmdLine, server, database); Assert.IsNotNull(dacpacName, $"There was a problem creating the dacpac for this test"); string sbmFileName = Path.Combine(Path.GetDirectoryName(dacpacName), Path.GetFileNameWithoutExtension(dacpacName) + ".sbm"); //get the size of the log file before we start int startingLine = TestHelper.LogFileCurrentLineCount(); RootCommand rootCommand = CommandLineBuilder.SetUp(); string jobName = TestHelper.GetUniqueJobName("ca"); string outputFile = Path.Combine(Directory.GetCurrentDirectory(), jobName + ".json"); //Prep the build var args = new string[] { "containerapp", "prep", "--settingsfile", settingsFile, "--settingsfilekey", this.settingsFileKeyPath, "--jobname", jobName, "--platinumdacpac", dacpacName, "--override", minusFirst }; var val = rootCommand.InvokeAsync(args); val.Wait(); int result = val.Result; Assert.AreEqual(0, result); //Create another table in the first that will be applied when the custom DACPAC is created DatabaseHelper.CreateRandomTable(cmdLine, firstOverride); DatabaseHelper.CreateRandomTable(cmdLine, thirdOverride); //enqueue the topic messages args = new string[] { "containerapp", "enqueue", "--settingsfile", settingsFile, "--settingsfilekey", this.settingsFileKeyPath, "--jobname", jobName, "--concurrencytype", concurrencyType.ToString(), "--override", minusFirst }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); //monitor for completion args = new string[] { //"--loglevel", "Debug", "containerapp", "deploy", "--settingsfile", settingsFile, "--settingsfilekey", this.settingsFileKeyPath, "-P", sbmFileName, "--platinumdacpac", dacpacName, "--override", minusFirst, "--jobname", jobName, "--concurrencytype", concurrencyType.ToString(), "--concurrency", concurrency.ToString(), "--unittest", "true", "--monitor", "true", "--stream", "true", "--deletewhendone", "true", "--allowobjectdelete", "true" }; val = rootCommand.InvokeAsync(args); val.Wait(); result = val.Result; Assert.AreEqual(0, result); var logFileContents = TestHelper.ReleventLogFileContents(startingLine); Assert.IsTrue(logFileContents.Contains("Committed - With Custom Dacpac"), "A custom DACPAC should have been required for a database"); }