Ejemplo n.º 1
0
        public IList<string> GetHotmailQueuesByVmta(Mta pmta, IEnumerable<string> domains)
        {
            if (!_testMode)
            {
                var domainStr = string.Join("|", domains.Select(d => Regex.Escape(d.Trim())));
                var results =
                    RunCommand(
                               string.Format("/usr/sbin/pmta show queues | egrep -i 'hotmail|outlook|live|msn' | egrep -i '{0}' | cut -d\" \" -f1",
                                             domainStr), pmta);

                if (string.IsNullOrWhiteSpace(results))
                {
                    return new List<string>();
                }

                return results.Split('\n')
                              .ToList()
                              .Where(x => !string.IsNullOrWhiteSpace(x))
                              .ToList();
            }
            else
            {
                return new[] {"TestQueue1", "TestQueue2"};
            }
        }
Ejemplo n.º 2
0
        public bool IsQueueActive(Mta pmta, string queue)
        {
            //TODO:Needs testing
            var results = RunCommand(string.Format("/usr/sbin/pmta show queues --paused=no | egrep -i 'hotmail|outlook|live|msn' | egrep -i '{0}' | cut -d\" \" -f1", Regex.Escape(queue)), pmta);

            return !string.IsNullOrWhiteSpace(results);
        }
Ejemplo n.º 3
0
        public IList<string> GetVmtasIn421BackoffMode(Mta pmta)
        {
            lock (locker)
            {
                var testcases = from t in Test421s
                                join p in Pmtas on t.PmtaId equals p.PMTAId
                                join d in deliveryserverips on t.DeliveryServerIpId equals d.deliveryserverip_id
                                where p.Host == pmta.Host && t.BackOff && p.deliveryserver_id == d.deliveryserver_id
                                select new { t.QueueCount,t.PmtaId,t.DeliveryServerIpId, d.reverse,d.deliveryGroup };

                var queueList = new List<string>();

                foreach (var testcase in testcases)
                {
                    for (int i = 1; i < testcase.QueueCount + 1; i++)
                    {
                        if (string.IsNullOrWhiteSpace(testcase.reverse))
                        {
                            Logger.WarnFormat("PmtaID {0} DeliveryServerIpId {1} has empty VmtaUrl",testcase.PmtaId,testcase.DeliveryServerIpId);
                        }
                        else if (testcase.deliveryGroup == null)
                        {
                            Logger.WarnFormat("PmtaID {0} DeliveryServerIpId {1} is orphaned from DeliveryGroup", testcase.PmtaId, testcase.DeliveryServerIpId);
                        }
                        else
                        {
                            queueList.Add(string.Format("test{0}/{1}", i, testcase.reverse));
                        }
                    }
                }
                Thread.Sleep(new Random().Next(Heavy.Low, Heavy.High));
                return queueList; 
            }
        }
Ejemplo n.º 4
0
        public IList<string> GetQueuesForHost(Mta pmta, string host, string domains)
        {
            lock (locker)
            {
                var testcases = from t in Test421s
                                join p in Pmtas on t.PmtaId equals p.PMTAId
                                join d in deliveryserverips on t.DeliveryServerIpId equals d.deliveryserverip_id
                                where p.Host == pmta.Host && p.deliveryserver_id == d.deliveryserver_id
                                select new { t.QueueCount, d.reverse };
                var queueList = new List<string>();

                foreach (var testcase in testcases)
                {
                    for (int i = 1; i < testcase.QueueCount + 1; i++)
                    {
                        if (!string.IsNullOrWhiteSpace(testcase.reverse))
                        {
                            queueList.Add(string.Format("test{0}/{1}", i, testcase.reverse));
                        }
                    }
                }
                Thread.Sleep(new Random().Next(Heavy.Low, Heavy.High));
                return queueList; 
            }
        }
Ejemplo n.º 5
0
        //Host comes from the DG...
        public IList<string> GetQueuesForHost(Mta pmta, string host, string domains)
        {
            var results = RunCommand(String.Format("/usr/sbin/pmta show queues | grep -i {0} | egrep -i '{1}' | cut -d\" \" -f1", host, domains), pmta);

            if (string.IsNullOrWhiteSpace(results))
            {
                return new List<string>();
            }

            return results.Split('\n').ToList().Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
        }
Ejemplo n.º 6
0
        public IList<string> GetVmtasIn421BackoffMode(Mta pmta)
        {
            var results = RunCommand("/usr/sbin/pmta show queues --mode=backoff | egrep \"(hotmail\\.|outlook\\.|live\\.|msn\\.).+/\" | grep 421 | cut -d\" \" -f1", pmta);

            if (string.IsNullOrWhiteSpace(results))
            {
                return new List<string>();
            }

            return results.Split('\n').ToList().Where(x => !string.IsNullOrWhiteSpace(x)).ToList();
        }
Ejemplo n.º 7
0
        private string RunCommand(string cmd, Mta pmta)
        {
            if (!_testMode)
            {
                try
                {
                    using (var client = new SshClient(pmta.Host, pmta.Username, pmta.Password))
                    {
                        client.Connect();
                        var command = client.RunCommand(cmd);
                        client.Disconnect();

                        if (command.ExitStatus != 0 && !string.IsNullOrWhiteSpace(command.Error))
                            throw new Exception(string.Format("PMTA Command error: {0}", command.Error));

                        return command.Result;
                    }
                }
                catch (Exception e)
                {
                    throw new Exception("PMTA Command error", e);
                }
            }
            else
            {
                return "";
            }
        }
Ejemplo n.º 8
0
        public void Purge(Mta pmta, string vmta)
        {
            _logger.TraceFormat("Purged Queue '{0}' on '{1}'", vmta, pmta.Host);
            var cmd = string.Format("/usr/sbin/pmta delete --queue={0}", vmta);

            RunCommand(cmd, pmta);
        }
Ejemplo n.º 9
0
 public void DeleteJob(Mta pmta, int jobId)
 {
     Logger.TraceFormat("Deleted Job {0} on '{1}'", jobId, pmta.Host);
     Thread.Sleep(new Random().Next(Heavy.Low, Heavy.High));
     FailTest();
 }
Ejemplo n.º 10
0
 public IList<string> GetHotmailQueuesByVmta(Mta pmta, IEnumerable<string> domains)
 {
     return GetQueuesForHost(pmta, null, null);
 }
Ejemplo n.º 11
0
 public void Purge(Mta pmta, string vmta)
 {
     Logger.TraceFormat("Purged Queue '{0}' on '{1}'", vmta, pmta.Host);
     Thread.Sleep(new Random().Next(Hefty.Low, Hefty.High));
     FailTest();
 }
Ejemplo n.º 12
0
 public void RemoveBackoff(Mta pmta, string vmta)
 {
     Logger.TraceFormat("Removed Backoff on Queue '{0}' on '{1}'", vmta, pmta.Host);
     Thread.Sleep(new Random().Next(Hefty.Low, Hefty.High));
     FailTest();
 }
Ejemplo n.º 13
0
 public void UnPause(Mta pmta, string vmta)
 {
     Logger.TraceFormat("UnPaused Queue '{0}' on '{1}'", vmta, pmta.Host);
     Thread.Sleep(new Random().Next(Lean.Low, Lean.High));
     FailTest();
 }
Ejemplo n.º 14
0
        public void Pause(Mta pmta, string vmta)
        {
            _logger.TraceFormat("Paused Queue '{0}' on '{1}'", vmta, pmta.Host);
            var cmd = string.Format("/usr/sbin/pmta pause queue {0}", vmta);

            RunCommand(cmd, pmta);
        }
Ejemplo n.º 15
0
        public void RemoveBackoff(Mta pmta, string vmta)
        {
            _logger.TraceFormat("Removed Backoff on Queue '{0}' on '{1}'", vmta, pmta.Host);
            var cmd = string.Format("/usr/sbin/pmta set queue --mode=normal {0}", vmta);

            RunCommand(cmd, pmta);
        }
Ejemplo n.º 16
0
        public void DeleteJob(Mta pmta, int jobId)
        {
            _logger.TraceFormat("Deleted Job {0} on '{1}'", jobId, pmta.Host);
            var cmd = string.Format("/usr/sbin/pmta delete --job={0}", jobId);

            RunCommand(cmd, pmta);
        }
Ejemplo n.º 17
0
 public bool IsQueueActive(Mta pmta, string queue)
 {
     Thread.Sleep(new Random().Next(Lean.Low, Lean.High));
     FailTest();
     return true;
 }