-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Avastancu/joannaakl/service container error log #2110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
JoannaaKL
merged 41 commits into
main
from
avastancu/joannaakl/service-container-error-log
Oct 3, 2022
Merged
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
3b44061
adding support for a service container docker logs
AvaStancu 2e8d8a7
Adding Unit test to ContainerOperationProvider
JoannaaKL 160d07e
Adding another test to ContainerOperationProvider
JoannaaKL ae7bb31
placed the docker logs output in dedicated ##group section
AvaStancu 892a90c
Removed the exception thrown if the service container was not healthy
JoannaaKL d533271
Removed duplicated logging to the executionContext
JoannaaKL 29e26c0
Updated the container logs sub-section message
AvaStancu 2f9ced9
Print service containers only if they were healthy
AvaStancu 94e504c
Removed recently added method to inspect docker logs
AvaStancu cfcf083
Added execution context error
AvaStancu 2d4dc37
Removing the section 'Waiting for all services to be ready'
JoannaaKL ad8f17e
Update src/Runner.Worker/Container/DockerCommandManager.cs
JoannaaKL 354c8bc
Update src/Test/L0/TestHostContext.cs
JoannaaKL f0b315c
Change the logic for printing Service Containers logs
JoannaaKL 2dc8f25
Removed unused import
JoannaaKL dfcbe9b
Added back section group.
JoannaaKL 7a992f8
Moved service containers error logs to separate group sections
AvaStancu 76e4f51
Removed the test testing the old logic flow.
JoannaaKL 912d7d6
Remove unnecessary 'IsAnyUnhealthy' flag
JoannaaKL f5461b7
Remove printHello() function
JoannaaKL 3c88e14
Add newline to TestHostContext
JoannaaKL 47ead99
Remove unnecessary field 'UnhealthyContainers'
JoannaaKL b8aafc4
Rename boolean flag indicating service container failure
JoannaaKL 826cec2
Refactor healthcheck logic to separate method to enable unit testing.
JoannaaKL e03ad87
Remove the default value for bool variable
JoannaaKL 5b26a1e
Update src/Runner.Worker/ContainerOperationProvider.cs
JoannaaKL a9fa7f8
Update src/Runner.Worker/ContainerOperationProvider.cs
JoannaaKL b15525a
Rename Healthcheck back to ContainerHealthcheck
JoannaaKL 72fe579
Make test sequential
JoannaaKL 7ba0916
Unextract the container error logs method
JoannaaKL 805d6fd
remove test asserting thrown exception
JoannaaKL 3b30e5c
Add configure await
JoannaaKL d3f463b
Update src/Test/L0/Worker/ContainerOperationProviderL0.cs
JoannaaKL 75c40e3
Update src/Test/L0/Worker/ContainerOperationProviderL0.cs
JoannaaKL b1dd797
Update src/Test/L0/Worker/ContainerOperationProviderL0.cs
JoannaaKL 82b81f2
Update src/Test/L0/Worker/ContainerOperationProviderL0.cs
JoannaaKL c5685b7
Update src/Test/L0/Worker/ContainerOperationProviderL0.cs
JoannaaKL 1778f8f
Add back test asserting exception
JoannaaKL fec24e8
Check service exit code if there is no healtcheck configured
JoannaaKL f39a18d
Remove unnecessary healthcheck for healthy service container
JoannaaKL 0d782f4
Revert "Check service exit code if there is no healtcheck configured"
JoannaaKL File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,108 @@ | ||
| using GitHub.Runner.Worker; | ||
| using GitHub.Runner.Worker.Container; | ||
| using Xunit; | ||
| using Moq; | ||
| using GitHub.Runner.Worker.Container.ContainerHooks; | ||
| using System.Threading.Tasks; | ||
| using System.Collections.Generic; | ||
| using System.Runtime.CompilerServices; | ||
| using GitHub.DistributedTask.WebApi; | ||
| using System; | ||
|
|
||
| namespace GitHub.Runner.Common.Tests.Worker | ||
| { | ||
|
|
||
| public sealed class ContainerOperationProviderL0 | ||
| { | ||
|
|
||
| private TestHostContext _hc; | ||
| private Mock<IExecutionContext> _ec; | ||
| private Mock<IDockerCommandManager> _dockerManager; | ||
| private Mock<IContainerHookManager> _containerHookManager; | ||
| private ContainerOperationProvider containerOperationProvider; | ||
| private Mock<IJobServerQueue> serverQueue; | ||
| private Mock<IPagingLogger> pagingLogger; | ||
| private List<string> healthyDockerStatus = new List<string> { "healthy" }; | ||
| private List<string> unhealthyDockerStatus = new List<string> { "unhealthy" }; | ||
| private List<string> dockerLogs = new List<string> { "log1", "log2", "log3" }; | ||
|
|
||
| List<ContainerInfo> containers = new List<ContainerInfo>(); | ||
|
|
||
| [Fact] | ||
| [Trait("Level", "L0")] | ||
| [Trait("Category", "Worker")] | ||
| public async void RunServiceContainersHealthcheck_UnhealthyServiceContainer_AssertFailedTask() | ||
| { | ||
| //Arrange | ||
| Setup(); | ||
| _dockerManager.Setup(x => x.DockerInspect(_ec.Object, It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(unhealthyDockerStatus)); | ||
|
|
||
| //Act | ||
| try | ||
| { | ||
| await containerOperationProvider.RunContainersHealthcheck(_ec.Object, containers); | ||
| } | ||
| catch (InvalidOperationException) | ||
| { | ||
|
|
||
| //Assert | ||
| Assert.Equal(TaskResult.Failed, _ec.Object.Result ?? TaskResult.Failed); | ||
| } | ||
| } | ||
|
|
||
| [Fact] | ||
| [Trait("Level", "L0")] | ||
| [Trait("Category", "Worker")] | ||
| public async void RunServiceContainersHealthcheck_UnhealthyServiceContainer_AssertExceptionThrown() | ||
| { | ||
| //Arrange | ||
| Setup(); | ||
| _dockerManager.Setup(x => x.DockerInspect(_ec.Object, It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(unhealthyDockerStatus)); | ||
|
|
||
| //Act and Assert | ||
| await Assert.ThrowsAsync<InvalidOperationException>(() => containerOperationProvider.RunContainersHealthcheck(_ec.Object, containers)); | ||
|
|
||
| } | ||
|
|
||
| [Fact] | ||
| [Trait("Level", "L0")] | ||
| [Trait("Category", "Worker")] | ||
| public async void RunServiceContainersHealthcheck_healthyServiceContainer_AssertSucceededTask() | ||
| { | ||
| //Arrange | ||
| Setup(); | ||
JoannaaKL marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| _dockerManager.Setup(x => x.DockerInspect(_ec.Object, It.IsAny<string>(), It.IsAny<string>())).Returns(Task.FromResult(healthyDockerStatus)); | ||
|
|
||
| //Act | ||
| await containerOperationProvider.RunContainersHealthcheck(_ec.Object, containers); | ||
|
|
||
| //Assert | ||
| Assert.Equal(TaskResult.Succeeded, _ec.Object.Result ?? TaskResult.Succeeded); | ||
|
|
||
| } | ||
|
|
||
JoannaaKL marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| private void Setup([CallerMemberName] string testName = "") | ||
JoannaaKL marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| { | ||
| containers.Add(new ContainerInfo() { ContainerImage = "ubuntu:16.04" }); | ||
| _hc = new TestHostContext(this, testName); | ||
| _ec = new Mock<IExecutionContext>(); | ||
| serverQueue = new Mock<IJobServerQueue>(); | ||
| pagingLogger = new Mock<IPagingLogger>(); | ||
|
|
||
| _dockerManager = new Mock<IDockerCommandManager>(); | ||
| _containerHookManager = new Mock<IContainerHookManager>(); | ||
| containerOperationProvider = new ContainerOperationProvider(); | ||
|
|
||
| _hc.SetSingleton<IDockerCommandManager>(_dockerManager.Object); | ||
| _hc.SetSingleton<IJobServerQueue>(serverQueue.Object); | ||
| _hc.SetSingleton<IPagingLogger>(pagingLogger.Object); | ||
|
|
||
| _hc.SetSingleton<IDockerCommandManager>(_dockerManager.Object); | ||
| _hc.SetSingleton<IContainerHookManager>(_containerHookManager.Object); | ||
|
|
||
| _ec.Setup(x => x.Global).Returns(new GlobalContext()); | ||
|
|
||
| containerOperationProvider.Initialize(_hc); | ||
| } | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.