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

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


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

Modified:
   SwiftApps/adem-osg/adem-test.rb
   SwiftApps/adem-osg/adem.rb
Log:
Added site exceptions and tests

Modified: SwiftApps/adem-osg/adem-test.rb
===================================================================
--- SwiftApps/adem-osg/adem-test.rb	2010-05-03 19:56:05 UTC (rev 3300)
+++ SwiftApps/adem-osg/adem-test.rb	2010-05-03 19:56:07 UTC (rev 3301)
@@ -13,7 +13,6 @@
         :virtual_organization => "engage"
       }
       @site_list = File.open("sites").read
-      #@site_list.gsub! /^\s+/, ''
       @ress = File.open("dummy_ress").read
     end
   end
@@ -22,22 +21,15 @@
 class OnlineTest < Test::Unit::TestCase
   include Adem::TestSetup
 
-  def test_sites_exception
+  def test_sites_live
     conf = @conf
-    conf[:ress_server] = nil
-    site_list = YAML.load @site_list
     begin
       sites(nil, conf, "non_existent_file")
-    rescue Errno::ENOENT
-      assert true, "Received exception"
+    rescue SiteError => e
+      assert_equal YAML.load(@site_list), e.output
     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"
@@ -63,19 +55,26 @@
 class OfflineTest < Test::Unit::TestCase
   include Adem::TestSetup
 
+  def test_sites_exception
+    conf = @conf
+    conf[:ress_server] = nil
+    site_list = YAML.load @site_list
+    assert_raise SiteError do
+      sites(nil, conf, "non_existent_file")
+    end
+  end
+
   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.split("\n\n"))
   end
 
-
   def test_app
     conf = @conf
     assert_equal("app", app(nil, conf))

Modified: SwiftApps/adem-osg/adem.rb
===================================================================
--- SwiftApps/adem-osg/adem.rb	2010-05-03 19:56:05 UTC (rev 3300)
+++ SwiftApps/adem-osg/adem.rb	2010-05-03 19:56:07 UTC (rev 3301)
@@ -1,14 +1,26 @@
 #!/usr/bin/env ruby
 
 # = ADEM: Application software DEployment and Management
-# authors:: Zhengxiong Hou (original sh prototype)
-#           Allan Espinosa (rewrite to ruby)
+# Author::       Zhengxiong Hou (original sh prototype)
+# Author:: Allan Espinosa (rewrite to ruby)
+#
 
 require 'yaml'
 
 CONFIGURATION_FILE = "#{ENV['HOME']}/.adem/config"
-SITES_FILE = "#{ENV['HOME']}/.adem/sites"
+SITES_FILE         = "#{ENV['HOME']}/.adem/sites"
+APPS_FILE          = "#{ENV['HOME']}/.adem/apps"
 
+class SiteError < Exception
+  attr_reader :output
+  def initialize(output)
+    @output = output
+  end
+end
+
+class ConfigError < RuntimeError
+end
+
 def load_config(yaml_config)
   conf = YAML.load yaml_config
   conf.each do |key, val|
@@ -65,6 +77,7 @@
     site[site_name]["data_directory"] = tmp['GlueCEInfoDataDir']
     site[site_name]["app_directory"] = tmp['GlueCEInfoApplicationDir']
 
+    # Disabled because some storage endpoints are broken
     #storage_element = tmp['GlueSEAccessProtocolEndpoint'] if tmp['GlueSEAccessProtocolType'] == 'gsiftp'
     #next if storage_element == nil
     #if storage_element.include? ','
@@ -85,7 +98,8 @@
   begin
     YAML.load File.open sites_file
   rescue Errno::ENOENT
-    parse_classads query_ress(conf).split("\n\n")
+    result = parse_classads query_ress(conf).split("\n\n")
+    raise SiteError.new(result)
   end
 end
 




More information about the Swift-commit mailing list