Index: trunk/Nebulous-Server/lib/Test/Nebulous.pm
===================================================================
--- trunk/Nebulous-Server/lib/Test/Nebulous.pm	(revision 19493)
+++ trunk/Nebulous-Server/lib/Test/Nebulous.pm	(revision 24372)
@@ -11,4 +11,5 @@
 use base qw( Exporter );
 
+use Cache::Memcached;
 use DBI;
 use File::Path qw( mkpath rmtree );
@@ -16,9 +17,10 @@
 use Nebulous::Server::SQL;
 
-our @EXPORT = qw( $NEB_DB $NEB_USER $NEB_PASS );
+our @EXPORT = qw( $NEB_DB $NEB_USER $NEB_PASS $NEB_MEMCACHED_SERVERS);
 
 our $NEB_DB     = $ENV{'NEB_DB'}   || "DBI:mysql:database=test:host=localhost";
 our $NEB_USER   = $ENV{'NEB_USER'} || "test";
 our $NEB_PASS   = $ENV{'NEB_PASS'} || '';
+our $NEB_MEMCACHED_SERVERS = ['127.0.0.1:11211'];
 
 my $dbh = DBI->connect( $NEB_DB, $NEB_USER, $NEB_PASS );
@@ -83,4 +85,18 @@
 
 sub cleanup {
+    # memcached needs to be emptied between test runs
+        Cache::Memcached->new(servers => $NEB_MEMCACHED_SERVERS)->flush_all;
+    # if flush_all() turns out to be useless as feared
+#   my $memd = Cache::Memcached->new(servers => $NEB_MEMCACHED_SERVERS);
+#   my $query = $dbh->prepare("SELECT ext_id FROM storage_object");
+#   if ($query->execute) {
+#        while (my $row = $query->fetchrow_hashref) {
+#            my $ext_id = $row->{ext_id};
+#            warn "found key $ext_id\n" if $memd->get($ext_id);
+#            warn "deleted $ext_id\n" if $memd->delete($ext_id);
+#        }
+#   }
+#   $query->finish;
+
     foreach my $statement (@{ $sql->get_db_clear }) {
         $dbh->do( $statement );
