Merge branch '10460-cwl-directory-literal' closes #10460
authorPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 7 Nov 2016 22:03:00 +0000 (17:03 -0500)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Mon, 7 Nov 2016 22:03:00 +0000 (17:03 -0500)
build/run-build-packages.sh
build/run-tests.sh
services/api/app/models/node.rb
services/api/test/fixtures/nodes.yml
services/api/test/unit/node_test.rb
tools/keep-exercise/keep-exercise.go

index f62bff01f714f4163abc2d3a4453f7e7e80998af..320f9d445c3a052a62bf5b8560b2080c98b06904 100755 (executable)
@@ -431,6 +431,8 @@ package_go_binary tools/keep-block-check keep-block-check \
     "Verify that all data from one set of Keep servers to another was copied"
 package_go_binary tools/keep-rsync keep-rsync \
     "Copy all data from one set of Keep servers to another"
+package_go_binary tools/keep-exercise keep-exercise \
+    "Performance testing tool for Arvados Keep"
 
 # The Python SDK
 # Please resist the temptation to add --no-python-fix-name to the fpm call here
index 2797ec31093fc5183289123aa916efcaf051533f..fa608738c7e63cd3aa24ad8457fafc7bed829e84 100755 (executable)
@@ -93,6 +93,7 @@ sdk/go/streamer
 sdk/go/crunchrunner
 sdk/cwl
 tools/crunchstat-summary
+tools/keep-exercise
 tools/keep-rsync
 tools/keep-block-check
 
@@ -764,8 +765,9 @@ gostuff=(
     services/crunch-dispatch-local
     services/crunch-dispatch-slurm
     services/crunch-run
-    tools/keep-rsync
     tools/keep-block-check
+    tools/keep-exercise
+    tools/keep-rsync
     )
 for g in "${gostuff[@]}"
 do
index abb46fdc661128f5321a55b186d54afd142ed5f3..e470e4c2bd9c47a45b395a4c90f4814edf89a417 100644 (file)
@@ -13,6 +13,8 @@ class Node < ArvadosModel
   belongs_to(:job, foreign_key: :job_uuid, primary_key: :uuid)
   attr_accessor :job_readable
 
+  UNUSED_NODE_IP = '127.40.4.0'
+
   api_accessible :user, :extend => :common do |t|
     t.add :hostname
     t.add :domain
@@ -133,20 +135,22 @@ class Node < ArvadosModel
   end
 
   def dns_server_update
-    if self.hostname_changed? or self.ip_address_changed?
-      if not self.ip_address.nil?
-        stale_conflicting_nodes = Node.where('id != ? and ip_address = ? and last_ping_at < ?',self.id,self.ip_address,10.minutes.ago)
-        if not stale_conflicting_nodes.empty?
-          # One or more stale compute node records have the same IP address as the new node.
-          # Clear the ip_address field on the stale nodes.
-          stale_conflicting_nodes.each do |stale_node|
-            stale_node.ip_address = nil
-            stale_node.save!
-          end
+    if hostname_changed? && hostname_was
+      self.class.dns_server_update(hostname_was, UNUSED_NODE_IP)
+    end
+    if hostname_changed? or ip_address_changed?
+      if ip_address
+        Node.where('id != ? and ip_address = ? and last_ping_at < ?',
+                   id, ip_address, 10.minutes.ago).each do |stale_node|
+          # One or more stale compute node records have the same IP
+          # address as the new node.  Clear the ip_address field on
+          # the stale nodes.
+          stale_node.ip_address = nil
+          stale_node.save!
         end
       end
-      if self.hostname and self.ip_address
-        self.class.dns_server_update(self.hostname, self.ip_address)
+      if hostname
+        self.class.dns_server_update(hostname, ip_address || UNUSED_NODE_IP)
       end
     end
   end
@@ -225,7 +229,7 @@ class Node < ArvadosModel
       if !File.exists? hostfile
         n = Node.where(:slot_number => slot_number).first
         if n.nil? or n.ip_address.nil?
-          dns_server_update(hostname, '127.40.4.0')
+          dns_server_update(hostname, UNUSED_NODE_IP)
         else
           dns_server_update(hostname, n.ip_address)
         end
index 489bb1d6605f86d622c824260d96ef89f63bd026..c5516cc38b34dc9329fc759b1c61b2877681f1af 100644 (file)
@@ -47,7 +47,7 @@ was_idle_now_down:
   hostname: compute3
   slot_number: ~
   domain: ""
-  ip_address: 172.17.2.173
+  ip_address: 172.17.2.174
   last_ping_at: <%= 1.hour.ago.to_s(:db) %>
   first_ping_at: <%= 23.hour.ago.to_s(:db) %>
   job_uuid: ~
@@ -62,7 +62,7 @@ new_with_no_hostname:
   owner_uuid: zzzzz-tpzed-000000000000000
   hostname: ~
   slot_number: ~
-  ip_address: 172.17.2.173
+  ip_address: 172.17.2.175
   last_ping_at: ~
   first_ping_at: ~
   job_uuid: ~
@@ -74,7 +74,7 @@ new_with_custom_hostname:
   owner_uuid: zzzzz-tpzed-000000000000000
   hostname: custom1
   slot_number: 23
-  ip_address: 172.17.2.173
+  ip_address: 172.17.2.176
   last_ping_at: ~
   first_ping_at: ~
   job_uuid: ~
index e5b88354fb128e1308c1a00a7c9e297928f191dd..6eb1df56d129f0279c2e86323b865d13fd09817c 100644 (file)
@@ -125,4 +125,31 @@ class NodeTest < ActiveSupport::TestCase
     refute_nil node2.slot_number
     assert_equal "custom1", node2.hostname
   end
+
+  test "update dns when nodemanager clears hostname and ip_address" do
+    act_as_system_user do
+      node = ping_node(:new_with_custom_hostname, {})
+      Node.expects(:dns_server_update).with(node.hostname, Node::UNUSED_NODE_IP)
+      node.update_attributes(hostname: nil, ip_address: nil)
+    end
+  end
+
+  test "update dns when hostname changes" do
+    act_as_system_user do
+      node = ping_node(:new_with_custom_hostname, {})
+
+      Node.expects(:dns_server_update).with(node.hostname, Node::UNUSED_NODE_IP)
+      Node.expects(:dns_server_update).with('foo0', node.ip_address)
+      node.update_attributes!(hostname: 'foo0')
+
+      Node.expects(:dns_server_update).with('foo0', Node::UNUSED_NODE_IP)
+      node.update_attributes!(hostname: nil, ip_address: nil)
+
+      Node.expects(:dns_server_update).with('foo0', '10.11.12.13')
+      node.update_attributes!(hostname: 'foo0', ip_address: '10.11.12.13')
+
+      Node.expects(:dns_server_update).with('foo0', '10.11.12.14')
+      node.update_attributes!(hostname: 'foo0', ip_address: '10.11.12.14')
+    end
+  end
 end
index 9dc8f9425a8e4707bc4538842911511928428095..6d791bf9876a5b84a2b1b642025b730771f76da2 100644 (file)
@@ -47,7 +47,7 @@ func main() {
        if err != nil {
                log.Fatal(err)
        }
-       kc, err := keepclient.MakeKeepClient(&arv)
+       kc, err := keepclient.MakeKeepClient(arv)
        if err != nil {
                log.Fatal(err)
        }
@@ -56,11 +56,11 @@ func main() {
 
        overrideServices(kc)
 
-       nextBuf := make(chan []byte, *WriteThreads)
        nextLocator := make(chan string, *ReadThreads+*WriteThreads)
 
        go countBeans(nextLocator)
        for i := 0; i < *WriteThreads; i++ {
+               nextBuf := make(chan []byte, 1)
                go makeBufs(nextBuf, i)
                go doWrites(kc, nextBuf, nextLocator)
        }
@@ -106,23 +106,28 @@ func countBeans(nextLocator chan string) {
        }
 }
 
-func makeBufs(nextBuf chan []byte, threadID int) {
+func makeBufs(nextBuf chan<- []byte, threadID int) {
        buf := make([]byte, *BlockSize)
        if *VaryThread {
                binary.PutVarint(buf, int64(threadID))
        }
+       randSize := 524288
+       if randSize > *BlockSize {
+               randSize = *BlockSize
+       }
        for {
                if *VaryRequest {
-                       buf = make([]byte, *BlockSize)
-                       if _, err := io.ReadFull(rand.Reader, buf); err != nil {
+                       rnd := make([]byte, randSize)
+                       if _, err := io.ReadFull(rand.Reader, rnd); err != nil {
                                log.Fatal(err)
                        }
+                       buf = append(rnd, buf[randSize:]...)
                }
                nextBuf <- buf
        }
 }
 
-func doWrites(kc *keepclient.KeepClient, nextBuf chan []byte, nextLocator chan string) {
+func doWrites(kc *keepclient.KeepClient, nextBuf <-chan []byte, nextLocator chan<- string) {
        for buf := range nextBuf {
                locator, _, err := kc.PutB(buf)
                if err != nil {
@@ -139,7 +144,7 @@ func doWrites(kc *keepclient.KeepClient, nextBuf chan []byte, nextLocator chan s
        }
 }
 
-func doReads(kc *keepclient.KeepClient, nextLocator chan string) {
+func doReads(kc *keepclient.KeepClient, nextLocator <-chan string) {
        for locator := range nextLocator {
                rdr, size, url, err := kc.Get(locator)
                if err != nil {