public void ShouldResolveImageTagWhenImageNameIsNotSet() { var date = DateTimeOffset.UtcNow.AddHours(-1); var dockerRunLine = DockerRunParamsBuilder.BuildDockerLogLine( "testContainer", ":1.0", "test-services", "test", date, 42.ToString(), 4242.ToString()).AsSpan(); var dockerRunParameters = LogExtractor.Extract(dockerRunLine); Assert.Empty(dockerRunParameters.ImageName.ToString()); Assert.Equal("1.0", dockerRunParameters.ImageTag.ToString()); }
public void ShouldHaveEmptyContainerOrServiceNameWhenNotProvided() { var date = DateTimeOffset.UtcNow.AddHours(-1); var dockerRunLine = DockerRunParamsBuilder.BuildDockerLogLine( null, "test:1.0", null, "test", date, 42.ToString(), 4242.ToString()).AsSpan(); var dockerRunParameters = LogExtractor.Extract(dockerRunLine); Assert.Empty(dockerRunParameters.ContainerName.ToString()); Assert.Empty(dockerRunParameters.ServiceName.ToString()); }
public void ShouldHaveEmptyImageAndTagWhenTheyAreNotProvided() { var date = DateTimeOffset.UtcNow.AddHours(-1); var dockerRunLine = DockerRunParamsBuilder.BuildDockerLogLine( "testContainer", null, "test-services", "test", date, 42.ToString(), 4242.ToString()).AsSpan(); var dockerRunParameters = LogExtractor.Extract(dockerRunLine); Assert.Empty(dockerRunParameters.ImageName.ToString()); Assert.Empty(dockerRunParameters.ImageTag.ToString()); }
public void ShouldResolveOutboundPortOnly() { var date = DateTimeOffset.UtcNow.AddHours(-1); var dockerRunLine = DockerRunParamsBuilder.BuildDockerLogLine( "testContainer", "test:1.0:invalidTag", "test-services", "test", date, string.Empty, 42.ToString()).AsSpan(); var dockerRunParameters = LogExtractor.Extract(dockerRunLine); Assert.Equal(-1, dockerRunParameters.InboundPort); Assert.Equal(42, dockerRunParameters.OutboundPort); }
public void ShouldReturnNegativeOneWhenPortsDontHaveNumericValues() { var date = DateTimeOffset.UtcNow.AddHours(-1); var dockerRunLine = DockerRunParamsBuilder.BuildDockerLogLine( "testContainer", "test:1.0:invalidTag", "test-services", "test", date, null, "not-a-number").AsSpan(); var dockerRunParameters = LogExtractor.Extract(dockerRunLine); Assert.Equal(-1, dockerRunParameters.InboundPort); Assert.Equal(-1, dockerRunParameters.OutboundPort); }
public Task <ExtractDockerRunParamsResponse> Handle(ExtractDockerRunParamsRequest request, CancellationToken cancellationToken) { _logger.LogDebug(LogDockerLogLineReceived, request.LogLine); var metadata = LogExtractor.Extract(request.LogLine); return(Task.FromResult( new ExtractDockerRunParamsResponse { ServiceName = metadata.ServiceName.ToString(), ContainerName = metadata.ContainerName.ToString(), ImageName = metadata.ImageName.ToString(), ImageTag = metadata.ImageTag.ToString(), InboundPort = metadata.InboundPort.ToString(), OutboundPort = metadata.OutboundPort.ToString(), EventDate = metadata.Date })); }
public void ShouldExtractCorrectParameters() { var date = DateTimeOffset.UtcNow.AddHours(-1); var dockerRunLine = DockerRunParamsBuilder.BuildDockerLogLine( "testContainer", "test:1.0", "test-service", "test", date, 42.ToString(), 4242.ToString()).AsSpan(); var dockerRunParameters = LogExtractor.Extract(dockerRunLine); Assert.Equal("testContainer", dockerRunParameters.ContainerName.ToString()); Assert.Equal("test", dockerRunParameters.ImageName.ToString()); Assert.Equal("1.0", dockerRunParameters.ImageTag.ToString()); Assert.Equal("test-service", dockerRunParameters.ServiceName.ToString()); Assert.Equal(42, dockerRunParameters.InboundPort); Assert.Equal(4242, dockerRunParameters.OutboundPort); Assert.Equal(date, dockerRunParameters.Date); }
public void Extract2() { _ = LogExtractor.Extract(Data); }