public async Task ShouldNotPatchDeploymentsWithDifferentContainerImageAsync(string imageName, string tag, string protectedNamespace, int numberOfDeployments) { var deployList = GetDeployListHavingDifferentContainerImage(tag, protectedNamespace, numberOfDeployments); _broker.Setup(x => x.FindDeploymentsByImageAsync(imageName)).ReturnsAsync(deployList); var patchedDeploys = await _kubernetesService.PatchAllDeploymentAsync(imageName, tag); patchedDeploys.Should().Be(0); }
protected override async Task ExecuteAsync(CancellationToken stoppingToken) { // TODO: Move this to a service and inject it using DI using var consumer = new ConsumerBuilder <Null, string>(_config).Build(); var topic = "mihai"; try { consumer.Subscribe(topic); _logger.LogInformation($"Subscribed to topic {topic}."); } catch (Exception ex) { _logger.LogError(ex, "A Kafka error occurred."); } while (!stoppingToken.IsCancellationRequested) { try { var cr = consumer.Consume(stoppingToken); var message = JsonSerializer.Deserialize <DockerHubPayload>(cr.Message.Value); _logger.LogInformation("Received following message from Kafka: {@message}", message); await _kubernetesService.PatchAllDeploymentAsync(message?.Repository?.RepoName, message?.PushData?.Tag, stoppingToken); } catch (ConsumeException ex) { _logger.LogError(ex, "Could not consume the specified Kafka topic."); } catch (Exception ex) { _logger.LogCritical(ex, "An error occurred while calling K8s API."); } } }