basic info tests
This commit is contained in:
parent
7c4ad416d4
commit
e743a1cd7b
|
@ -32,6 +32,22 @@ namespace CodexPlugin
|
|||
return mapper.Map(OnCodex(api => api.GetDebugInfoAsync()));
|
||||
}
|
||||
|
||||
public string GetSpr()
|
||||
{
|
||||
return CrashCheck(() =>
|
||||
{
|
||||
var endpoint = GetEndpoint();
|
||||
var json = endpoint.HttpGetString("spr");
|
||||
var response = JsonConvert.DeserializeObject<SprResponse>(json);
|
||||
return response!.Spr;
|
||||
});
|
||||
}
|
||||
|
||||
private class SprResponse
|
||||
{
|
||||
public string Spr { get; set; } = string.Empty;
|
||||
}
|
||||
|
||||
public DebugPeer GetDebugPeer(string peerId)
|
||||
{
|
||||
// Cannot use openAPI: debug/peer endpoint is not specified there.
|
||||
|
|
|
@ -15,6 +15,7 @@ namespace CodexPlugin
|
|||
string GetName();
|
||||
string GetPeerId();
|
||||
DebugInfo GetDebugInfo();
|
||||
string GetSpr();
|
||||
DebugPeer GetDebugPeer(string peerId);
|
||||
ContentId UploadFile(TrackedFile file);
|
||||
ContentId UploadFile(TrackedFile file, Action<Failure> onFailure);
|
||||
|
@ -130,6 +131,11 @@ namespace CodexPlugin
|
|||
return debugInfo;
|
||||
}
|
||||
|
||||
public string GetSpr()
|
||||
{
|
||||
return CodexAccess.GetSpr();
|
||||
}
|
||||
|
||||
public DebugPeer GetDebugPeer(string peerId)
|
||||
{
|
||||
return CodexAccess.GetDebugPeer(peerId);
|
||||
|
|
|
@ -1,12 +1,62 @@
|
|||
using System;
|
||||
using CodexPlugin;
|
||||
using CodexTests;
|
||||
using NUnit.Framework;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Utils;
|
||||
|
||||
namespace CodexReleaseTests.NodeTests
|
||||
{
|
||||
internal class BasicInfoTests
|
||||
[TestFixture]
|
||||
public class BasicInfoTests : CodexDistTest
|
||||
{
|
||||
[Test]
|
||||
public void QuotaTest()
|
||||
{
|
||||
var size = 3.GB();
|
||||
var node = StartCodex(s => s.WithStorageQuota(size));
|
||||
var space = node.Space();
|
||||
|
||||
Assert.That(space.QuotaMaxBytes, Is.EqualTo(size.SizeInBytes));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void Spr()
|
||||
{
|
||||
var node = StartCodex();
|
||||
|
||||
var info = node.GetDebugInfo();
|
||||
Assert.That(!string.IsNullOrEmpty(info.Spr));
|
||||
|
||||
var spr = node.GetSpr();
|
||||
Assert.That(!string.IsNullOrEmpty(spr));
|
||||
|
||||
Assert.That(info.Spr, Is.EqualTo(spr));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void VersionInfo()
|
||||
{
|
||||
var node = StartCodex();
|
||||
|
||||
var info = node.GetDebugInfo();
|
||||
Assert.That(!string.IsNullOrEmpty(info.Version.Version));
|
||||
Assert.That(!string.IsNullOrEmpty(info.Version.Revision));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void AnnounceAddress()
|
||||
{
|
||||
var node = StartCodex();
|
||||
var addr = node.Container.GetInternalAddress(CodexContainerRecipe.ListenPortTag);
|
||||
|
||||
var info = node.GetDebugInfo();
|
||||
|
||||
Assert.That(info.AnnounceAddresses.Count, Is.GreaterThan(0));
|
||||
// Ideally we'd assert the pod IP is in the announce address, but we can't access it from here.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue