Example #1
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock)
            {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("NeonSwitch Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;

                if (bkTimer != null)
                {
                    bkTimer.Dispose();
                    bkTimer = null;
                }

                if (router != null)
                {
                    router.Stop();
                    router = null;
                }
            }
        }
Example #2
0
        public void ParallelQuerySession_WaitAll_SingleError()
        {
            // Test a single error query just to make sure it actually works.

            try
            {
                router = new LeafRouter();
                router.Start();
                router.Dispatcher.AddTarget(this);

                Thread.Sleep(1000);

                var parallelQuery = new ParallelQuery();
                var queryMsg1     = new PropertyMsg();

                queryMsg1["cmd"]   = "error";
                queryMsg1["value"] = "1";
                parallelQuery.Operations.Add(new ParallelOperation("logical://parallel/test", queryMsg1));

                router.ParallelQuery(parallelQuery);

                Assert.IsNotNull(parallelQuery.Operations[0].Error);
            }
            finally
            {
                if (router != null)
                {
                    router.Stop();
                    router = null;
                }

                Config.SetConfig(null);
            }
        }
Example #3
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock)
            {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("Dynamic DNS Client Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;
            }

            if (router != null)
            {
                client.Close();
                client = null;

                router.Stop();
                router = null;
            }

            Program.PerfCounters.Zero();
        }
Example #4
0
        public void StreamTransferSession_Upload_Sync()
        {
            StreamTransferSession clientSession;
            LeafRouter            router;

            InitServer();

            router = null;
            try
            {
                SetConfig("DefBlockSize=1000");

                router = new LeafRouter();
                router.Start();
                router.Dispatcher.AddTarget(this);

                clientSession      = StreamTransferSession.ClientUpload(router, "logical://Test/Upload", CreateStream(TransferSize));
                clientSession.Args = "Upload";
                clientSession.Transfer();

                Verify(msServer, TransferSize);
                Assert.IsTrue(serverNotify);
                Assert.IsNull(serverException);
                Assert.AreEqual("Upload", serverArgs);
            }
            finally
            {
                if (router != null)
                {
                    router.Stop();
                }

                Config.SetConfig(null);
            }
        }
Example #5
0
        public void ReliableMessenger_Client_PlugIn()
        {
            LeafRouter         router    = null;
            IReliableMessenger messenger = null;

            System.Type type;

            try
            {
                router = CreateLeaf("detached", "hub", group);

                type = typeof(LazyMessenger);
                Config.SetConfig(string.Format("args=messenger-type={0}:{1};confirm-ep=logical://foo", type.FullName, type.Assembly.Location));
                messenger = ReliableMessenger.OpenClient(router, "args", null);
                Assert.IsInstanceOfType(messenger, typeof(LazyMessenger));
                Assert.IsTrue(messenger.IsClient);
            }
            finally
            {
                if (messenger != null)
                {
                    messenger.Close();
                }

                if (router != null)
                {
                    router.Stop();
                }

                Config.SetConfig(null);
            }
        }
Example #6
0
        public void StreamTransferSession_Upload_Async()
        {
            StreamTransferSession clientSession;
            LeafRouter            router;

            InitServer();

            router = null;
            try
            {
                SetConfig("DefBlockSize=1000");

                router = new LeafRouter();
                router.Start();
                router.Dispatcher.AddTarget(this);

                clientSession = StreamTransferSession.ClientUpload(router, "logical://Test/Upload", CreateStream(TransferSize));
                clientSession.BeginTransfer(new AsyncCallback(OnClientDone), clientSession);
                clientWait.WaitOne(TimeSpan.FromSeconds(30), false);

                Verify(msServer, TransferSize);
                Assert.IsTrue(serverNotify);
                Assert.IsNull(serverException);
            }
            finally
            {
                if (router != null)
                {
                    router.Stop();
                }

                Config.SetConfig(null);
            }
        }
Example #7
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock)
            {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("Config Service Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;

                if (router != null)
                {
                    handler.Stop();
                    handler = null;

                    router.Stop();
                    router = null;
                }
            }
        }
Example #8
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock) {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("GeoTracker Service Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;
            }

            if (node != null)
            {
                node.Stop();
                node = null;
            }

            if (router != null)
            {
                router.Stop();
                router = null;
            }

            Program.PerfCounters.Zero();
        }
Example #9
0
        /// <summary>
        /// Stops the service immediately, terminating any user activity.
        /// </summary>
        public void Stop()
        {
            lock (syncLock)
            {
                if (state == ServiceState.Stopped)
                {
                    return;
                }

                SysLog.LogInformation("Authentication Service Stop");
                SysLog.Flush();

                base.Close();
                state = ServiceState.Stopped;

                if (handler != null)
                {
                    handler.Stop();
                    handler = null;
                }

                if (router != null)
                {
                    router.Stop();
                    router = null;
                }

                Program.PerfCounters.Zero();
            }
        }
Example #10
0
        public void TopologyHelper_Client_PlugIn()
        {
            LeafRouter        router  = null;
            ITopologyProvider cluster = null;

            System.Type type;

            try
            {
                router = CreateLeaf("detached", "hub", Helper.NewGuid().ToString(), group);

                type = typeof(BasicTopology);
                Config.SetConfig(string.Format("topology-type={0}:{1}\r\nargs=cluster-ep=logical://foo", type.FullName, type.Assembly.Location));
                cluster = TopologyHelper.OpenClient(router, "topology-type", "args");
                Assert.AreEqual(type.FullName, cluster.GetType().FullName);
                Assert.IsTrue(cluster.IsClient);
            }
            finally
            {
                if (cluster != null)
                {
                    cluster.Close();
                }

                if (router != null)
                {
                    router.Stop();
                }

                Config.SetConfig(null);
            }
        }
Example #11
0
        public void TopologyHelper_Server_PlugIn()
        {
            LeafRouter        client        = null;
            LeafRouter        server        = null;
            ITopologyProvider clientCluster = null;
            ITopologyProvider serverCluster = null;

            System.Type type;
            PropertyMsg reply;

            try
            {
                client = CreateLeaf("detached", "hub", Helper.NewGuid().ToString(), group);
                server = CreateLeaf("detached", "hub", Helper.NewGuid().ToString(), group);

                type = typeof(BasicTopology);
                Config.SetConfig(string.Format("topology-type={0}:{1}\r\nargs=cluster-ep=logical://foo", type.FullName, type.Assembly.Location));

                clientCluster = TopologyHelper.OpenClient(client, "topology-type", "args");
                Assert.AreEqual(type.FullName, clientCluster.GetType().FullName);
                Assert.IsTrue(clientCluster.IsClient);

                Config.SetConfig(string.Format("topology-type={0}:{1}\r\nargs=cluster-ep=logical://foo", type.FullName, type.Assembly.Location));
                serverCluster = TopologyHelper.OpenServer(client, "A", this, "topology-type", "args");
                Assert.AreEqual(type.FullName, serverCluster.GetType().FullName);
                Assert.IsFalse(serverCluster.IsClient);

                Thread.Sleep(2000);

                reply = (PropertyMsg)clientCluster.Query(null, new PropertyMsg());
                Assert.AreEqual("Hello World!", reply["value"]);
            }
            finally
            {
                if (client != null)
                {
                    client.Stop();
                }

                if (server != null)
                {
                    server.Stop();
                }

                if (clientCluster != null)
                {
                    clientCluster.Close();
                }

                if (serverCluster != null)
                {
                    serverCluster.Close();
                }

                Config.SetConfig(null);
            }
        }
Example #12
0
        public void Cleanup()
        {
            Helper.SetLocalGuidMode(GuidMode.Normal);
            Config.SetConfig(null);

            if (router != null)
            {
                router.Stop();
            }

            NetTrace.Stop();
        }
Example #13
0
        public void Cleanup()
        {
            Config.SetConfig(null);

            if (router != null)
            {
                router.Stop();
            }

            NetTrace.Stop();
            Helper.DeleteFile(tempFolder, true);
        }
Example #14
0
        public void ParallelQuerySession_WaitAll_PartialFail()
        {
            // Test 4 parallel queries where 2 succeed and two fail.

            try
            {
                router = new LeafRouter();
                router.Start();
                router.Dispatcher.AddTarget(this);

                Thread.Sleep(1000);

                var parallelQuery = new ParallelQuery();
                var queryMsg1     = new PropertyMsg();
                var queryMsg2     = new PropertyMsg();
                var queryMsg3     = new PropertyMsg();
                var queryMsg4     = new PropertyMsg();

                queryMsg1["cmd"]   = "reply";
                queryMsg1["value"] = "1";
                parallelQuery.Operations.Add(new ParallelOperation("logical://parallel/test", queryMsg1));

                queryMsg2["cmd"]   = "error";
                queryMsg2["value"] = "2";
                parallelQuery.Operations.Add(new ParallelOperation("logical://parallel/test", queryMsg2));

                queryMsg3["cmd"]   = "reply";
                queryMsg3["value"] = "3";
                parallelQuery.Operations.Add(new ParallelOperation("logical://parallel/test", queryMsg3));

                queryMsg4["cmd"]   = "error";
                queryMsg4["value"] = "4";
                parallelQuery.Operations.Add(new ParallelOperation("logical://parallel/test", queryMsg4));

                router.ParallelQuery(parallelQuery);

                Assert.AreEqual("1", ((PropertyMsg)parallelQuery.Operations[0].ReplyMsg)["value"]);
                Assert.AreEqual("3", ((PropertyMsg)parallelQuery.Operations[2].ReplyMsg)["value"]);

                Assert.AreEqual("Error: 2", parallelQuery.Operations[1].Error.Message);
                Assert.AreEqual("Error: 4", parallelQuery.Operations[3].Error.Message);
            }
            finally
            {
                if (router != null)
                {
                    router.Stop();
                    router = null;
                }

                Config.SetConfig(null);
            }
        }
Example #15
0
        public void Cleanup()
        {
            if (handler != null)
            {
                handler.Stop();
            }

            if (router != null)
            {
                router.Stop();
            }

            NetTrace.Stop();
        }
Example #16
0
        /// <summary>
        /// Starts the service, associating it with an <see cref="IServiceHost" /> instance.
        /// </summary>
        /// <param name="serviceHost">The service user interface.</param>
        /// <param name="args">Command line arguments.</param>
        public void Start(IServiceHost serviceHost, string[] args)
        {
            lock (syncLock)
            {
                if (router != null)
                {
                    return;     // Already started
                }
                // Global initialization

                NetTrace.Start();

                Program.Config = new Config(MsgQueueHandler.ConfigPrefix);
                Program.InstallPerfCounters();

                // Service initialization

                this.serviceHost = serviceHost;
                SysLog.LogInformation("Message Queue v{0} Start", Helper.GetVersionString());

                try
                {
                    router = new LeafRouter();
                    router.Start();

                    handler = new MsgQueueHandler();
                    handler.Start(router, null, Program.PerfCounters, null);

                    state = ServiceState.Running;
                }
                catch (Exception e)
                {
                    if (handler != null)
                    {
                        handler.Stop();
                        handler = null;
                    }

                    if (router != null)
                    {
                        router.Stop();
                        router = null;
                    }

                    SysLog.LogException(e);
                    throw;
                }
            }
        }
Example #17
0
        /// <summary>
        /// Starts the service, associating it with an <see cref="IServiceHost" /> instance.
        /// </summary>
        /// <param name="serviceHost">The service user interface.</param>
        /// <param name="args">Command line arguments.</param>
        public void Start(IServiceHost serviceHost, string[] args)
        {
            lock (syncLock)
            {
                if (router != null)
                {
                    return;     // Already started
                }
                // Global initialization

                NetTrace.Start();
                Program.Config       = new Config(ConfigServiceHandler.ConfigPrefix);
                Program.PerfCounters = null;    // $todo(jeff.lill): new PerfCounterSet(true,Const.ConfigServicePerf,Const.ConfigServiceName);

                // Service initialization

                this.serviceHost = serviceHost;
                SysLog.LogInformation("Config Service v{0} Start", Helper.GetVersionString());

                try
                {
                    router = new LeafRouter();
                    router.Start();

                    handler = new ConfigServiceHandler();
                    handler.Start(router, null, null, null);

                    state = ServiceState.Running;
                }
                catch (Exception e)
                {
                    if (handler != null)
                    {
                        handler.Stop();
                        handler = null;
                    }

                    if (router != null)
                    {
                        router.Stop();
                        router = null;
                    }

                    SysLog.LogException(e);
                    throw;
                }
            }
        }
Example #18
0
        /// <summary>
        /// Starts the service, associating it with an <see cref="IServiceHost" /> instance.
        /// </summary>
        /// <param name="serviceHost">The service user interface.</param>
        /// <param name="args">Command line arguments.</param>
        public void Start(IServiceHost serviceHost, string[] args)
        {
            lock (syncLock)
            {
                if (router != null)
                {
                    return;     // Already started
                }
                // Global initialization

                NetTrace.Start();
                Program.Config = new Config("LillTek.Datacenter.DynDNSClient");
                Program.InstallPerfCounters();

                // Service initialization

                this.serviceHost = serviceHost;
                SysLog.LogInformation("Dynamic DNS Client v{0} Start", Helper.GetVersionString());

                try
                {
                    router = new LeafRouter();
                    router.Start();

                    client = new DynDnsClient();
                    client.Open(router, new DynDnsClientSettings("LillTek.Datacenter.DynDNSClient"));

                    state = ServiceState.Running;
                }
                catch (Exception e)
                {
                    if (client != null)
                    {
                        client.Close();
                        client = null;
                    }

                    if (router != null)
                    {
                        router.Stop();
                        router = null;
                    }

                    SysLog.LogException(e);
                    throw;
                }
            }
        }
Example #19
0
        private void TestCleanup()
        {
            client = null;

            if (server != null)
            {
                server.Stop();
                server = null;
            }

            if (router != null)
            {
                router.Stop();
                router = null;
            }
        }
Example #20
0
        public void StreamTransferSession_Upload_ErrorOnClient()
        {
            StreamTransferSession clientSession;
            LeafRouter            router;
            IAsyncResult          ar;

            InitServer();

            router = null;
            try
            {
                SetConfig("DefBlockSize=1000");

                router = new LeafRouter();
                router.Start();
                router.Dispatcher.AddTarget(this);

                clientSession               = StreamTransferSession.ClientUpload(router, "logical://Test/Upload", CreateStream(TransferSize));
                clientSession.Delay         = 500;
                clientSession.SimulateError = true;
                ar = clientSession.BeginTransfer(null, null);

                Thread.Sleep(1000);
                clientSession.Cancel();

                clientSession.EndTransfer(ar);
                Assert.Fail("Expected an exception");
            }
            catch
            {
                // Expecting an exception
            }
            finally
            {
                if (router != null)
                {
                    router.Stop();
                }

                Config.SetConfig(null);
            }

            Thread.Sleep(1000);
            Assert.IsTrue(serverNotify);
            Assert.IsInstanceOfType(serverException, typeof(SessionException));
        }
Example #21
0
        /// <summary>
        /// Starts the service, associating it with an <see cref="IServiceHost" /> instance.
        /// </summary>
        /// <param name="serviceHost">The service user interface.</param>
        /// <param name="args">Command line arguments.</param>
        public void Start(IServiceHost serviceHost, string[] args)
        {
            lock (syncLock) {
                if (router != null)
                {
                    return;     // Already started
                }
                // Global initialization

                NetTrace.Start();
                Program.Config = new Config("LillTek.GeoTracker.Service");
                Program.InstallPerfCounters();

                // Service initialization

                this.serviceHost = serviceHost;
                SysLog.LogInformation("GeoTracker Service v{0} Start", Helper.GetVersionString());

                try {
                    router = new LeafRouter();
                    router.Start();

                    node = new GeoTrackerNode();
                    node.Start(router, GeoTrackerNode.ConfigPrefix, Program.PerfCounters, null);

                    state = ServiceState.Running;
                }
                catch (Exception e) {
                    if (node != null)
                    {
                        node.Stop();
                        node = null;
                    }

                    if (router != null)
                    {
                        router.Stop();
                        router = null;
                    }

                    SysLog.LogException(e);
                    throw;
                }
            }
        }
Example #22
0
        public void StreamTransferSession_Download_ErrorOnServer()
        {
            StreamTransferSession clientSession;
            LeafRouter            router;
            EnhancedMemoryStream  msClient;

            InitServer();

            router = null;
            try
            {
                SetConfig("DefBlockSize=1000");

                router = new LeafRouter();
                router.Start();
                router.Dispatcher.AddTarget(this);

                msServer = CreateStream(TransferSize);
                msClient = new EnhancedMemoryStream();

                simServerError = true;

                clientSession       = StreamTransferSession.ClientDownload(router, "logical://Test/Download", msClient);
                clientSession.Delay = 500;
                clientSession.Transfer();
                Assert.Fail("Expecting a SessionException");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(SessionException));
            }
            finally
            {
                if (router != null)
                {
                    router.Stop();
                }

                Config.SetConfig(null);
            }

            Thread.Sleep(1000);
            Assert.IsTrue(serverNotify);
            Assert.IsInstanceOfType(serverException, typeof(Exception));
        }
Example #23
0
        public void StreamTransferSession_Cancel_OnServer()
        {
            StreamTransferSession clientSession;
            LeafRouter            router;

            InitServer();

            router = null;
            try
            {
                SetConfig("DefBlockSize=1000");

                router = new LeafRouter();
                router.Start();
                router.Dispatcher.AddTarget(this);

                simServerCancel = true;

                clientSession       = StreamTransferSession.ClientUpload(router, "logical://Test/Upload", CreateStream(TransferSize));
                clientSession.Delay = 500;
                clientSession.Transfer();
                Assert.Fail("Expected a CancelException");
            }
            catch (SessionException e)
            {
                SysLog.LogException(e);
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(CancelException));
            }
            finally
            {
                if (router != null)
                {
                    router.Stop();
                }

                Config.SetConfig(null);
            }

            Thread.Sleep(1000);
            Assert.IsTrue(serverNotify);
            Assert.IsInstanceOfType(serverException, typeof(CancelException));
        }
Example #24
0
        private void stopButton_Click(object sender, EventArgs args)
        {
            if (!running)
            {
                return;
            }

            foreach (ITestForm test in testForms)
            {
                test.Stop();
            }

            Router.Stop();
            Router = null;

            running = false;
            SetUIState();
        }
Example #25
0
        private void TestCleanup()
        {
            client = null;

            foreach (var instance in clusterInstances)
            {
                instance.Stop();
            }

            clusterInstances = null;

            if (router != null)
            {
                router.Stop();
                router = null;
            }

            //NetTrace.Stop();
        }
Example #26
0
        private void TestCleanup()
        {
            client = null;

            if (server != null)
            {
                server.Stop();
                server = null;
            }

            if (router != null)
            {
                router.Stop();
                router = null;
            }

            Helper.DeleteFile(IPGeocoder.DataPath);
            Helper.DeleteFile(IPGeocoder.DownloadPath);
            Helper.DeleteFile(IPGeocoder.DecryptedPath);
        }
Example #27
0
        public void StreamTransferSession_WrongDirection_Upload()
        {
            StreamTransferSession clientSession;
            LeafRouter            router;
            EnhancedMemoryStream  msClient;

            InitServer();

            router = null;
            try
            {
                SetConfig("DefBlockSize=1000");

                router = new LeafRouter();
                router.Start();
                router.Dispatcher.AddTarget(this);

                msServer = CreateStream(TransferSize);
                msClient = new EnhancedMemoryStream();

                clientSession = StreamTransferSession.ClientUpload(router, "logical://Test/Download", msClient);
                clientSession.Transfer();
                Assert.Fail("Expected a SessionException");
            }
            catch (Exception e)
            {
                Assert.IsInstanceOfType(e, typeof(SessionException));
            }
            finally
            {
                if (router != null)
                {
                    router.Stop();
                }

                Config.SetConfig(null);
            }
        }
Example #28
0
        public void ParallelQuerySession_WaitAny_SingleSuccess()
        {
            // Test a single successful query just to make sure it actually works.

            try
            {
                router = new LeafRouter();
                router.Start();
                router.Dispatcher.AddTarget(this);

                Thread.Sleep(1000);

                var parallelQuery = new ParallelQuery()
                {
                    WaitMode = ParallelWait.ForAny
                };
                var queryMsg1 = new PropertyMsg();

                queryMsg1["cmd"]   = "reply";
                queryMsg1["value"] = "1";
                parallelQuery.Operations.Add(new ParallelOperation("logical://parallel/test", queryMsg1));

                router.ParallelQuery(parallelQuery);

                Assert.AreEqual("1", ((PropertyMsg)parallelQuery.Operations[0].ReplyMsg)["value"]);
            }
            finally
            {
                if (router != null)
                {
                    router.Stop();
                    router = null;
                }

                Config.SetConfig(null);
            }
        }
Example #29
0
        public void AppStore_EndToEnd()
        {
            // This test peforms a simple end-to-end test of the AppStore
            // service by starting the service, uploading, downloading
            // and then deleting a package file.

            Process        svcProcess = null;
            LeafRouter     router     = null;
            AppStoreClient client     = null;
            Assembly       assembly;
            string         packageFolder;
            string         tempFolder;
            AppRef         appRef;

            Helper.InitializeApp(Assembly.GetExecutingAssembly());

            assembly      = typeof(LillTek.Datacenter.AppStore.Program).Assembly;
            tempFolder    = Helper.AddTrailingSlash(Path.GetTempPath());
            packageFolder = Helper.GetAssemblyFolder(assembly) + "packages\\";
            appRef        = AppRef.Parse("appref://MyApps/App00.zip?version=1.2.0.0");

            try
            {
                // Start a local router and open a client.

                Config.SetConfig(@"

//-----------------------------------------------------------------------------
// LeafRouter Settings

&section MsgRouter

    AppName                = LillTek.Test Router
    AppDescription         = Unit Test
    RouterEP			   = physical://DETACHED/$(LillTek.DC.DefHubName)/$(Guid)
    CloudEP                = $(LillTek.DC.CloudEP)
    CloudAdapter           = ANY
    UdpEP				   = ANY:0
    TcpEP				   = ANY:0
    TcpBacklog			   = 100
    TcpDelay			   = off
    BkInterval			   = 1s
    MaxIdle				   = 5m
    EnableP2P              = yes
    AdvertiseTime		   = 1m
    DefMsgTTL			   = 5
    Encryption		       = PLAINTEXT
    Key					   = 00
    SessionCacheTime       = 2m
    SessionRetries         = 3
    SessionTimeout         = 10s
    MaxLogicalAdvertiseEPs = 256
    DeadRouterTTL          = 2s
    
    // This maps the abstract AppStore endpoints to their default logical endpoints.

    AbstractMap[abstract://LillTek/DataCenter/AppStore]   = logical://LillTek/DataCenter/AppStore
    AbstractMap[abstract://LillTek/DataCenter/AppStore/*] = logical://LillTek/DataCenter/AppStore/*

&endsection

".Replace('&', '#'));

                router = new LeafRouter();
                router.Start();

                client = new AppStoreClient();
                client.Open(router, AppStoreClientSettings.LoadConfig("AppStore.Client"));

                // Start the application store service

                svcProcess = Helper.StartProcess(assembly, "-mode:form -start");
                Thread.Sleep(10000);    // Give the process a chance to spin up

                // Upload a package to the server

                CreatePackage(tempFolder, appRef);
                client.UploadPackage(null, appRef, tempFolder + appRef.FileName);
                Thread.Sleep(1000);
                CompareFiles(tempFolder + appRef.FileName, packageFolder + appRef.FileName);

                // Download the package

                File.Delete(tempFolder + appRef.FileName);
                client.DownloadPackage(null, appRef, tempFolder + appRef.FileName);
                Thread.Sleep(1000);
                CompareFiles(tempFolder + appRef.FileName, packageFolder + appRef.FileName);

                // Delete the package

                client.RemoveRemotePackage(null, appRef);
                Thread.Sleep(1000);
                Assert.IsFalse(File.Exists(packageFolder + appRef.FileName));
            }
            finally
            {
                if (svcProcess != null)
                {
                    svcProcess.Kill();
                    svcProcess.Close();
                }

                if (client != null)
                {
                    client.Close();
                }

                if (router != null)
                {
                    router.Stop();
                }

                if (File.Exists(tempFolder + appRef.FileName))
                {
                    File.Delete(tempFolder + appRef.FileName);
                }

                Config.SetConfig(null);
            }
        }
Example #30
0
        public void MessageQueue_EndToEnd_Disk()
        {
            // This test peforms a simple end-to-end test of the Message
            // Queue Service by starting the service and processing
            // some messages.

            Process    svcProcess = null;
            LeafRouter router     = null;
            MsgQueue   queue      = null;
            Assembly   assembly;

            Helper.InitializeApp(Assembly.GetExecutingAssembly());
            assembly = typeof(LillTek.Datacenter.MessageQueue.Program).Assembly;

            try
            {
                // Start a local router and open a client.

                Config.SetConfig(@"

//-----------------------------------------------------------------------------
// LeafRouter Settings

&section MsgRouter

    AppName                = LillTek.Test Router
    AppDescription         = Unit Test
    RouterEP			   = physical://DETACHED/$(LillTek.DC.DefHubName)/$(Guid)
    CloudEP                = $(LillTek.DC.CloudEP)
    CloudAdapter           = ANY
    UdpEP				   = ANY:0
    TcpEP				   = ANY:0
    TcpBacklog			   = 100
    TcpDelay			   = off
    BkInterval			   = 1s
    MaxIdle				   = 5m
    EnableP2P              = yes
    AdvertiseTime		   = 1m
    DefMsgTTL			   = 5
    SharedKey		       = PLAINTEXT
    SessionCacheTime       = 2m
    SessionRetries         = 3
    SessionTimeout         = 10s
    MaxLogicalAdvertiseEPs = 256
    DeadRouterTTL          = 2s

&endsection

".Replace('&', '#'));

                router = new LeafRouter();
                router.Start();

                // Start the application store service

                svcProcess = Helper.StartProcess(assembly, "-mode:form -start");
                Thread.Sleep(10000);    // Give the process a chance to spin up

                // Send and receive some messages

                queue = new MsgQueue(router);
                queue.EnqueueTo("logical://LillTek/DataCenter/MsgQueue/10", new QueuedMsg(10));

                //for (int i=0;i<10;i++)
                //    queue.EnqueueTo("logical://LillTek/DataCenter/MsgQueue/" + i.ToString(),new QueuedMsg(i));

                //for (int i=0;i<10;i++)
                //    Assert.AreEqual(i,queue.DequeueFrom("logical://LillTek/DataCenter/MsgQueue/" + i.ToString(),TimeSpan.FromSeconds(1)).Body);
            }
            finally
            {
                if (svcProcess != null)
                {
                    svcProcess.Kill();
                    svcProcess.Close();
                }

                if (queue != null)
                {
                    queue.Close();
                }

                if (router != null)
                {
                    router.Stop();
                }

                Config.SetConfig(null);
            }
        }