splunk-sdk-ruby 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. data/CHANGELOG.md +160 -0
  2. data/Gemfile +8 -0
  3. data/LICENSE +177 -0
  4. data/README.md +310 -0
  5. data/Rakefile +40 -0
  6. data/examples/1_connect.rb +51 -0
  7. data/examples/2_manage.rb +103 -0
  8. data/examples/3_blocking_searches.rb +82 -0
  9. data/examples/4_asynchronous_searches.rb +79 -0
  10. data/examples/5_stream_data_to_splunk.rb +79 -0
  11. data/lib/splunk-sdk-ruby.rb +47 -0
  12. data/lib/splunk-sdk-ruby/ambiguous_entity_reference.rb +28 -0
  13. data/lib/splunk-sdk-ruby/atomfeed.rb +323 -0
  14. data/lib/splunk-sdk-ruby/collection.rb +417 -0
  15. data/lib/splunk-sdk-ruby/collection/apps.rb +35 -0
  16. data/lib/splunk-sdk-ruby/collection/case_insensitive_collection.rb +58 -0
  17. data/lib/splunk-sdk-ruby/collection/configuration_file.rb +50 -0
  18. data/lib/splunk-sdk-ruby/collection/configurations.rb +80 -0
  19. data/lib/splunk-sdk-ruby/collection/jobs.rb +136 -0
  20. data/lib/splunk-sdk-ruby/collection/messages.rb +51 -0
  21. data/lib/splunk-sdk-ruby/context.rb +522 -0
  22. data/lib/splunk-sdk-ruby/entity.rb +260 -0
  23. data/lib/splunk-sdk-ruby/entity/index.rb +191 -0
  24. data/lib/splunk-sdk-ruby/entity/job.rb +339 -0
  25. data/lib/splunk-sdk-ruby/entity/message.rb +36 -0
  26. data/lib/splunk-sdk-ruby/entity/saved_search.rb +71 -0
  27. data/lib/splunk-sdk-ruby/entity/stanza.rb +45 -0
  28. data/lib/splunk-sdk-ruby/entity_not_ready.rb +26 -0
  29. data/lib/splunk-sdk-ruby/illegal_operation.rb +27 -0
  30. data/lib/splunk-sdk-ruby/namespace.rb +239 -0
  31. data/lib/splunk-sdk-ruby/resultsreader.rb +716 -0
  32. data/lib/splunk-sdk-ruby/service.rb +339 -0
  33. data/lib/splunk-sdk-ruby/splunk_http_error.rb +49 -0
  34. data/lib/splunk-sdk-ruby/synonyms.rb +50 -0
  35. data/lib/splunk-sdk-ruby/version.rb +27 -0
  36. data/lib/splunk-sdk-ruby/xml_shim.rb +117 -0
  37. data/splunk-sdk-ruby.gemspec +27 -0
  38. data/test/atom_test_data.rb +472 -0
  39. data/test/data/atom/atom_feed_with_message.xml +19 -0
  40. data/test/data/atom/atom_with_feed.xml +99 -0
  41. data/test/data/atom/atom_with_several_entries.xml +101 -0
  42. data/test/data/atom/atom_with_simple_entries.xml +30 -0
  43. data/test/data/atom/atom_without_feed.xml +248 -0
  44. data/test/data/export/4.2.5/export_results.xml +88 -0
  45. data/test/data/export/4.3.5/export_results.xml +87 -0
  46. data/test/data/export/5.0.1/export_results.xml +78 -0
  47. data/test/data/export/5.0.1/nonreporting.xml +232 -0
  48. data/test/data/results/4.2.5/results-empty.xml +0 -0
  49. data/test/data/results/4.2.5/results-preview.xml +255 -0
  50. data/test/data/results/4.2.5/results.xml +336 -0
  51. data/test/data/results/4.3.5/results-empty.xml +0 -0
  52. data/test/data/results/4.3.5/results-preview.xml +1057 -0
  53. data/test/data/results/4.3.5/results.xml +626 -0
  54. data/test/data/results/5.0.2/results-empty.xml +1 -0
  55. data/test/data/results/5.0.2/results-empty_preview.xml +1 -0
  56. data/test/data/results/5.0.2/results-preview.xml +448 -0
  57. data/test/data/results/5.0.2/results.xml +501 -0
  58. data/test/export_test_data.json +360 -0
  59. data/test/resultsreader_test_data.json +1119 -0
  60. data/test/services.server.info.xml +43 -0
  61. data/test/services.xml +111 -0
  62. data/test/test_atomfeed.rb +71 -0
  63. data/test/test_collection.rb +278 -0
  64. data/test/test_configuration_file.rb +124 -0
  65. data/test/test_context.rb +119 -0
  66. data/test/test_entity.rb +95 -0
  67. data/test/test_helper.rb +250 -0
  68. data/test/test_http_error.rb +52 -0
  69. data/test/test_index.rb +91 -0
  70. data/test/test_jobs.rb +319 -0
  71. data/test/test_messages.rb +17 -0
  72. data/test/test_namespace.rb +188 -0
  73. data/test/test_restarts.rb +49 -0
  74. data/test/test_resultsreader.rb +106 -0
  75. data/test/test_roles.rb +41 -0
  76. data/test/test_saved_searches.rb +119 -0
  77. data/test/test_service.rb +65 -0
  78. data/test/test_users.rb +33 -0
  79. data/test/test_xml_shim.rb +28 -0
  80. data/test/testfile.txt +1 -0
  81. metadata +200 -0
@@ -0,0 +1,17 @@
1
+ require_relative 'test_helper'
2
+ require 'splunk-sdk-ruby'
3
+
4
+ include Splunk
5
+
6
+ class MessagesTestCase < TestCaseWithSplunkConnection
7
+ def test_message
8
+ messages = @service.messages
9
+ messages.create("sdk_message", :value => "Moose on the roof")
10
+ assert_true(messages.has_key?("sdk_message"))
11
+ message = messages.fetch("sdk_message")
12
+ assert_equal("sdk_message", message.name)
13
+ assert_equal("Moose on the roof", message.value)
14
+ messages.delete("sdk_message")
15
+ assert_false(messages.has_key?("sdk_message"))
16
+ end
17
+ end
@@ -0,0 +1,188 @@
1
+ require_relative 'test_helper'
2
+ require 'splunk-sdk-ruby/namespace'
3
+
4
+ include Splunk
5
+
6
+ class TestNamespaces < Test::Unit::TestCase
7
+ def test_incorrect_constructors
8
+ assert_raises(ArgumentError) { Splunk::namespace(:sharing => "boris") }
9
+ assert_raises(ArgumentError) { Splunk::namespace(:sharing => "app") }
10
+ assert_raises(ArgumentError) { Splunk::namespace(:sharing => "user") }
11
+ assert_raises(ArgumentError) { Splunk::namespace(:sharing => "user",
12
+ :app => "search") }
13
+ assert_raises(ArgumentError) { Splunk::namespace() }
14
+ end
15
+
16
+ def test_equality
17
+ assert_equal(Splunk::namespace(:sharing => "global"),
18
+ Splunk::namespace(:sharing => "global"))
19
+ assert_equal(Splunk::namespace(:sharing => "system"),
20
+ Splunk::namespace(:sharing => "system"))
21
+ assert_equal(Splunk::namespace(:sharing => "default"),
22
+ Splunk::namespace(:sharing => "default"))
23
+ assert_equal(Splunk::namespace(:sharing => "user",
24
+ :app => "search",
25
+ :owner => "boris"),
26
+ Splunk::namespace(:sharing => "user",
27
+ :app => "search",
28
+ :owner => "boris"))
29
+ assert_equal(Splunk::namespace(:sharing => "app",
30
+ :app => "search"),
31
+ Splunk::namespace(:sharing => "app",
32
+ :app => "search"))
33
+ end
34
+
35
+ def test_inequality
36
+ assert_not_equal(Splunk::namespace(:sharing => "global"),
37
+ Splunk::namespace(:sharing => "system"))
38
+ assert_not_equal(Splunk::namespace(:sharing => "app", :app => "search"),
39
+ Splunk::namespace(:sharing => "app", :app => "gettingstarted"))
40
+ assert_not_equal(Splunk::namespace(:sharing => "user",
41
+ :app => "search",
42
+ :owner => "boris"),
43
+ Splunk::namespace(:sharing => "app",
44
+ :app => "search"))
45
+ assert_not_equal(Splunk::namespace(:sharing => "default"),
46
+ Splunk::namespace(:sharing => "system"))
47
+ assert_not_equal(Splunk::namespace(:sharing => "user",
48
+ :app => "search",
49
+ :owner => "boris"),
50
+ Splunk::namespace(:sharing => "user",
51
+ :app => "search",
52
+ :owner => "hilda"))
53
+ end
54
+
55
+ def test_types
56
+ assert_true(Splunk::namespace(:sharing => "global").is_a?(GlobalNamespace))
57
+ assert_true(Splunk::namespace(:sharing => "global").is_a?(Namespace))
58
+
59
+ assert_true(Splunk::namespace(:sharing => "system").is_a?(SystemNamespace))
60
+ assert_true(Splunk::namespace(:sharing => "system").is_a?(Namespace))
61
+
62
+ assert_true(Splunk::namespace(:sharing => "app",
63
+ :app => "search").is_a?(AppNamespace))
64
+ assert_true(Splunk::namespace(:sharing => "app",
65
+ :app => "search").is_a?(Namespace))
66
+
67
+ assert_true(Splunk::namespace(:sharing => "app",
68
+ :app => "").is_a?(AppReferenceNamespace))
69
+ assert_true(Splunk::namespace(:sharing => "app",
70
+ :app => "").is_a?(Namespace))
71
+
72
+ assert_true(Splunk::namespace(:sharing => "user",
73
+ :app => "search",
74
+ :owner => "boris").is_a?(UserNamespace))
75
+ assert_true(Splunk::namespace(:sharing => "user",
76
+ :app => "search",
77
+ :owner => "boris").is_a?(Namespace))
78
+
79
+ assert_true(Splunk::namespace(:sharing => "default").is_a?(DefaultNamespace))
80
+ assert_true(Splunk::namespace(:sharing => "default").is_a?(Namespace))
81
+ end
82
+
83
+ def test_throws_without_enough_information
84
+ assert_raise ArgumentError do
85
+ Splunk::namespace(:sharing => "user")
86
+ end
87
+
88
+ assert_raise ArgumentError do
89
+ Splunk::namespace(:sharing => "user", :app => "boris")
90
+ end
91
+
92
+ assert_raise ArgumentError do
93
+ Splunk::namespace(:sharing => "app")
94
+ end
95
+ end
96
+
97
+ def test_propriety
98
+ assert_true(Splunk::namespace(:sharing => "global").is_exact?)
99
+ assert_true(Splunk::namespace(:sharing => "system").is_exact?)
100
+ assert_true(Splunk::namespace(:sharing => "default").is_exact?)
101
+ assert_true(Splunk::namespace(:sharing => "app", :app => "search").is_exact?)
102
+ assert_false(Splunk::namespace(:sharing => "app", :app => "-").is_exact?)
103
+ assert_true(Splunk::namespace(:sharing => "app", :app => "").is_exact?)
104
+ assert_true(Splunk::namespace(:sharing => "user", :app => "search",
105
+ :owner => "boris").is_exact?)
106
+ assert_false(Splunk::namespace(:sharing => "user", :app => "-",
107
+ :owner => "boris").is_exact?)
108
+ assert_false(Splunk::namespace(:sharing => "user", :app => "search",
109
+ :owner => "-").is_exact?)
110
+ assert_false(Splunk::namespace(:sharing => "user", :app => "-",
111
+ :owner => "-").is_exact?)
112
+ end
113
+
114
+ def test_path_segments
115
+ assert_equal(["services"], Splunk::namespace(:sharing => "default").to_path_fragment())
116
+ assert_equal(["servicesNS", "nobody", "system"],
117
+ Splunk::namespace(:sharing => "global").to_path_fragment)
118
+ assert_equal(["servicesNS", "nobody", "system"],
119
+ Splunk::namespace(:sharing => "system").to_path_fragment)
120
+ assert_equal(["servicesNS", "nobody", "search"],
121
+ Splunk::namespace(:sharing => "app", :app => "search").to_path_fragment)
122
+ assert_equal(["servicesNS", "nobody", "-"],
123
+ Splunk::namespace(:sharing => "app", :app => "-").to_path_fragment)
124
+ assert_equal(["services"], Splunk::namespace(:sharing => "app",
125
+ :app => "").to_path_fragment)
126
+ assert_equal(["servicesNS", "boris", "search"],
127
+ Splunk::namespace(:sharing => "user",
128
+ :app => "search",
129
+ :owner => "boris").to_path_fragment)
130
+ end
131
+
132
+ def test_eai_acl_to_namespace
133
+ data = {
134
+ Splunk::namespace(:sharing => "app", :app => "system") => {
135
+ "app" => "system",
136
+ "can_change_perms" => "1",
137
+ "can_list" => "1",
138
+ "can_share_app" => "1",
139
+ "can_share_global" => "1",
140
+ "can_share_user" => "0",
141
+ "can_write" => "1",
142
+ "modifiable" => "1",
143
+ "owner" => "nobody",
144
+ "perms" => {
145
+ "read" => ["*"],
146
+ "write" => ["power"]
147
+ },
148
+ "removable" => "0",
149
+ "sharing" => "app"
150
+ },
151
+ Splunk::namespace(:sharing => "global") => {
152
+ "perms" => {
153
+ "read" => ["admin"],
154
+ "write" => ["admin"],
155
+ },
156
+ "owner" => "admin",
157
+ "modifiable" => "1",
158
+ "sharing" => "global",
159
+ "app" => "search",
160
+ "can_write" => "1"
161
+ },
162
+ Splunk::namespace(:sharing => "app", :app => "") => {
163
+ "app" => "",
164
+ "can_change_perms" => "1",
165
+ "can_list" => "1",
166
+ "can_share_app" => "1",
167
+ "can_share_global" => "1",
168
+ "can_share_user" => "0",
169
+ "can_write" => "1",
170
+ "modifiable" => "1",
171
+ "owner" => "system",
172
+ "perms" => {
173
+ "read" => ["*"],
174
+ "write" => ["power"]
175
+ },
176
+ "removable" => "0",
177
+ "sharing" => "app",
178
+ }
179
+ }
180
+ data.each_entry do |expected_namespace, eai_acl|
181
+ found_namespace = Splunk::eai_acl_to_namespace(eai_acl)
182
+ assert_equal(expected_namespace, found_namespace)
183
+ end
184
+ end
185
+ end
186
+
187
+
188
+
@@ -0,0 +1,49 @@
1
+ require_relative "test_helper"
2
+ require "splunk-sdk-ruby"
3
+
4
+ include Splunk
5
+
6
+ class TestRestarts < TestCaseWithSplunkConnection
7
+ def test_restart_with_long_timeout
8
+ service = Context.new(@splunkrc).login()
9
+ begin
10
+ service.restart(2000)
11
+ rescue TimeoutError
12
+ while !service.server_accepting_connections? ||
13
+ service.server_requires_restart?
14
+ sleep(0.3)
15
+ end
16
+ end
17
+
18
+ assert_logged_in(service)
19
+ end
20
+
21
+ def test_restart_with_short_timeout
22
+ service = Context.new(@splunkrc).login()
23
+ begin
24
+ service.restart(0.1)
25
+ rescue TimeoutError
26
+ # Wait for it to come back up
27
+ while !service.server_accepting_connections? ||
28
+ service.server_requires_restart?
29
+ sleep(0.3)
30
+ end
31
+ assert_logged_in(service)
32
+ else
33
+ fail("Somehow Splunk managed to restart in 100ms...")
34
+ end
35
+ end
36
+
37
+ def test_restart_with_no_timeout
38
+ service = Context.new(@splunkrc).login()
39
+ service.restart()
40
+ assert_not_logged_in(service)
41
+
42
+ # Wait for it to come back up
43
+ while !service.server_accepting_connections? ||
44
+ service.server_requires_restart?
45
+ sleep(0.3)
46
+ end
47
+ assert_logged_in(service)
48
+ end
49
+ end
@@ -0,0 +1,106 @@
1
+ require_relative 'test_helper'
2
+ require 'splunk-sdk-ruby'
3
+ require 'json'
4
+
5
+ include Splunk
6
+
7
+ class TestResultsReader < Test::Unit::TestCase
8
+ if nokogiri_available?
9
+ xml_libraries = [:nokogiri, :rexml]
10
+ else
11
+ xml_libraries = [:rexml]
12
+ puts "Nokogiri not installed. Skipping."
13
+ end
14
+
15
+ def assert_results_reader_equals(expected, reader)
16
+ assert_equal(expected["is_preview"], reader.is_preview?)
17
+ assert_equal(expected["fields"], reader.fields)
18
+
19
+ n_results = 0
20
+ reader.each_with_index do |result, index|
21
+ n_results += 1
22
+ # The assert of the full data structure below works, but
23
+ # by default Test::Unit doesn't print the diff of large
24
+ # data structures, so for debugging purposes it's much
25
+ # nicer to have each key checked individually as well.
26
+ expected["results"][index].each_entry do |key, value|
27
+ assert_equal([index, key, value],
28
+ [index, key, result[key]])
29
+ end
30
+ assert_equal(expected["results"][index], result)
31
+ end
32
+ assert_equal(expected["results"].length, n_results)
33
+ end
34
+
35
+ test_data = JSON::parse(open("test/resultsreader_test_data.json").read())
36
+ export_data = JSON::parse(open("test/export_test_data.json").read())
37
+
38
+ xml_libraries.each do |xml_library|
39
+ test_data.each_entry do |version, tests|
40
+ tests.each_entry do |name, expected|
41
+ test_name = "test_#{xml_library}_#{version.gsub(/\./, "_")}_#{name}"
42
+ define_method(test_name.intern()) do
43
+ Splunk::require_xml_library(xml_library)
44
+ file = File.open("test/data/results/#{version}/#{name}.xml")
45
+ reader = ResultsReader.new(file)
46
+ assert_results_reader_equals(expected, reader)
47
+ end
48
+ end
49
+ end
50
+
51
+ export_data.each_entry do |version, tests|
52
+ # without_preview
53
+ test_name = "test_#{xml_library}_#{version.gsub(/\./, "_")}_sans_preview"
54
+ define_method(test_name.intern) do
55
+ Splunk::require_xml_library(xml_library)
56
+ file = File.open("test/data/export/#{version}/export_results.xml")
57
+ reader = MultiResultsReader.new(file)
58
+ found = reader.final_results()
59
+ expected = tests["without_preview"]
60
+ assert_results_reader_equals(expected, found)
61
+ end
62
+
63
+ # with preview
64
+ test_name = "test_#{xml_library}_#{version.gsub(/\./, "_")}_with_preview"
65
+ define_method(test_name.intern) do
66
+ Splunk::require_xml_library(xml_library)
67
+ file = File.open("test/data/export/#{version}/export_results.xml")
68
+ multireader = MultiResultsReader.new(file)
69
+ n_results_sets = 0
70
+ readers = []
71
+ multireader.each_with_index do |rr, index|
72
+ readers << rr
73
+ expected = tests["with_preview"][index]
74
+ assert_results_reader_equals(expected, rr)
75
+ n_results_sets += 1
76
+ end
77
+ assert_equal(tests["with_preview"].length, n_results_sets)
78
+ assert_raise do # Out of order invocation should raise an error
79
+ readers[0].each()
80
+ end
81
+ end
82
+
83
+ # nonreporting
84
+ test_name = "test_#{xml_library}_#{version.gsub("/\./", "_")}_nonreporting"
85
+ if tests.has_key?("nonreporting")
86
+ define_method(test_name.intern) do
87
+ Splunk::require_xml_library(xml_library)
88
+ file = File.open("test/data/export/#{version}/nonreporting.xml")
89
+ multireader = MultiResultsReader.new(file)
90
+ n_results_sets = 0
91
+ readers = []
92
+ multireader.each_with_index do |rr, index|
93
+ readers << rr
94
+ expected = tests["nonreporting"][index]
95
+ assert_results_reader_equals(expected, rr)
96
+ n_results_sets += 1
97
+ end
98
+ assert_equal(1, n_results_sets)
99
+ end
100
+ end
101
+
102
+ end
103
+ end
104
+
105
+
106
+ end
@@ -0,0 +1,41 @@
1
+ require_relative 'test_helper'
2
+ require 'splunk-sdk-ruby'
3
+
4
+ include Splunk
5
+
6
+ class RoleTestCase < TestCaseWithSplunkConnection
7
+ def teardown
8
+ @service.roles.each do |role|
9
+ if role.name.start_with?("delete-me")
10
+ @service.roles.delete(role.name)
11
+ end
12
+ end
13
+
14
+ super
15
+ end
16
+
17
+ ##
18
+ # Create a role and make sure the values we created it with actually
19
+ # appear, and that the role appears in the collection. Then delete it and
20
+ # make sure it vanishes from the collection.
21
+ #
22
+ def test_create_and_delete
23
+ name = temporary_name()
24
+ role = @service.roles.create(name)
25
+ assert_true(@service.roles.has_key?(name))
26
+ assert_equal(name, role.name)
27
+
28
+ @service.roles.delete(name)
29
+ assert_false(@service.roles.has_key?(name))
30
+ end
31
+
32
+ ##
33
+ # Make sure that the roles collection normalizes all names to lowercase,
34
+ # since role names are case insensitive.
35
+ #
36
+ def test_case_insensitive
37
+ name = temporary_name() + "UPCASE"
38
+ user = @service.roles.create(name)
39
+ assert_true(@service.roles.has_key?(name.downcase()))
40
+ end
41
+ end
@@ -0,0 +1,119 @@
1
+ require_relative 'test_helper'
2
+ require 'splunk-sdk-ruby'
3
+
4
+ include Splunk
5
+
6
+ class SavedSearchesTestCase < TestCaseWithSplunkConnection
7
+ def teardown
8
+ @service.saved_searches.each do |ss|
9
+ if ss.name.start_with?("delete-me")
10
+ ss.history.each() {|job| job.cancel()}
11
+ @service.saved_searches.delete(ss.name)
12
+ end
13
+ end
14
+
15
+ assert_eventually_true do
16
+ @service.saved_searches.all?() {|ss| !ss.name.start_with?("delete-me")}
17
+ end
18
+
19
+ super
20
+ end
21
+
22
+ def check_saved_search(saved_search)
23
+ expected_fields = ['alert.expires',
24
+ 'alert.severity',
25
+ 'alert.track',
26
+ 'alert_type',
27
+ 'dispatch.buckets',
28
+ 'dispatch.lookups',
29
+ 'dispatch.max_count',
30
+ 'dispatch.max_time',
31
+ 'dispatch.reduce_freq',
32
+ 'dispatch.spawn_process',
33
+ 'dispatch.time_format',
34
+ 'dispatch.ttl',
35
+ 'max_concurrent',
36
+ 'realtime_schedule',
37
+ 'restart_on_searchpeer_add',
38
+ 'run_on_startup',
39
+ 'search',
40
+ 'action.email',
41
+ 'action.populate_lookup',
42
+ 'action.rss',
43
+ 'action.script',
44
+ 'action.summary_index']
45
+ expected_fields.each do |f|
46
+ saved_search[f]
47
+ end
48
+
49
+ is_scheduled = saved_search["is_scheduled"]
50
+ assert_true(is_scheduled == '1' || is_scheduled == '0')
51
+ is_visible = saved_search["is_visible"]
52
+ assert_true(is_visible == '1' || is_visible == '0')
53
+ end
54
+
55
+ ##
56
+ # Make sure we can create a saved search, it shows up in the collection,
57
+ # and we can delete it.
58
+ #
59
+ def test_create_and_delete
60
+ saved_search_name = temporary_name()
61
+ @service.saved_searches.create(saved_search_name, :search => "search *")
62
+ assert_eventually_true(3) do
63
+ @service.saved_searches.has_key?(saved_search_name)
64
+ end
65
+
66
+ check_saved_search(@service.saved_searches[saved_search_name])
67
+
68
+ @service.saved_searches.delete(saved_search_name)
69
+ assert_eventually_true(3) do
70
+ !@service.saved_searches.member?(saved_search_name)
71
+ end
72
+ end
73
+
74
+ ##
75
+ # In Splunk 4.x, update on saved searches has to have special behavior, since
76
+ # Splunk will try to clear the search if you don't pass it (or will throw an
77
+ # error if you don't pass it). So we make sure that update works and the
78
+ # search is the same before and after.
79
+ #
80
+ def test_update
81
+ saved_search_name = temporary_name()
82
+ ss = @service.saved_searches.create(saved_search_name,
83
+ :search => "search *")
84
+
85
+ ss.update(:description => "boris")
86
+ ss.refresh()
87
+ assert_equal("boris", ss["description"])
88
+ assert_equal("search *", ss["search"])
89
+ end
90
+
91
+ ##
92
+ # In contrast to the previous test, make sure that we can set the search.
93
+ # with update.
94
+ #
95
+ def test_update_search
96
+ saved_search_name = temporary_name()
97
+ ss = @service.saved_searches.create(saved_search_name,
98
+ :search => "search *")
99
+
100
+ ss.update(:description => "boris",
101
+ :search => "search index=_internal *")
102
+ ss.refresh()
103
+ assert_equal("boris", ss["description"])
104
+ assert_equal("search index=_internal *", ss["search"])
105
+ end
106
+
107
+ ##
108
+ #
109
+ def test_dispatch()
110
+ saved_search_name = temporary_name()
111
+ ss = @service.saved_searches.create(saved_search_name,
112
+ :search => "search *")
113
+ job = ss.dispatch()
114
+ while !job.is_ready?()
115
+ sleep(0.2)
116
+ end
117
+ end
118
+
119
+ end