コード例 #1
0
ファイル: TestFixtureThread.cs プロジェクト: Badgerati/Edison
 public TestFixtureThread(int threadId, EdisonContext context, TestResultDictionary resultQueue, IEnumerable<Type> fixtures,
     Exception globalSetupEx, ConcurrencyType concurrenyType, int numberOfTestThreads)
 {
     ThreadId = threadId;
     Context = context;
     ResultQueue = resultQueue;
     GlobalSetupException = globalSetupEx;
     TestFixtures = fixtures;
     NumberOfTestThreads = numberOfTestThreads;
 }
コード例 #2
0
        public QueueManager(string topicConnectionString, string jobName, ConcurrencyType concurrencyType)
        {
            this.topicConnectionString = topicConnectionString;
            this.jobName = jobName;

            this.topicSubscriptionName        = jobName;
            this.topicSessionSubscriptionName = $"{jobName}session";
            this.concurrencyType = concurrencyType;
            CreateSubscriptions().Wait();
        }
コード例 #3
0
 public AnalysisMember(Func <AnalysisMember> parent, ConcurrencyType runAs, Analysis analysis, IEnumerable <Feature> features, Func <Result, IEnumerable <Result <T> > > setFunction) : base(parent, runAs, analysis, features)
 {
     this.setFunction            = setFunction;
     this.values                 = new List <Result <T> >();
     this.producerLock           = new object();
     this.rwls                   = new ReaderWriterLockSlim();
     this.parentResultEnumerator = new Lazy <IEnumerator <Result> >(() => base.Parent.GetResults().GetEnumerator(), true);
     this.producerEnumerator     = Enumerable.Empty <Result <T> >().GetEnumerator();
     this.task                   = null;
     this.taskLock               = new object();
 }
コード例 #4
0
ファイル: TestThread.cs プロジェクト: Badgerati/Edison
 public TestThread(int threadId, TestResultDictionary resultQueue, IEnumerable<MethodInfo> tests, Type testFixture,
     int testFixtureRepeatIndex, TestCaseAttribute testFixtureCase, object activator, Exception globalSetupEx,
     Exception fixtureSetupEx, Exception activatorEx, EdisonContext context, ConcurrencyType concurrenyType)
 {
     ThreadId = threadId;
     Context = context;
     ResultQueue = resultQueue;
     TestFixture = testFixture;
     TestFixtureRepeatIndex = testFixtureRepeatIndex;
     Activator = activator;
     TestFixtureCase = testFixtureCase;
     GlobalSetupException = globalSetupEx;
     FixtureSetupException = fixtureSetupEx;
     ActivatorException = activatorEx;
     Tests = tests;
 }
コード例 #5
0
 public AnalysisMember(Func <AnalysisMember> parent, ConcurrencyType runAs, Analysis analysis, IEnumerable <Feature> features)
 {
     this.parent = new Lazy <AnalysisMember>(delegate()
     {
         if (parent != null)
         {
             return(parent());
         }
         return(analysis.RootAnalysisMember);
     }, true);
     this.RunAs    = runAs;
     this.Analysis = analysis;
     this.features = new List <Feature>(features);
     this.featuresHaveBeenInherited = false;
     this.startTimeTicks            = default(DateTime).Ticks;
     this.stopTimeTicks             = default(DateTime).Ticks;
 }
コード例 #6
0
        private static async Task <bool> HandleConCurrencyForUpdate(CloudBlockBlob blockBlob, ConcurrencyType type)
        {
            bool result = false;

            switch (type)
            {
            case ConcurrencyType.Default:
                blockBlob.Metadata["Author"]   = "Default Update";
                blockBlob.Metadata["Priority"] = "High";
                await blockBlob.SetMetadataAsync();

                break;

            case ConcurrencyType.Optimistic:
                blockBlob.Metadata["Author"]   = "Optimistic Update";
                blockBlob.Metadata["Priority"] = "High";
                var accessCondition = new AccessCondition
                {
                    IfMatchETag = blockBlob.Properties.ETag
                };
                try
                {
                    await blockBlob.SetMetadataAsync(accessCondition, null, null);
                }
                catch (Exception exe)
                {
                    result = false;
                }

                break;

            case ConcurrencyType.Pessimistic:
                blockBlob.Metadata["Author"]   = "Optimistic Update";
                blockBlob.Metadata["Priority"] = "High";
                string leaseId = await blockBlob.AcquireLeaseAsync(TimeSpan.FromMinutes(1));

                var accessConditionPessimistic = new AccessCondition
                {
                    LeaseId = leaseId
                };
                try
                {
                    await blockBlob.SetMetadataAsync(accessConditionPessimistic, null, null);
                }
                catch (Exception exe)
                {
                    result = false;
                }

                //await blockBlob.BreakLeaseAsync(TimeSpan.FromSeconds(0));

                await blockBlob.ReleaseLeaseAsync(accessConditionPessimistic);

                break;
            }

            return(result);
        }
コード例 #7
0
ファイル: Concurrency.cs プロジェクト: Badgerati/Edison
 public ConcurrencyAttribute(ConcurrencyType concurrentType)
 {
     ConcurrencyType = concurrentType;
 }
コード例 #8
0
        public ModelClass(XmlTextReader r, string version)
        {
            extended = new Dictionary <Type, ModelClassExtension>();

            // BE SURE TO CREATE SYSTEM FOLDER!

            if (r.Name != "ClassObject")
            {
                throw new Exception(string.Format("Source file does not match NitroCast DTD; " +
                                                  "expected 'ClassModel', found '{0}'.", r.Name));
            }

            r.MoveToAttribute("Name");
            name = r.Value;
            r.MoveToAttribute("NameSpace");
            _namespace = r.Value;
            r.MoveToContent();
            r.Read();

            outputpath = r.ReadElementString("OutputPath");
            if (r.Name == "WebOutputPath")
            {
                webOutputPath = r.ReadElementString("WebOutputPath");
            }
            defaultTableName = r.ReadElementString("DefaultTableName");
            isTableCoded     = bool.Parse(r.ReadElementString("DefaultTableNameHardCoded"));
            caption          = r.ReadElementString("Caption");
            description      = r.ReadElementString("Description");
            summary          = r.ReadElementString("Summary");

            if (r.Name == "IsCachingEnabled")
            {
                isCachingEnabled = bool.Parse(r.ReadElementString("IsCachingEnabled"));
            }
            if (r.Name == "CacheClass")
            {
                cacheClass = r.ReadElementString("CacheClass");
            }
            if (r.Name == "CacheName")
            {
                cacheName = r.ReadElementString("CacheName");
            }
            if (r.Name == "AspNetCachingEnabled")
            {
                isCachingEnabled = bool.Parse(r.ReadElementString("AspNetCachingEnabled"));
            }
            if (r.Name == "CacheLifetime")
            {
                cacheLifetime = TimeSpan.Parse(r.ReadElementString("CacheLifetime"));
            }
            if (r.Name == "IsCollectionCachingEnabled")
            {
                isCollectionCachingEnabled = bool.Parse(r.ReadElementString("IsCollectionCachingEnabled"));
            }
            if (r.Name == "CollectionCacheLifetime")
            {
                collectionCacheLifetime = TimeSpan.Parse(r.ReadElementString("CollectionCacheLifetime"));
            }
            if (r.Name == "LockType")
            {
                concurrency = (ConcurrencyType)Enum.Parse(typeof(ConcurrencyType), r.ReadElementString("LockType"), true);
            }
            if (r.Name == "Concurrency")
            {
                concurrency = (ConcurrencyType)Enum.Parse(typeof(ConcurrencyType), r.ReadElementString("Concurrency"), true);
            }
            if (r.Name == "IsThreadSafe")
            {
                isThreadSafe = bool.Parse(r.ReadElementString("IsThreadSafe"));
            }
            if (r.Name == "IsCreateDateEnabled")
            {
                r.ReadElementString("IsCreateDateEnabled");
            }
            if (r.Name == "IsModifyDateEnabled")
            {
                r.ReadElementString("IsModifyDateEnabled");
            }
            if (r.Name == "Interfaces")
            {
                interfaces = r.ReadElementString("Interfaces");
            }
            if (r.Name == "ToStringOverride")
            {
                toStringOverride = r.ReadElementString("ToStringOverride");
            }
            if (r.Name == "SimpleQueryEnabled")
            {
                simpleQueryEnabled = bool.Parse(r.ReadElementString("SimpleQueryEnabled"));
            }

            #region Obsolete Code

            // Place old version of fields data in data folder
            if (r.Name == "Fields")
            {
                // Make sure there is a default folder!
                if (folders.Count == 0)
                {
                    ClassFolder defaultFolder = new ClassFolder("Default");
                    defaultFolder.ParentClass = this;
                    folders.Add(defaultFolder);
                }

                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "FieldEntry")
                    {
                        ValueField field = new ValueField(r, version);
                        field.ParentFolder = folders[0];
                        folders[0].Items.Add(field);
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            // Place old version of children data in data folder
            if (r.Name == "Children")
            {
                // Make sure there is a default folder!
                if (folders.Count == 0)
                {
                    ClassFolder defaultFolder = new ClassFolder("Default");
                    folders.Add(defaultFolder);
                }

                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "ChildEntry")
                    {
                        ReferenceField field = new ReferenceField(r, version);
                        field.ParentFolder = folders[0];
                        folders[0].Items.Add(field);
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            #endregion

            if (r.Name == "ClassFolders")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "ClassFolder")
                    {
                        ClassFolder folder = new ClassFolder(r, version);
                        folder.ParentClass = this;
                        folders.Add(folder);
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            if (r.Name == "OutputPlugins")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "ClassOutputConnector")
                    {
                        outputConnectors.Add(new OutputExtensionConnector(r, this));
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            if (r.Name == "MetaAttributes")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();
                    while (r.LocalName == "MetaAttribute")
                    {
                        attributes.Add(new MetaAttribute(r));
                    }
                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }


            if (r.Name == "Extensions")
            {
                if (!r.IsEmptyElement)
                {
                    r.Read();

                    while (r.Name == "Extension")
                    {
                        ModelClassExtension newExtension = (ModelClassExtension)
                                                           ObjectExtension.Build(r, version);
                        extended.Add(newExtension.GetType(), newExtension);
                    }

                    r.ReadEndElement();
                }
                else
                {
                    r.Read();
                }
            }

            r.ReadEndElement();

            EnsureSystemFolderExists();
        }
コード例 #9
0
        /// <summary>
        /// Execute method that is used inherently from the Execute()
        /// </summary>
        /// <returns></returns>
        private int ExecuteFromOverrideFile(string buildZipFileName, string platinumDacPacFileName, MultiDbData multiData, string rootLoggingPath, string description, string buildRequestedBy, bool forceCustomDacpac, int concurrency = 20, ConcurrencyType concurrencyType = ConcurrencyType.Count)
        {
            try
            {
                var tasks       = new List <Task <int> >();
                int targetTotal = 0;
                try
                {
                    startTime = DateTime.Now;
                    log.LogInformation($"Starting Threaded processing at {startTime.ToString()}");

                    var concurrencyBuckets = Concurrency.ConcurrencyByType(multiData, concurrency, concurrencyType);
                    targetTotal = concurrencyBuckets.Sum(c => c.Count());
                    foreach (var bucket in concurrencyBuckets)
                    {
                        tasks.Add(ProcessConcurrencyBucket(bucket, forceCustomDacpac));
                    }
                }
                catch (Exception exe)
                {
                    WriteToLog(new LogMsg()
                    {
                        Message = exe.ToString(), LogType = LogType.Error
                    });
                }

                //Wait for all of the tasks to finish
                Task.WaitAll(tasks.ToArray());


                TimeSpan interval = DateTime.Now - startTime;
                var      finalMsg = new LogMsg()
                {
                    RunId = ThreadedExecution.RunID, Message = $"Ending threaded processing at {DateTime.Now.ToUniversalTime()}", LogType = LogType.Message
                };
                WriteToLog(finalMsg);
                finalMsg.Message = $"Execution Duration: {interval.ToString()}";
                WriteToLog(finalMsg);
                finalMsg.Message = $"Total number of targets: {targetTotal.ToString()}";
                WriteToLog(finalMsg);

                WriteToLog(new LogMsg()
                {
                    LogType = LogType.SuccessDatabases
                });
                if (this.hasError)
                {
                    WriteToLog(new LogMsg()
                    {
                        LogType = LogType.FailureDatabases
                    });
                    finalMsg.Message = "Finishing with Errors";
                    finalMsg.LogType = LogType.Error;
                    WriteToLog(finalMsg);
                    finalMsg.LogType = LogType.Message;
                    WriteToLog(finalMsg);
                    return((int)ExecutionReturn.FinishingWithErrors);
                }
                else
                {
                    log.LogInformation("Successful");
                    return((int)ExecutionReturn.Successful);
                }
            }
            catch (Exception bigExe)
            {
                log.LogCritical($"Big problem running the threaded build...{bigExe.ToString()}");
                return((int)ExecutionReturn.NullBuildData);
            }
        }
コード例 #10
0
        public async Task <int> SendTargetsToQueue(MultiDbData multiDb, ConcurrencyType cType)
        {
            try
            {
                log.LogInformation($"Setting up Topic Subscription with Job filter name '{this.jobName}'");
                await RemoveDefaultFilters();
                await CleanUpCustomFilters();
                await CreateBatchJobFilter(cType == ConcurrencyType.Count?false : true);

                var sender = this.Client.CreateSender(topicName);

                //Use bucketing to 1 bucket to get flattened list of targest
                var concurrencyBuckets = Concurrency.ConcurrencyByType(multiDb, 1, ConcurrencyType.Count);
                var messages           = CreateMessages(concurrencyBuckets, jobName);
                int count     = messages.Count();
                int sentCount = 0;

                //because of partitiioning, can't batch across session Id, so group by SessionId first, then batch
                var bySessionId = messages.GroupBy(s => s.SessionId);
                foreach (var sessionSet in bySessionId)
                {
                    var msgBatch = sessionSet.Batch(20); //send in batches of 20
                    foreach (var b in msgBatch)
                    {
                        var sbb = await sender.CreateMessageBatchAsync();

                        foreach (var msg in b)
                        {
                            if (!sbb.TryAddMessage(msg))
                            {
                                log.LogError($"Failed to add message to Service Bus batch.{Environment.NewLine}{msg.Body}");
                            }
                            else
                            {
                                sentCount++;
                            }
                        }
                        await sender.SendMessagesAsync(sbb);
                    }
                }
                if (sentCount != count)
                {
                    log.LogError($"Only {sentCount} out of {count} database targets were sent to the Service Bus. Before running your workload, please run a 'dequeue' command and try again");
                    return(-1);
                }

                //Confirm message count in Queue
                int retry          = 0;
                var activeMessages = await MonitorServiceBustopic(cType);

                while (activeMessages != count && retry < 4)
                {
                    Thread.Sleep(1000);
                    activeMessages = await MonitorServiceBustopic(cType);
                }

                if (activeMessages != count)
                {
                    log.LogError($"After attempting to queue messages, there are only {activeMessages} out of {count} messages in the Service Bus Subscription. Before running your workload, please run a 'dequeue' command and try again");
                    return(-1);
                }
                else
                {
                    log.LogInformation($"Validated {activeMessages} of {count} active messages in Service Bus Subscription {this.topicName}:{this.topicSessionSubscriptionName}");
                }

                return(count);
            }
            catch (Exception exe)
            {
                log.LogError(exe, "Failed to send database override targets to Service Bus Queue");
                return(-1);
            }
        }
コード例 #11
0
        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");
        }
コード例 #12
0
        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");
        }
コード例 #13
0
        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));
        }
コード例 #14
0
        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));
        }
コード例 #15
0
        public void Batch_Override_SBMSource_ByConcurrencyType_Success(string batchMethod, string settingsFile, ConcurrencyType concurType, int concurrency)
        {
            string sbmFileName = Path.GetFullPath("SimpleSelect.sbm");

            if (!File.Exists(sbmFileName))
            {
                File.WriteAllBytes(sbmFileName, Properties.Resources.SimpleSelect);
            }

            settingsFile = Path.GetFullPath(settingsFile);

            //get the size of the log file before we start
            int startingLine = LogFileCurrentLineCount();

            var args = new string[] {
                "batch", batchMethod,
                "--settingsfile", settingsFile,
                "--settingsfilekey", this.settingsFileKeyPath,
                "--override", this.overrideFilePath,
                "--packagename", sbmFileName,
                "--concurrency", "2",
                "--concurrencytype", "Server"
            };

            RootCommand rootCommand = CommandLineBuilder.SetUp();
            var         val         = rootCommand.InvokeAsync(args);

            val.Wait();
            var result = val.Result;


            var logFileContents = ReleventLogFileContents(startingLine);

            Assert.AreEqual(0, result, StandardExecutionErrorMessage(logFileContents));
            Assert.IsTrue(logFileContents.Contains("Completed Successfully"), "This test was should have worked");
            if (batchMethod == "run")
            {
                Assert.IsTrue(logFileContents.Contains($"Batch complete"), $"Should indicate that this was run as a batch job");
            }
            if (batchMethod == "runthreaded")
            {
                Assert.IsTrue(logFileContents.Contains($"Total number of targets: {this.overrideFileContents.Count()}"), $"Should have run against a {this.overrideFileContents.Count()} databases");
            }
        }
コード例 #16
0
ファイル: Rule.cs プロジェクト: YHZX2013/exchange_diff
 private Rule(Func <AnalysisMember> parent, ConcurrencyType runAs, Analysis analysis, IEnumerable <Feature> features, Func <Result, IEnumerable <Result <bool> > > setFunction) : base(parent, runAs, analysis, features, setFunction)
 {
 }
コード例 #17
0
        public static List <IEnumerable <(string, List <DatabaseOverride>)> > ConcurrencyByType(MultiDbData multiData, int concurrency, ConcurrencyType concurrencyType)
        {
            switch (concurrencyType)
            {
            case ConcurrencyType.Server:
                return(ConcurrencyByServer(multiData));

            case ConcurrencyType.MaxPerServer:
                return(MaxConcurrencyByServer(multiData, concurrency));

            case ConcurrencyType.Count:
            default:
                return(ConcurrencyByInt(multiData, concurrency));
            }
        }
コード例 #18
0
        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);
        }