2023-05-04 06:25:48 +00:00
|
|
|
|
using DistTestCore;
|
|
|
|
|
using NUnit.Framework;
|
|
|
|
|
using Utils;
|
|
|
|
|
|
|
|
|
|
namespace Tests.BasicTests
|
|
|
|
|
{
|
2023-05-04 12:55:39 +00:00
|
|
|
|
// Warning!
|
|
|
|
|
// This is a test to check network-isolation in the test-infrastructure.
|
|
|
|
|
// It requires parallelism(2) or greater to run.
|
2023-05-04 06:25:48 +00:00
|
|
|
|
[TestFixture]
|
|
|
|
|
public class NetworkIsolationTest : DistTest
|
|
|
|
|
{
|
|
|
|
|
private IOnlineCodexNode? node = null;
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void SetUpANodeAndWait()
|
|
|
|
|
{
|
|
|
|
|
node = SetupCodexNode();
|
|
|
|
|
|
2023-05-04 12:55:39 +00:00
|
|
|
|
Time.WaitUntil(() => node == null, TimeSpan.FromMinutes(5), TimeSpan.FromSeconds(5));
|
2023-05-04 06:25:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
public void ForeignNodeConnects()
|
|
|
|
|
{
|
|
|
|
|
var myNode = SetupCodexNode();
|
|
|
|
|
|
2023-05-04 12:55:39 +00:00
|
|
|
|
Time.WaitUntil(() => node != null, TimeSpan.FromMinutes(1), TimeSpan.FromSeconds(5));
|
|
|
|
|
|
|
|
|
|
try
|
2023-05-04 06:25:48 +00:00
|
|
|
|
{
|
2023-05-04 12:55:39 +00:00
|
|
|
|
myNode.ConnectToPeer(node!);
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
// Good! This connection should be prohibited by the network isolation policy.
|
|
|
|
|
node = null;
|
|
|
|
|
return;
|
2023-05-04 06:25:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-04 12:55:39 +00:00
|
|
|
|
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.");
|
2023-05-04 06:25:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|