-
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix to allow for force pull in UseImage fluent API.
This allows a force pull from either private or public repo and solves Issue #84.
- Loading branch information
Mario Toffia
committed
May 3, 2019
1 parent
831dd51
commit 8946d91
Showing
12 changed files
with
162 additions
and
44 deletions.
There are no files selected for viewing
This file contains 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 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
85 changes: 85 additions & 0 deletions
85
Ductus.FluentDocker.Tests/FluentApiTests/FluentNetworkTests.cs
This file contains 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,85 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Ductus.FluentDocker.Extensions; | ||
using Ductus.FluentDocker.Services.Extensions; | ||
using Ductus.FluentDocker.Tests.Extensions; | ||
using Microsoft.VisualStudio.TestTools.UnitTesting; | ||
|
||
namespace Ductus.FluentDocker.Tests.FluentApiTests | ||
{ | ||
[TestClass] | ||
public class FluentNetworkTests | ||
{ | ||
[ClassInitialize] | ||
public static void Initialize(TestContext ctx) | ||
{ | ||
Utilities.LinuxMode(); | ||
} | ||
|
||
[TestMethod] | ||
public void StaticIpv4InCustomNetworkShallWork() | ||
{ | ||
using (var nw = Fd.UseNetwork("unit-test-nw") | ||
.UseSubnet("10.18.0.0/16").Build()) | ||
{ | ||
using ( | ||
var container = | ||
Fd.UseContainer() | ||
.WithName("mycontainer") | ||
.UseImage("postgres:9.6-alpine") | ||
.WithEnvironment("POSTGRES_PASSWORD=mysecretpassword") | ||
.ExposePort(5432) | ||
.UseNetwork(nw) | ||
.UseIpV4("10.18.0.22") | ||
.WaitForPort("5432/tcp", 30000 /*30s*/) | ||
.Build() | ||
.Start()) | ||
{ | ||
var ip = container.GetConfiguration().NetworkSettings.Networks["unit-test-nw"].IPAddress; | ||
Assert.AreEqual("10.18.0.22", ip); | ||
} | ||
} | ||
} | ||
|
||
[TestMethod] | ||
public void InternalNetworkExposedToHostShallWork() | ||
{ | ||
using (var nw = Fd.UseNetwork("unit-test-nw") | ||
.UseDriver("bridge") | ||
.IsInternal() | ||
.Build()) | ||
{ | ||
// Ping outside shall not work | ||
using ( | ||
var container = | ||
Fd.UseContainer() | ||
.WithName("internal-container") | ||
.UseImage("alpine") | ||
.UseNetwork(nw) | ||
.Command("ping", "1.1.1.1", "-c 1", "-w 5", "-W 5") | ||
.Build() | ||
.Start()) | ||
{ | ||
var log = container.Logs().ReadToEnd(30_000); | ||
var c = container.GetConfiguration(true); | ||
var ec = c.State.ExitCode; | ||
Assert.AreEqual(1, ec); | ||
} | ||
|
||
// Gain access to the container from host shall work | ||
using (var container = | ||
Fd.UseContainer() | ||
.UseImage("nginx:1.13.6-alpine") | ||
.ExposePort(80) | ||
.UseNetwork(nw) | ||
.WaitForPort("80/tcp", 30000 /*30s*/) | ||
.Build() | ||
.Start()) | ||
{ | ||
var response = $"http://{container.ToHostExposedEndpoint("80/tcp")}".Wget().Result; | ||
Console.WriteLine(response); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains 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 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 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 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 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 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 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 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
Oops, something went wrong.