9514: add container log tests. 9514-delete-old-container-logs
authorradhika <radhika@curoverse.com>
Wed, 21 Sep 2016 18:27:21 +0000 (14:27 -0400)
committerradhika <radhika@curoverse.com>
Wed, 21 Sep 2016 18:27:21 +0000 (14:27 -0400)
apps/workbench/test/integration/container_requests_test.rb
services/api/test/fixtures/containers.yml

index df6584ebb6490cedac2fe439a1a77110a9feeb84..d87580733a8a2f99b49ffed3af4ff8e5c8cf0668 100644 (file)
@@ -96,4 +96,36 @@ class ContainerRequestsTest < ActionDispatch::IntegrationTest
     wait_for_ajax
     assert_text 'This container is queued'
   end
+
+  def mock_container_log_data
+    content = "2014-01-01_12:00:01 container log message 1\n" +
+              "2014-01-01_12:00:02 container log message 2\n" +
+              "2014-01-01_12:00:03 container log message 3\n"
+    StringIO.new content, 'r'
+  end
+
+  [
+    false,
+    true,
+  ].each do |partial|
+    test "view container #{partial ? 'partial' : 'full'} log from log collection" do
+      Rails.configuration.log_viewer_max_bytes = 100 if partial
+
+      IO.expects(:popen).returns(mock_container_log_data)
+
+      cr = api_fixture('container_requests')['completed']
+      visit page_with_token("active", "/container_requests/#{cr['uuid']}")
+      find(:xpath, "//a[@href='#Log']").click
+      wait_for_ajax
+
+      if partial
+        assert page.has_text?('Showing only 100 bytes of this log') if partial
+        assert page.has_text? 'container log message 1'
+      else
+        assert page.has_text? 'container log message 1'
+        assert page.has_text? 'container log message 2'
+        assert page.has_text? 'container log message 3'
+      end
+    end
+  end
 end
index 87098dcf53e96e693635bfd8ce355dbb2f012b36..08fafff3aec03a067115af5e0f5c52e31b2c4f72 100644 (file)
@@ -73,7 +73,7 @@ completed:
   finished_at: 2016-01-12 11:12:13.111111111 Z
   container_image: test
   cwd: test
-  log: ea10d51bcf88862dbcc36eb292017dfd+45
+  log: 0b9a7787660e1fce4a93f33e01376ba6+81
   output: zzzzz-4zz18-znfnqtbbv4spc3w
   output_path: test
   command: ["echo", "hello"]