public async Task PerformMetricsTest(string language, string functionName, string moduleName, string functionHandler, HttpStatusCode expectedResponse) { // Arrange EnvironmentManager.SetVariables(moduleName, functionHandler, funcRuntime: "dotnetcore3.1"); FunctionCompiler.PublishTestFunction(language, functionName); HttpClient client = _factory.CreateClient(); var request = new HttpRequestMessage(new HttpMethod("GET"), "/"); var invokeResponse = await client.SendAsync(request); Assert.Equal(expectedResponse, invokeResponse.StatusCode); // Act var response = await client.GetAsync("/metrics"); // Assert response.EnsureSuccessStatusCode(); var responseBody = await response.Content.ReadAsStringAsync(); Assert.Contains("kubeless_calls_total", responseBody); Assert.Contains($"status=\"{(int) expectedResponse}\"", responseBody); Assert.Contains("function=\"handler\"", responseBody); Assert.Contains("runtime=\"dotnetcore3.1\"", responseBody); Assert.Contains("handler=\"module\"", responseBody); }
public async Task PerformHealthCheck(string language, string functionName, string moduleName, string functionHandler) { // Arrange EnvironmentManager.SetVariables(moduleName, functionHandler); FunctionCompiler.PublishTestFunction(language, functionName); HttpClient client = _factory.CreateClient(); // Act var response = await client.GetAsync("/healthz"); // Assert response.EnsureSuccessStatusCode(); }
public async Task InvokeFunctionsThroughAPI(string httpMethod, string language, string functionName, string moduleName, string functionHandler, object expectedResponse) { // Arrange EnvironmentManager.SetVariables(moduleName, functionHandler); FunctionCompiler.PublishTestFunction(language, functionName); var client = _factory.CreateClient(); var request = new HttpRequestMessage(new HttpMethod(httpMethod), "/"); // Act var response = await client.SendAsync(request); // Assert response.EnsureSuccessStatusCode(); Assert.Equal(expectedResponse, await response.Content.ReadAsStringAsync()); }