Permalink
Browse files

some test tweaking

  • Loading branch information...
1 parent 4439919 commit c37150fe47720841c0e63af4e238c4e7e7b81ed9 @sdether committed Dec 4, 2011
@@ -82,7 +82,7 @@ public class BeanstalkClientTests {
[Test]
public void Can_change_current_tube() {
- using (var client = CreateClient()) {
+ using(var client = CreateClient()) {
Assert.AreEqual("default", client.CurrentTube);
client.CurrentTube = "foo";
Assert.AreEqual("foo", client.CurrentTube);
@@ -92,10 +92,10 @@ public class BeanstalkClientTests {
[Test]
public void Can_Watch_and_Ignore_tubes() {
using(var client = CreateClient()) {
- Assert.AreEqual(1,client.WatchedTubes.Count);
+ Assert.AreEqual(1, client.WatchedTubes.Count);
client.WatchedTubes.Add("foo");
Assert.AreEqual(2, client.WatchedTubes.Count);
- Assert.AreEqual(new[]{"default","foo"},client.WatchedTubes.OrderBy(x => x).ToArray());
+ Assert.AreEqual(new[] { "default", "foo" }, client.WatchedTubes.OrderBy(x => x).ToArray());
client.WatchedTubes.Refresh();
Assert.AreEqual(2, client.WatchedTubes.Count);
Assert.AreEqual(new[] { "default", "foo" }, client.WatchedTubes.OrderBy(x => x).ToArray());
@@ -111,7 +111,23 @@ public class BeanstalkClientTests {
var stats = client.GetServerStats();
Assert.IsNotNull(stats["version"]);
Assert.AreEqual(stats.Version, stats["version"]);
- Assert.Greater(stats.Uptime,TimeSpan.Zero);
+ Assert.Greater(stats.Uptime, TimeSpan.Zero);
+ }
+ }
+ [Test]
+ public void Can_get_tube_stats() {
+ using(var client = CreateClient()) {
+ foreach(var tube in client.GetTubes()) {
+ var tubeStats = client.GetTubeStats(tube);
+ Console.WriteLine("--Name: {0} --------------------", tubeStats.Name);
+ Console.WriteLine(" TotalJobs: {0}", tubeStats.TotalJobs);
+ Console.WriteLine(" CurrentBuriedJobs: {0}", tubeStats.CurrentBuriedJobs);
+ Console.WriteLine(" CurrentDelayedJobs: {0}", tubeStats.CurrentDelayedJobs);
+ Console.WriteLine(" CurrentReadyJobs: {0}", tubeStats.CurrentReadyJobs);
+ Console.WriteLine(" CurrentReservedJobs: {0}", tubeStats.CurrentReservedJobs);
+ Console.WriteLine(" CurrentUrgentJobs: {0}", tubeStats.CurrentUrgentJobs);
+ Console.WriteLine(" CurrentWaiting: {0}", tubeStats.CurrentWaiting);
+ }
}
}
@@ -124,7 +140,33 @@ public class BeanstalkClientTests {
Assert.AreEqual("bob", client.WatchedTubes.First());
client.WatchedTubes.Remove("bob");
Assert.AreEqual(1, client.WatchedTubes.Count);
- Assert.AreEqual("bob",client.WatchedTubes.First());
+ Assert.AreEqual("bob", client.WatchedTubes.First());
+ }
+ }
+
+ [Test, Ignore]
+ public void Wipe_all_queues() {
+ using(var client = CreateClient()) {
+ long expectedJobs = 0;
+ foreach(var tube in client.GetTubes()) {
+ client.WatchedTubes.Add(tube);
+ var tubeStats = client.GetTubeStats(tube);
+ expectedJobs += tubeStats.CurrentReadyJobs;
+ Console.WriteLine("{0}: {1}", tube, tubeStats.CurrentReadyJobs);
+ }
+ var counter = 0;
+ while(true) {
+ Job job;
+ if(client.TryReserve(TimeSpan.Zero, out job) == ReservationStatus.TimedOut) {
+ break;
+ }
+ client.Delete(job.Id);
+ counter++;
+ if(counter % 1000 == 0) {
+ Console.WriteLine("removed {0} pending messages", counter);
+ }
+ }
+ Console.WriteLine("removed a total of {0} pending messages");
}
}
@@ -133,7 +133,8 @@ public class PerformanceTests {
[Test]
public void Producer_consumer_load_test_runs_forever() {
var pool = ConnectionPool.GetPool(TestConfig.Host, TestConfig.Port);
- var tube = Guid.NewGuid().ToString();
+ var tube = "forever-" + Guid.NewGuid().ToString();
+ Console.WriteLine("using tube: {0}", tube);
var set = 0;
while(true) {
set++;
@@ -176,6 +177,21 @@ public class PerformanceTests {
n / producerTimer.Elapsed.TotalSeconds,
n / consumerTimer.Elapsed.TotalSeconds
);
+ using(var client = new BeanstalkClient(pool)) {
+ foreach(var t in client.GetTubes()) {
+ var tubeStats = client.GetTubeStats(t);
+ Console.WriteLine("{0}:total:{1}/buried:{2}/delayed:{3}/ready:{4}/reserved:{5}/urgent:{6}/waiting:{7}",
+ tubeStats.Name,
+ tubeStats.TotalJobs,
+ tubeStats.CurrentBuriedJobs,
+ tubeStats.CurrentDelayedJobs,
+ tubeStats.CurrentReadyJobs,
+ tubeStats.CurrentReservedJobs,
+ tubeStats.CurrentUrgentJobs,
+ tubeStats.CurrentWaiting
+ );
+ }
+ }
}
}

0 comments on commit c37150f

Please sign in to comment.