[Swift-commit] r3300 - SwiftApps/adem-osg

noreply at svn.ci.uchicago.edu noreply at svn.ci.uchicago.edu
Mon May 3 14:56:05 CDT 2010


Author: aespinosa
Date: 2010-05-03 14:56:05 -0500 (Mon, 03 May 2010)
New Revision: 3300

Modified:
   SwiftApps/adem-osg/adem-test.rb
   SwiftApps/adem-osg/adem.rb
Log:
Full sites support

Modified: SwiftApps/adem-osg/adem-test.rb
===================================================================
--- SwiftApps/adem-osg/adem-test.rb	2010-05-03 19:56:02 UTC (rev 3299)
+++ SwiftApps/adem-osg/adem-test.rb	2010-05-03 19:56:05 UTC (rev 3300)
@@ -4,16 +4,27 @@
 require 'adem'
 require 'yaml'
 
-class AdemTest < Test::Unit::TestCase
-
-  def test_sites_from_file
-    conf = @conf
-    site_list = YAML.load @site_list
-    assert_equal(site_list, sites(nil, conf, "sites"))
+module Adem
+  module TestSetup
+    def setup
+      @conf = {
+        :pacman_cache         => "http://www.ci.uchicago.edu/~aespinosa/pacman",
+        :ress_server          => "osg-ress-1.fnal.gov",
+        :virtual_organization => "engage"
+      }
+      @site_list = File.open("sites").read
+      #@site_list.gsub! /^\s+/, ''
+      @ress = File.open("dummy_ress").read
+    end
   end
+end
 
+class OnlineTest < Test::Unit::TestCase
+  include Adem::TestSetup
+
   def test_sites_exception
     conf = @conf
+    conf[:ress_server] = nil
     site_list = YAML.load @site_list
     begin
       sites(nil, conf, "non_existent_file")
@@ -22,28 +33,59 @@
     end
   end
 
+  def test_sites_live
+    conf = @conf
+    assert_equal(YAML.load(@site_list), sites(nil, conf, "non_existent_file"))
+  end
+
+  def test_query_ress
+    conf = @conf
+    ress = query_ress(conf).split "\n\n"
+    assumption = true
+    class_ads = [
+      "GlueSiteUniqueID", "GlueCEInfoHostName", "GlueCEInfoJobManager",
+      "GlueCEInfoGatekeeperPort", "GlueSEAccessProtocolEndpoint",
+      "GlueSEAccessProtocolType", "GlueCEInfoApplicationDir", "GlueCEInfoDataDir"
+    ]
+    missing = []
+    ress.each do |entry|
+      class_ads.each do |ad|
+        assumption = assumption && entry.include?(ad)
+        missing << ad if not entry.include?(ad)
+      end
+    end
+    # False: there exist an entry without the expected classad.
+    # Must report to osg support then
+    assert assumption, "Missing attributes: \n\t#{missing.uniq.join(", ")}"
+  end
+end
+
+class OfflineTest < Test::Unit::TestCase
+  include Adem::TestSetup
+
+  def test_sites_from_file
+    conf = @conf
+    site_list = YAML.load @site_list
+    assert_equal(site_list, sites(nil, conf, "sites"))
+  end
+
+
   def test_parse_classads
     site_list = YAML.load @site_list
-    assert_equal site_list, parse_classads(@ress)
+    assert_equal site_list, parse_classads(@ress.split("\n\n"))
   end
 
+
   def test_app
     conf = @conf
     assert_equal("app", app(nil, conf))
   end
 
   def test_config
-    assert_equal(@conf, config(nil))
+    assert_equal(@conf, config(nil, "config"))
   end
+end
 
-  def setup
-    @conf = {
-      "pacman_cache"         => "http://www.ci.uchicago.edu/~aespinosa/pacman",
-      "ress_server"          => "osg-ress-1.fnal.gov",
-      "virtual_organization" => "engage"
-    }
-    @site_list = File.open("sites").read
-    #@site_list.gsub! /^\s+/, ''
-    @ress = File.open("dummy_ress").read.split "\n\n"
-  end
+class RunTest < Test::Unit::TestCase
+  include Adem::TestSetup
 end

Modified: SwiftApps/adem-osg/adem.rb
===================================================================
--- SwiftApps/adem-osg/adem.rb	2010-05-03 19:56:02 UTC (rev 3299)
+++ SwiftApps/adem-osg/adem.rb	2010-05-03 19:56:05 UTC (rev 3300)
@@ -10,11 +10,18 @@
 SITES_FILE = "#{ENV['HOME']}/.adem/sites"
 
 def load_config(yaml_config)
-  YAML.load yaml_config
+  conf = YAML.load yaml_config
+  conf.each do |key, val|
+    conf.delete(key)
+    conf[key.to_sym] = val
+  end
+  conf
 end
 
 def query_ress(conf)
-  File.open("dummy_ress").read.split '\n\n'
+  `condor_status -pool #{conf[:ress_server]} -const \
+    'stringListIMember(\"VO:#{conf[:virtual_organization]}\", \  
+    GlueCEAccessControlBaseRule)' -long`
 end
 
 def parse_classads(ress)
@@ -78,7 +85,7 @@
   begin
     YAML.load File.open sites_file
   rescue Errno::ENOENT
-    #parse_classads query_ress conf
+    parse_classads query_ress(conf).split("\n\n")
   end
 end
 
@@ -86,20 +93,20 @@
   "app"
 end
 
-def config(args)
-  load_config File.open("config")
+def config(args, config_file)
+  load_config File.open(config_file)
 end
 
 def run_command(args)
   command = args.shift
   if command != "config"
-    conf = load_configuration File.open(CONFIGURATION_FILE)
-    sites args, conf, File.open(SITES_FILE).read
+    conf = load_config File.open(CONFIGURATION_FILE)
+    puts sites(args, conf, SITES_FILE).to_yaml if command == "sites"
   else
-    config args
+    config args, CONFIGURATION_FILE
   end
 end
 
 if $0 == __FILE__
-  run_command ARGV, conf
+  run_command ARGV
 end




More information about the Swift-commit mailing list