public void JobRefreshTest() { var cli = Command.Splunk("search"); cli.AddRule("search", typeof(string), "search string"); cli.Opts["search"] = "search index=_internal * | head 10 "; var service = new Service(Scheme.Https, "localhost", 8089); service.LoginAsync("admin", "changeme").Wait(); var job = service.CreateJobAsync((string)cli.Opts["search"]).Result; Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); TimeSpan max = new TimeSpan(0, 0, 0, 10); while (!job.IsDone) { Thread.Sleep(1000); //has to call this to get the job.IsCompleted job.GetAsync().Wait(); Console.WriteLine("jobUpdated={0}", job.Updated); if (stopwatch.Elapsed > max) { Assert.False(true, string.Format("The job is not finished within expected time {0} seconds", max.TotalSeconds)); } } job.CancelAsync().Wait(); }
///// <summary> ///// Invalid argument ///// </summary> //private readonly Args<SearchOption> badOutputMode = // new Args("output_mode", "invalid_arg_value"); ///// <summary> ///// Invalid argument ///// </summary> //private readonly Args<SearchMode> badSearchMode = // new Args("search_mode", "invalid_arg_value"); ///// <summary> ///// Invalid argument ///// </summary> //private readonly Args badTruncationMode = // new Args("truncation_mode", "invalid_arg_value"); ///// <summary> ///// Invalid argument ///// </summary> //private readonly Args badExecutionMode = // new Args("exec_mode", "invalid_arg_value"); ///// <summary> ///// Run the given query. ///// </summary> ///// <param name="service">The service</param> ///// <param name="query">The search query</param> ///// <returns>The job</returns> //private Job Run(Service service, string query) //{ // return this.Run(service, query, null); //} ///// <summary> ///// Run the given query with the given query args. ///// </summary> ///// <param name="service">The service</param> ///// <param name="query">The search query</param> ///// <param name="args">The args</param> ///// <returns>The job</returns> //private Job Run(Service service, string query, JobArgs args) //{ // args.Search = query; // return service.StartJob(args); //} ///// <summary> ///// Run the given query and wait for the job to complete. ///// </summary> ///// <param name="service">The service</param> ///// <param name="query">The search query</param> ///// <returns>The job</returns> //private Job RunWait(Service service, string query) //{ // return this.RunWait(service, query, null); //} /// <summary> /// Run the given query with the given query args and wait for the job to /// complete. /// </summary> /// <param name="service">The service</param> /// <param name="jobArgs">The args</param> /// <returns>The job</returns> private Job RunWait(Service service, JobArgs jobArgs) { return service.CreateJobAsync(jobArgs).Result; }