2023-09-12 13:43:30 +00:00
|
|
|
|
using CodexPlugin;
|
|
|
|
|
using DistTestCore;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Utils;
|
|
|
|
|
|
2023-10-09 14:59:52 +00:00
|
|
|
|
namespace CodexTests.BasicTests
|
2023-09-12 13:43:30 +00:00
|
|
|
|
{
|
|
|
|
|
// Warning!
|
|
|
|
|
// This is a test to check network-isolation in the test-infrastructure.
|
|
|
|
|
// It requires parallelism(2) or greater to run.
|
|
|
|
|
[TestFixture]
|
|
|
|
|
[Ignore("Disabled until a solution is implemented.")]
|
|
|
|
|
public class NetworkIsolationTest : DistTest
|
|
|
|
|
{
|
2023-09-19 09:51:59 +00:00
|
|
|
|
private ICodexNode? node = null;
|
2023-09-12 13:43:30 +00:00
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SetUpANodeAndWait()
|
|
|
|
|
{
|
2023-09-20 10:02:32 +00:00
|
|
|
|
node = Ci.StartCodexNode();
|
2023-09-12 13:43:30 +00:00
|
|
|
|
|
|
|
|
|
Time.WaitUntil(() => node == null, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(5));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ForeignNodeConnects()
|
|
|
|
|
{
|
2023-09-20 10:02:32 +00:00
|
|
|
|
var myNode = Ci.StartCodexNode();
|
2023-09-12 13:43:30 +00:00
|
|
|
|
|
|
|
|
|
Time.WaitUntil(() => node != null, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(5));
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
myNode.ConnectToPeer(node!);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// Good! This connection should be prohibited by the network isolation policy.
|
|
|
|
|
node = null;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Assert.Fail("Connection could be established between two Codex nodes running in different namespaces. " +
|
|
|
|
|
"This may cause cross-test interference. Network isolation policy should be applied. Test infra failure.");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|