[ARVADOS] created: 635a2b59e4a9a3ec147b7064a932e4db17bc3955

git at public.curoverse.com git at public.curoverse.com
Wed Apr 9 00:00:58 EDT 2014


        at  635a2b59e4a9a3ec147b7064a932e4db17bc3955 (commit)


commit 635a2b59e4a9a3ec147b7064a932e4db17bc3955
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Apr 8 23:58:48 2014 -0400

    Get logs and archives directly from the given git repo. Skip git-clone
    and attendant race conditions.

diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job
index e185d66..0fde43a 100755
--- a/sdk/cli/bin/crunch-job
+++ b/sdk/cli/bin/crunch-job
@@ -400,24 +400,21 @@ else
   my $commit;
   my $git_archive;
   my $treeish = $Job->{'script_version'};
-  my $repo = $git_dir || $ENV{'CRUNCH_DEFAULT_GIT_DIR'};
+  my $repo = $git_dir || $ENV{'CRUNCH_DEFAULT_GIT_DIR'} || $Job->{'repository'};
   # Todo: let script_version specify repository instead of expecting
   # parent process to figure it out.
   $ENV{"CRUNCH_SRC_URL"} = $repo;
 
-  # Create/update our clone of the remote git repo
-
-  if (!-d $ENV{"CRUNCH_SRC"}) {
-    system(qw(git clone), $repo, $ENV{"CRUNCH_SRC"}) == 0
-	or croak ("git clone $repo failed: exit ".($?>>8));
-    system("cd $ENV{CRUNCH_SRC} && git config clean.requireForce false");
+  if (-d "$repo/.git") {
+    # We were given a working directory, but we are only interested in
+    # the index.
+    $repo = "$repo/.git";
   }
-  `cd $ENV{CRUNCH_SRC} && git remote set-url origin \"\$CRUNCH_SRC_URL\" && git fetch -q --tags origin`;
 
   # If this looks like a subversion r#, look for it in git-svn commit messages
 
   if ($treeish =~ m{^\d{1,4}$}) {
-    my $gitlog = `cd $ENV{CRUNCH_SRC} && git log --pretty="format:%H" --grep="git-svn-id:.*\@$treeish " origin/master`;
+    my $gitlog = `git --git-dir="$repo" log --pretty="format:%H" --grep="git-svn-id:.*\@$treeish " master`;
     chomp $gitlog;
     if ($gitlog =~ /^[a-f0-9]{40}$/) {
       $commit = $gitlog;
@@ -428,15 +425,7 @@ else
   # If that didn't work, try asking git to look it up as a tree-ish.
 
   if (!defined $commit) {
-
-    my $cooked_treeish = $treeish;
-    if ($treeish !~ m{^[0-9a-f]{5,}$}) {
-      # Looks like a git branch name -- make sure git knows it's
-      # relative to the remote repo
-      $cooked_treeish = "origin/$treeish";
-    }
-
-    my $found = `cd $ENV{CRUNCH_SRC} && git rev-list -1 $cooked_treeish`;
+    my $found = `git --git-dir="$repo" rev-list -1 "$treeish"`;
     chomp $found;
     if ($found =~ /^[0-9a-f]{40}$/s) {
       $commit = $found;
@@ -461,7 +450,7 @@ else
     $ENV{"CRUNCH_SRC_COMMIT"} = $commit;
     @execargs = ("sh", "-c",
 		 "mkdir -p $ENV{CRUNCH_INSTALL} && cd $ENV{CRUNCH_TMP} && perl -");
-    $git_archive = `cd $ENV{CRUNCH_SRC} && git archive $commit`;
+    $git_archive = `git --git-dir="$repo" archive "$commit"`;
   }
   else {
     croak ("could not figure out commit id for $treeish");

commit e93b022d02fa68cc3cf34afb8d5448cf984789ac
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Apr 8 23:34:25 2014 -0400

    Add "create collection" integration test

diff --git a/services/api/test/integration/collections_api_test.rb b/services/api/test/integration/collections_api_test.rb
index 5a3250e..5fa77c3 100644
--- a/services/api/test/integration/collections_api_test.rb
+++ b/services/api/test/integration/collections_api_test.rb
@@ -4,35 +4,43 @@ class CollectionsApiTest < ActionDispatch::IntegrationTest
   fixtures :all
 
   test "should get index" do
-    get "/arvados/v1/collections", {:format => :json}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/collections", {:format => :json}, auth(:active)
     assert_response :success
     assert_equal "arvados#collectionList", jresponse['kind']
   end
 
   test "get index with filters= (empty string)" do
-    get "/arvados/v1/collections", {:format => :json, :filters => ''}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/collections", {:format => :json, :filters => ''}, auth(:active)
     assert_response :success
     assert_equal "arvados#collectionList", jresponse['kind']
   end
 
   test "get index with where= (empty string)" do
-    get "/arvados/v1/collections", {:format => :json, :where => ''}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/collections", {:format => :json, :where => ''}, auth(:active)
     assert_response :success
     assert_equal "arvados#collectionList", jresponse['kind']
   end
 
   test "controller 404 response is json" do
-    get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/thingsthatdonotexist", {:format => :xml}, auth(:active)
     assert_response 404
     assert_equal 1, jresponse['errors'].length
     assert_equal true, jresponse['errors'][0].is_a?(String)
   end
 
   test "object 404 response is json" do
-    get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f", {}, {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(:active).api_token}"}
+    get "/arvados/v1/groups/zzzzz-j7d0g-o5ba971173cup4f", {}, auth(:active)
     assert_response 404
     assert_equal 1, jresponse['errors'].length
     assert_equal true, jresponse['errors'][0].is_a?(String)
   end
 
+  test "store collection as json" do
+    post "/arvados/v1/collections", {
+      format: :json,
+      collection: "{\"manifest_text\":\". bad42fa702ae3ea7d888fef11b46f450+44 0:44:md5sum.txt\\n\",\"uuid\":\"ad02e37b6a7f45bbe2ead3c29a109b8a+54\"}"
+    }, auth(:active)
+    assert_response 200
+    assert_equal 'ad02e37b6a7f45bbe2ead3c29a109b8a+54', jresponse['uuid']
+  end
 end
diff --git a/services/api/test/integration/permissions_test.rb b/services/api/test/integration/permissions_test.rb
index 40a77e7..bd9685b 100644
--- a/services/api/test/integration/permissions_test.rb
+++ b/services/api/test/integration/permissions_test.rb
@@ -3,10 +3,6 @@ require 'test_helper'
 class PermissionsTest < ActionDispatch::IntegrationTest
   fixtures :users, :groups, :api_client_authorizations, :collections
 
-  def auth auth_fixture
-    {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(auth_fixture).api_token}"}
-  end
-
   test "adding and removing direct can_read links" do
     # try to read collection as spectator
     get "/arvados/v1/collections/#{collections(:foo_file).uuid}", {:format => :json}, auth(:spectator)
diff --git a/services/api/test/test_helper.rb b/services/api/test/test_helper.rb
index 8e33995..a81bfdf 100644
--- a/services/api/test/test_helper.rb
+++ b/services/api/test/test_helper.rb
@@ -24,6 +24,9 @@ class ActionDispatch::IntegrationTest
   def jresponse
     @jresponse ||= ActiveSupport::JSON.decode @response.body
   end
+  def auth auth_fixture
+    {'HTTP_AUTHORIZATION' => "OAuth2 #{api_client_authorizations(auth_fixture).api_token}"}
+  end
 end
 
 # Ensure permissions are computed from the test fixtures.

commit 71b0d0fb51e3c54a7959f51fd4dbf523fbaf57db
Author: Tom Clegg <tom at curoverse.com>
Date:   Tue Apr 8 23:45:12 2014 -0400

    Trim newline from output hash emerging from `arv keep put`.

diff --git a/sdk/cli/bin/crunch-job b/sdk/cli/bin/crunch-job
index 2f7376f..e185d66 100755
--- a/sdk/cli/bin/crunch-job
+++ b/sdk/cli/bin/crunch-job
@@ -1120,6 +1120,7 @@ sub collate_output
     my $s = IO::Select->new($child_out);
     if ($s->can_read(120)) {
       sysread($child_out, $joboutput, 64 * 1024 * 1024);
+      chomp($joboutput);
     } else {
       Log (undef, "timed out reading from 'arv keep put'");
     }

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list