public void RemoteWorkerWaitsForJoinInRemoteNode() { var joinLock = new object(); var uriProviderMock = GetSimpleUriProvider(); var remoteServiceMock = new Mock<IRemoteWorkerService>(MockBehavior.Strict); remoteServiceMock.Setup(s => s.Init(It.IsAny<int>())); remoteServiceMock.Setup(s => s.TryJoin(It.IsAny<int>(), It.IsAny<Uri>())).Returns(() => { lock (joinLock) { Monitor.Wait(joinLock); } return new string[] { "a" }; }); MockerForRemoteWorkerService.Mock = remoteServiceMock.Object; var worker = new RemoteWorker<MockerForRemoteWorkerService>(); worker.Init(); var joinThread = new Thread(() => { worker.Join(); }); joinThread.Start(); Thread.Sleep(10); joinThread.ThreadState.ShouldBe(ThreadState.WaitSleepJoin); lock (joinLock) { Monitor.Pulse(joinLock); } joinThread.Join(); remoteServiceMock.VerifyAll(); }
public void RemoteReduceWorks() { var coordinatorStorage = new FileSystemStorage(@"c:\temp\netreduce\coordinator", true); var coordinatorProcess = Process.Start(new ProcessStartInfo(@"..\..\..\NetReduce.CoordinatorService.ConsoleHost\bin\Debug\NetReduce.CoordinatorService.ConsoleHost.exe")); Thread.Sleep(100); try { var workerStorage = new FileSystemStorage(@"c:\temp\netreduce\0", false); var reducerCodeFileName = new Uri("file:///SampleReducer.cs"); TestHelpers.LoadToStorage(@"..\..\..\NetReduce.Core.Tests\SampleReducer.cs", reducerCodeFileName, this.storage); IUriProvider uriProvider = new UriProvider(); uriProvider.Uris.Add(new Uri("http://*****:*****@"(?<Key>.+)", "[0-9]+", RegexExtensions.GuidRegexString)); var uris = workerStorage.ListFiles(); foreach (var uri in uris) { var fileName = workerStorage.GetFileName(uri); if (regex.IsMatch(fileName)) { var key = regex.Match(fileName).Groups["Key"].Value; if (Base64.Decode(key) == "k1") { result = workerStorage.Read(fileName); } } } result.ShouldBe("3"); } finally { coordinatorProcess.Kill(); } }
public void RemoteMapWorks() { var fileName = new Uri(string.Format("file:///{0}", Base64.Encode("file1.txt"))); var fileContent = "whatever am i i"; var mapperCodeFileName = new Uri("file:///SampleMapper.cs"); this.storage.Store(fileName, fileContent); TestHelpers.LoadToStorage(@"..\..\..\NetReduce.Core.Tests\SampleMapper.cs", mapperCodeFileName, this.storage); IUriProvider uriProvider = new UriProvider(); uriProvider.Uris.Add(new Uri("http://*****:*****@"c:\temp\netreduce\0", false); var fileNo = workerStorage.ListFiles().Count(); fileNo.ShouldBe(6); }