public long _2_0_2_AddJob_Async_TimeToLive_Wait_Dead(Disquuun disquuun) { WaitUntil("_2_0_2_AddJob_Async_TimeToLive_Wait_Dead", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = string.Empty; disquuun.AddJob(queueId, data_10, 0, "TTL", 1).Async( (command, result) => { jobId = DisquuunDeserializer.AddJob(result); } ); WaitUntil("_2_0_2_AddJob_Async_TimeToLive_Wait_Dead", () => !string.IsNullOrEmpty(jobId), 5); // wait 2 sec. Wait("_2_0_2_AddJob_Async_TimeToLive_Wait_Dead", 2); // get queue len. var len = DisquuunDeserializer.Qlen(disquuun.Qlen(queueId).DEPRICATED_Sync()); Assert("_2_0_2_AddJob_Async_TimeToLive_Wait_Dead", len == 0, "not match, len:" + len); return(0); }
public long _2_8_Qlen_Async(Disquuun disquuun) { WaitUntil("_2_8_Qlen_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = DisquuunDeserializer.AddJob( disquuun.AddJob(queueId, data_10).DEPRICATED_Sync() ); var w = new Stopwatch(); w.Start(); var qlen = 0; disquuun.Qlen(queueId).Async( (c, data) => { qlen = DisquuunDeserializer.Qlen(data); w.Stop(); } ); WaitUntil("_2_8_Qlen_Async", () => (qlen == 1), 5); var result = disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); var ackCount = DisquuunDeserializer.FastAck(result); return(w.ElapsedMilliseconds); }
public long _2_9_Qstat_Async(Disquuun disquuun) { WaitUntil("_2_9_Qstat_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = DisquuunDeserializer.AddJob(disquuun.AddJob(queueId, data_10).DEPRICATED_Sync()); var w = new Stopwatch(); w.Start(); var qstatLen = 0; disquuun.Qstat(queueId).Async( (command, data) => { qstatLen = DisquuunDeserializer.Qstat(data).len; w.Stop(); } ); WaitUntil("_2_9_Qstat_Async", () => (qstatLen == 1), 5); disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); return(w.ElapsedMilliseconds); }
public long _2_0_1_AddJob_Async_TimeToLive(Disquuun disquuun) { WaitUntil("_2_0_1_AddJob_Async_TimeToLive", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = string.Empty; var w = new Stopwatch(); w.Start(); disquuun.AddJob(queueId, data_10, 0, "TTL", 100).Async( (command, result) => { jobId = DisquuunDeserializer.AddJob(result); w.Stop(); } ); WaitUntil("_2_0_1_AddJob_Async_TimeToLive", () => !string.IsNullOrEmpty(jobId), 5); // ack in. disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); return(w.ElapsedMilliseconds); }
public long _2_2_AckJob_Async(Disquuun disquuun) { WaitUntil("_2_2_AckJob_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var jobId = DisquuunDeserializer.AddJob( disquuun.AddJob(queueId, data_10).DEPRICATED_Sync() ); var w = new Stopwatch(); w.Start(); var ackCount = 0; disquuun.AckJob(new string[] { jobId }).Async( (command, result) => { ackCount = DisquuunDeserializer.AckJob(result); w.Stop(); } ); WaitUntil("_2_2_AckJob_Async", () => (ackCount == 1), 5); return(w.ElapsedMilliseconds); }
public long _2_1_4_GetJobWithCounters_Async(Disquuun disquuun) { WaitUntil("_2_1_4_GetJobWithCounters_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); disquuun.AddJob(queueId, data_100).DEPRICATED_Sync(); var ackCount = -1; var w = new Stopwatch(); w.Start(); disquuun.GetJob(new string[] { queueId }, "withcounters").Async( (command, result) => { var jobDatas = DisquuunDeserializer.GetJob(result); ackCount = jobDatas[0].additionalDeliveriesCount; w.Stop(); disquuun.FastAck(new string[] { jobDatas[0].jobId }).Async( (c, d) => { } ); } ); WaitUntil("_2_1_4_GetJobWithCounters_Async", () => (ackCount == 0), 5); return(w.ElapsedMilliseconds); }
public void _0_0_4_ReadmeSamplePipeline(Disquuun disquuun) { WaitUntil("_0_0_4_ReadmeSamplePipeline", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var fastacked = false; disquuun.Pipeline( disquuun.AddJob("my queue name", new byte[100]), disquuun.GetJob(new string[] { "my queue name" }) ).Execute( (command, data) => { if (command != DisqueCommand.GETJOB) { return; } var jobs = DisquuunDeserializer.GetJob(data); var jobIds = jobs.Select(jobData => jobData.jobId).ToArray(); var jobDatas = jobs.Select(jobData => jobData.jobData).ToList(); /* * fast ack all. */ disquuun.FastAck(jobIds).Async( (command2, data2) => { fastacked = true; } ); } ); WaitUntil("_0_0_4_ReadmeSamplePipeline", () => fastacked, 5); }
public void _2_1_2_GetJobFromMultiQueue_Async(Disquuun disquuun) { WaitUntil("_2_1_2_GetJobFromMultiQueue_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId1 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId1, new byte[10]).DEPRICATED_Sync(); var queueId2 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId2, new byte[10]).DEPRICATED_Sync(); DisquuunDeserializer.JobData[] jobDatas = new DisquuunDeserializer.JobData[] {}; disquuun.GetJob(new string[] { queueId1, queueId2 }, "count", 2).Async( (command, result) => { jobDatas = DisquuunDeserializer.GetJob(result); } ); WaitUntil("_2_1_2_GetJobFromMultiQueue_Async", () => (jobDatas.Length == 2), 5); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); }
public long _2_1_GetJob_Async(Disquuun disquuun) { WaitUntil("_2_1_GetJob_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); disquuun.AddJob(queueId, data_10).DEPRICATED_Sync(); DisquuunDeserializer.JobData[] jobDatas = new DisquuunDeserializer.JobData[] { }; var w = new Stopwatch(); w.Start(); disquuun.GetJob(new string[] { queueId }).Async( (command, result) => { jobDatas = DisquuunDeserializer.GetJob(result); w.Stop(); } ); WaitUntil("_2_1_GetJob_Async", () => (jobDatas.Length == 1), 5); // ack in. var jobId = jobDatas[0].jobId; disquuun.FastAck(new string[] { jobId }).DEPRICATED_Sync(); return(w.ElapsedMilliseconds); }
public long _1_1_1_GetJobWithCount_Sync(Disquuun disquuun) { WaitUntil("_1_1_1_GetJobWithCount_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var w = new Stopwatch(); w.Start(); var queueId = Guid.NewGuid().ToString(); var addJobCount = 10000; for (var i = 0; i < addJobCount; i++) { disquuun.AddJob(queueId, data_100).DEPRICATED_Sync(); } var result = disquuun.GetJob(new string[] { queueId }, "COUNT", addJobCount).DEPRICATED_Sync(); var jobDatas = DisquuunDeserializer.GetJob(result); Assert("_1_1_1_GetJobWithCount_Sync", addJobCount, jobDatas.Length, "not match."); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); w.Stop(); return(w.ElapsedMilliseconds); }
public long _5_0_ConnectionFailed(Disquuun disquuun) { WaitUntil("_5_0_ConnectionFailed", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); Exception error = null; var disquuun2 = new Disquuun( DisquuunTests.TestDisqueHostStr, DisquuunTests.TestDisqueDummyPortNum,// fake port number. 1, 1, (conId) => { }, (info, e) => { error = e; }, (currentSocketCount, addSocket) => { return; } ); WaitUntil("_5_0_ConnectionFailed", () => (error != null), 5); disquuun2.Disconnect(); return(0); }
public long _1_0_2_AddJob_Sync_TimeToLive_Wait_Dead(Disquuun disquuun) { WaitUntil("_1_0_2_AddJob_Sync_TimeToLive_Wait_Dead", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var w = new Stopwatch(); w.Start(); var queueId = Guid.NewGuid().ToString(); var result = disquuun.AddJob(queueId, data_10, 0, "TTL", 1).DEPRICATED_Sync(); var jobId = DisquuunDeserializer.AddJob(result); WaitUntil("_1_0_2_AddJob_Sync_TimeToLive_Wait_Dead", () => !string.IsNullOrEmpty(jobId), 5); // wait 2 sec. Wait("_1_0_2_AddJob_Sync_TimeToLive_Wait_Dead", 2); // get queue len. var len = DisquuunDeserializer.Qlen(disquuun.Qlen(queueId).DEPRICATED_Sync()); Assert("_1_0_2_AddJob_Sync_TimeToLive_Wait_Dead", len == 0, "not match, len:" + len); w.Stop(); return(w.ElapsedMilliseconds); }
public long _6_1_ExceededSocketNo100In2(Disquuun disquuun) { WaitUntil("_6_1_ExceededSocketNo100In2", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var infoCount = 0; var connectCount = 1000; var w = new Stopwatch(); w.Start(); for (var i = 0; i < connectCount; i++) { disquuun.Info().Async( (command, data) => { lock (_6_1_ExceededSocketNo100In2LockObject) infoCount++; } ); } WaitUntil("_6_1_ExceededSocketNo100In2", () => (infoCount == connectCount), 5); w.Stop(); return(w.ElapsedMilliseconds); }
public long _6_2_ExceededSocketShouldStacked(Disquuun disquuun) { WaitUntil("_6_2_ExceededSocketShouldStacked", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var infoCount = 0; var connectCount = 1000; var w = new Stopwatch(); w.Start(); for (var i = 0; i < connectCount; i++) { disquuun.Info().Async( (command, data) => { lock (_6_2_ExceededSocketShouldStackedLockObject) infoCount++; } ); } var stackedCommandCount = disquuun.StackedCommandCount(); // this assert "maybe" hit. not hit if sockets can run so fast. Assert("_6_2_ExceededSocketShouldStacked", 0 < stackedCommandCount, "not match, " + stackedCommandCount); WaitUntil("_6_2_ExceededSocketShouldStacked", () => (infoCount == connectCount), 5); w.Stop(); return(w.ElapsedMilliseconds); }
public long _4_5_ByfferOverWithSokcetOverSyncGetJob_Async(Disquuun disquuun) { WaitUntil("_4_5_ByfferOverWithSokcetOverSyncGetJob_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var addJobCount = 10001; for (var i = 0; i < addJobCount; i++) { disquuun.AddJob(queueId, data_100).DEPRICATED_Sync(); } DisquuunDeserializer.JobData[] jobDatas = new DisquuunDeserializer.JobData[] { }; disquuun.GetJob(new string[] { queueId }, "COUNT", addJobCount).Async( (command, result) => { jobDatas = DisquuunDeserializer.GetJob(result); } ); WaitUntil("_4_5_ByfferOverWithSokcetOverSyncGetJob_Async", () => (jobDatas.Length == addJobCount), 5); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); return(0); }
public long _2_1_3_GetJobWithNoHang_Async(Disquuun disquuun) { WaitUntil("_2_1_3_GetJobWithNoHang_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); bool received = false; var w = new Stopwatch(); w.Start(); disquuun.GetJob(new string[] { queueId }, "NOHANG").Async( (command, result) => { var jobDatas = DisquuunDeserializer.GetJob(result); Assert("_2_1_3_GetJobWithNoHang_Async", jobDatas.Length == 0, "not match."); received = true; w.Stop(); } ); WaitUntil("_2_1_3_GetJobWithNoHang_Async", () => received, 5); return(w.ElapsedMilliseconds); }
public long _0_1_ConnectionFailedWithNoDisqueServer(Disquuun disquuun) { WaitUntil("_0_1_ConnectionFailedWithNoDisqueServer", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); Exception e = null; var w = new Stopwatch(); w.Start(); var disquuun2 = new Disquuun(DisquuunTests.TestDisqueHostStr, DisquuunTests.TestDisqueDummyPortNum, 1024, 1, conId => { }, (info, e2) => { // set error to param, lock (_0_1_ConnectionFailedWithNoDisqueServerObject) e = e2; // TestLogger.Log("e:" + e); }, (currentSocketCount, addSocket) => { return; } ); WaitUntil("_0_1_ConnectionFailedWithNoDisqueServer", () => (e != null), 1); w.Stop(); return(w.ElapsedMilliseconds); }
public long _0_7_LoopInfo_100(Disquuun disquuun) { WaitUntil("_0_7_LoopInfo_100", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var infos = new List <string>(); var w = new Stopwatch(); w.Start(); disquuun.Info().Loop( (DisqueCommand command, DisquuunResult[] datas) => { var infoStr = DisquuunDeserializer.Info(datas).rawString; lock (_0_7_LoopInfo_100Object) infos.Add(infoStr); if (infos.Count < 100) { return(true); } return(false); } ); WaitUntil("_0_7_LoopInfo_100", () => (infos.Count == 100), 5); w.Stop(); return(w.ElapsedMilliseconds); }
public void _2_1_1_GetJobWithCount_Async(Disquuun disquuun) { WaitUntil("_2_1_1_GetJobWithCount_Async", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var addJobCount = 10000; for (var i = 0; i < addJobCount; i++) { disquuun.AddJob(queueId, new byte[100]).DEPRICATED_Sync(); } DisquuunDeserializer.JobData[] jobDatas = new DisquuunDeserializer.JobData[] {}; disquuun.GetJob(new string[] { queueId }, "COUNT", addJobCount).Async( (command, result) => { jobDatas = DisquuunDeserializer.GetJob(result); } ); WaitUntil("_2_1_1_GetJobWithCount_Async", () => (jobDatas.Length == addJobCount), 5); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); }
public long _1_1_2_GetJobFromMultiQueue_Sync(Disquuun disquuun) { WaitUntil("_1_1_2_GetJobFromMultiQueue_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var w = new Stopwatch(); w.Start(); var queueId1 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId1, data_10).DEPRICATED_Sync(); var queueId2 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId2, data_10).DEPRICATED_Sync(); var result = disquuun.GetJob(new string[] { queueId1, queueId2 }, "count", 2).DEPRICATED_Sync(); var jobDatas = DisquuunDeserializer.GetJob(result); Assert("_1_1_2_GetJobFromMultiQueue_Sync", 2, jobDatas.Length, "not match."); // ack in. var jobIds = jobDatas.Select(job => job.jobId).ToArray(); disquuun.FastAck(jobIds).DEPRICATED_Sync(); w.Stop(); return(w.ElapsedMilliseconds); }
public long _5_1_ConnectionFailedMultiple(Disquuun disquuun) { WaitUntil("_5_1_ConnectionFailedMultiple", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); List <Exception> errors = new List <Exception>(); var disquuun2 = new Disquuun( DisquuunTests.TestDisqueHostStr, DisquuunTests.TestDisqueDummyPortNum,// fake port number. 1, 5, (conId) => { }, (info, e) => { lock (_5_1_ConnectionFailedMultipleLockObject) { errors.Add(e); } }, (currentSocketCount, addSocket) => { return; } ); WaitUntil("_5_1_ConnectionFailedMultiple", () => (errors.Count == 5), 10); disquuun2.Disconnect(); return(0); }
public void _0_2_SyncInfo(Disquuun disquuun) { WaitUntil("", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var data = disquuun.Info().DEPRICATED_Sync(); var infoStr = DisquuunDeserializer.Info(data).rawString; Assert("_0_2_SyncInfo", !string.IsNullOrEmpty(infoStr), "empty."); }
public void _7_2_GetJob1000byLoop(Disquuun disquuun) { WaitUntil("_7_2_GetJob1000byLoop", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var addingJobCount = 1000 * loadLevel; var queueId = Guid.NewGuid().ToString(); var addedCount = 0; for (var i = 0; i < addingJobCount; i++) { disquuun.AddJob(queueId, new byte[10]).Async( (command, data) => { lock (_7_2_GetJob1000byLoopLockObject) addedCount++; } ); } WaitUntil("_7_2_GetJob1000byLoop", () => (addedCount == addingJobCount), 5); var gotJobDataIds = new List <string>(); var w = new Stopwatch(); w.Start(); disquuun.GetJob(new string[] { queueId }).Loop( (command, data) => { lock (_7_2_GetJob1000byLoopLockObject) { var jobDatas = DisquuunDeserializer.GetJob(data); var jobIds = jobDatas.Select(j => j.jobId).ToList(); gotJobDataIds.AddRange(jobIds); if (gotJobDataIds.Count == addingJobCount) { w.Stop(); return(false); } return(true); } } ); WaitUntil("_7_2_GetJob1000byLoop 1", () => (gotJobDataIds.Count == addingJobCount), 20); WaitUntil("_7_2_GetJob1000byLoop 2", () => (0 < disquuun.AvailableSocketNum()), 1); TestLogger.Log("_7_2_GetJob1000byLoop w:" + w.ElapsedMilliseconds + " tick:" + w.ElapsedTicks); var fastackedCount = 0; disquuun.FastAck(gotJobDataIds.ToArray()).Async( (c, data) => { fastackedCount = DisquuunDeserializer.FastAck(data); } ); WaitUntil("_7_2_GetJob1000byLoop 3", () => (addingJobCount == fastackedCount), 10); }
public void _1_6_Info_Sync(Disquuun disquuun) { WaitUntil("_1_6_Info_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var infoData = disquuun.Info().DEPRICATED_Sync(); var infoResult = DisquuunDeserializer.Info(infoData); Assert("_1_6_Info_Sync", 0, infoResult.jobs.registered_jobs, "not match."); }
public long _0_0_InitWith2Connection(Disquuun disquuun) { var w = new Stopwatch(); w.Start(); WaitUntil("_0_0_InitWith2Connection", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); w.Stop(); return(w.ElapsedMilliseconds); }
public void _1_7_Hello_Sync(Disquuun disquuun) { WaitUntil("_1_7_Hello_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var helloData = disquuun.Hello().DEPRICATED_Sync(); var helloResult = DisquuunDeserializer.Hello(helloData); Assert("_1_7_Hello_Sync", "1", helloResult.version, "not match."); }
public long _3_0_Nested2AsyncSocket(Disquuun disquuun) { WaitUntil("_3_0_Nested2AsyncSocket", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var w = new Stopwatch(); w.Start(); var jobId1 = string.Empty; var queueId1 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId1, data_10).Async( (command, data) => { jobId1 = DisquuunDeserializer.AddJob(data); } ); var jobId2 = string.Empty; var queueId2 = Guid.NewGuid().ToString(); disquuun.AddJob(queueId2, data_10).Async( (command, data) => { jobId2 = DisquuunDeserializer.AddJob(data); } ); WaitUntil("_3_0_Nested2AsyncSocket", () => (!string.IsNullOrEmpty(queueId1) && !string.IsNullOrEmpty(queueId2)), 5); w.Stop(); var done = false; disquuun.GetJob(new string[] { queueId1, queueId2 }, "count", 2).Async( (command, data) => { var gets = DisquuunDeserializer.GetJob(data); Assert("_3_0_Nested2AsyncSocket", 2, gets.Length, "not match."); disquuun.FastAck(gets.Select(job => job.jobId).ToArray()).Async( (c, d) => { done = true; } ); } ); WaitUntil("_3_0_Nested2AsyncSocket", () => done, 5); return(w.ElapsedMilliseconds); }
public void _1_1_3_GetJobWithNoHang_Sync(Disquuun disquuun) { WaitUntil("_1_1_3_GetJobWithNoHang_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); var queueId = Guid.NewGuid().ToString(); var result = disquuun.GetJob(new string[] { queueId }, "NOHANG").DEPRICATED_Sync(); var jobDatas = DisquuunDeserializer.GetJob(result); Assert("_1_1_3_GetJobWithNoHang_Sync", 0, jobDatas.Length, "not match."); }
public void _1_16_Jscan_Sync(Disquuun disquuun) { DisquuunLogger.Log("_1_16_Jscan_Sync not yet applied"); // [<cursor>] [COUNT <count>] [BUSYLOOP] [QUEUE <queue>] [STATE <state1> STATE <state2> ... STATE <stateN>] [REPLY all|id] WaitUntil("_1_16_Jscan_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); // var infoData = disquuun.Info().DEPRICATED_Sync(); // var infoResult = DisquuunDeserializer.Info(infoData); // Assert("", 0, infoResult.jobs.registered_jobs, "not match."); }
public void _1_17_Pause_Sync(Disquuun disquuun) { DisquuunLogger.Log("_1_17_Pause_Sync not yet applied"); // <queue-name> option1 [option2 ... optionN] WaitUntil("_1_17_Pause_Sync", () => (disquuun.State() == Disquuun.ConnectionState.OPENED), 5); // var pauseData = disquuun.Pause().DEPRICATED_Sync(); // var pauseResult = DisquuunDeserializer.Info(pauseData); // Assert("", 0, pauseResult.jobs.registered_jobs, "not match."); }