feat: Implement Scheduler Worker Options and Planner Loop
	
		
			
	
		
	
	
		
	
		
			Some checks failed
		
		
	
	
		
			
				
	
				Docs CI / lint-and-preview (push) Has been cancelled
				
			
		
		
	
	
				
					
				
			
		
			Some checks failed
		
		
	
	Docs CI / lint-and-preview (push) Has been cancelled
				
			- Added `SchedulerWorkerOptions` class to encapsulate configuration for the scheduler worker. - Introduced `PlannerBackgroundService` to manage the planner loop, fetching and processing planning runs. - Created `PlannerExecutionService` to handle the execution logic for planning runs, including impact targeting and run persistence. - Developed `PlannerExecutionResult` and `PlannerExecutionStatus` to standardize execution outcomes. - Implemented validation logic within `SchedulerWorkerOptions` to ensure proper configuration. - Added documentation for the planner loop and impact targeting features. - Established health check endpoints and authentication mechanisms for the Signals service. - Created unit tests for the Signals API to ensure proper functionality and response handling. - Configured options for authority integration and fallback authentication methods.
This commit is contained in:
		
							
								
								
									
										70
									
								
								src/StellaOps.Signals.Tests/SignalsApiTests.cs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										70
									
								
								src/StellaOps.Signals.Tests/SignalsApiTests.cs
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,70 @@ | ||||
| using System.Net; | ||||
| using System.Net.Http.Json; | ||||
| using Microsoft.AspNetCore.Mvc.Testing; | ||||
| using Xunit; | ||||
|  | ||||
| namespace StellaOps.Signals.Tests; | ||||
|  | ||||
| public class SignalsApiTests : IClassFixture<WebApplicationFactory<Program>> | ||||
| { | ||||
|     private readonly WebApplicationFactory<Program> factory; | ||||
|  | ||||
|     public SignalsApiTests(WebApplicationFactory<Program> factory) | ||||
|     { | ||||
|         this.factory = factory; | ||||
|     } | ||||
|  | ||||
|     [Fact] | ||||
|     public async Task Healthz_ReturnsOk() | ||||
|     { | ||||
|         var client = factory.CreateClient(); | ||||
|         var response = await client.GetAsync("/healthz"); | ||||
|  | ||||
|         Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||||
|     } | ||||
|  | ||||
|     [Fact] | ||||
|     public async Task Readyz_ReturnsOk() | ||||
|     { | ||||
|         var client = factory.CreateClient(); | ||||
|         var response = await client.GetAsync("/readyz"); | ||||
|  | ||||
|         Assert.Equal(HttpStatusCode.OK, response.StatusCode); | ||||
|         var payload = await response.Content.ReadFromJsonAsync<Dictionary<string, string>>(); | ||||
|         Assert.NotNull(payload); | ||||
|         Assert.Equal("ready", payload!["status"]); | ||||
|     } | ||||
|  | ||||
|     [Fact] | ||||
|     public async Task Ping_WithoutScopeHeader_ReturnsUnauthorized() | ||||
|     { | ||||
|         var client = factory.CreateClient(); | ||||
|         var response = await client.GetAsync("/signals/ping"); | ||||
|  | ||||
|         Assert.Equal(HttpStatusCode.Unauthorized, response.StatusCode); | ||||
|     } | ||||
|  | ||||
|     [Fact] | ||||
|     public async Task Ping_WithMissingScope_ReturnsForbidden() | ||||
|     { | ||||
|         var client = factory.CreateClient(); | ||||
|         var request = new HttpRequestMessage(HttpMethod.Get, "/signals/ping"); | ||||
|         request.Headers.Add("X-Scopes", "signals:write"); | ||||
|  | ||||
|         var response = await client.SendAsync(request); | ||||
|  | ||||
|         Assert.Equal(HttpStatusCode.Forbidden, response.StatusCode); | ||||
|     } | ||||
|  | ||||
|     [Fact] | ||||
|     public async Task Ping_WithReadScope_ReturnsNoContent() | ||||
|     { | ||||
|         var client = factory.CreateClient(); | ||||
|         var request = new HttpRequestMessage(HttpMethod.Get, "/signals/ping"); | ||||
|         request.Headers.Add("X-Scopes", "signals:read"); | ||||
|  | ||||
|         var response = await client.SendAsync(request); | ||||
|  | ||||
|         Assert.Equal(HttpStatusCode.NoContent, response.StatusCode); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user