fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2011-04-28 03:32 am

[dw-free] atom-post.t should be skipped if memcache servers don't respond

[commit: http://hg.dwscoalition.org/dw-free/rev/ad0b62e5fb31]

http://bugs.dwscoalition.org/show_bug.cgi?id=3561

Add a check for proper running of memcache for testing purposes (don't use
this function on prod servers as it is bogus info)

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/Test.pm
  • t/atom-post.t
--------------------------------------------------------------------------------
diff -r 8a65ea36289a -r ad0b62e5fb31 cgi-bin/LJ/Test.pm
--- a/cgi-bin/LJ/Test.pm	Thu Apr 28 11:28:58 2011 +0800
+++ b/cgi-bin/LJ/Test.pm	Thu Apr 28 11:31:20 2011 +0800
@@ -168,6 +168,15 @@ sub memcache_stress (&) {
 
     # restore our memcache client object from before.
     LJ::MemCache::set_memcache($pre_mem);
+}
+
+# this is a quick check for whether memcache is functioning correctly
+# using a bogus wsse_auth key - add fails when not working as configured
+sub check_memcache {
+    return 1 unless @LJ::MEMCACHE_SERVERS;  # OK if not set
+
+    my $secs = time;
+    return LJ::MemCache::add( "wsse_auth:xxx:$secs", 1, 1 );
 }
 
 sub routing_request {
diff -r 8a65ea36289a -r ad0b62e5fb31 t/atom-post.t
--- a/t/atom-post.t	Thu Apr 28 11:28:58 2011 +0800
+++ b/t/atom-post.t	Thu Apr 28 11:31:20 2011 +0800
@@ -6,6 +6,9 @@ use lib "$ENV{LJHOME}/cgi-bin";
 use lib "$ENV{LJHOME}/cgi-bin";
 require 'ljlib.pl';
 use LJ::Test;
+
+plan skip_all => "Memcache configured but not active."
+    unless LJ::Test::check_memcache;
 
 use XML::Atom::Client;
 use XML::Atom::Entry;
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org