MoShiro__MinAgentVersion makes the backend refuse agents below it at hello (fleet_version_required); fleet.min_server_version or MOSHIRO_MIN_SERVER_VERSION makes the agent drop a backend below it. Either side waits five seconds and shakes hands again, because the other one may be updating.
22 lines
1007 B
C#
22 lines
1007 B
C#
using Fleet.Core;
|
|
|
|
namespace Fleet.Tests;
|
|
|
|
public sealed class NodeVersionsTests
|
|
{
|
|
[Theory]
|
|
[InlineData("0.4.2-dev.73-5245f03", "0.4.2-dev.74", true)]
|
|
[InlineData("0.4.2-dev.73-5245f03", "0.4.2-dev.73-abcdef0", false)] // 哈希不参与比较
|
|
[InlineData("0.4.2-dev.100-aaaaaaa", "0.4.2-dev.99", false)] // 序号按数字比,不是按字符串
|
|
[InlineData("0.4.2-dev.999", "0.4.2", true)] // 正式版高于预发布版
|
|
[InlineData("0.4.2", "0.4.2-dev.5", false)]
|
|
[InlineData("0.4.1", "0.4.2-dev.1", true)]
|
|
[InlineData("v0.5.0", "0.4.9", false)]
|
|
[InlineData("0.4.2-dev.73-5245f03", "", false)] // 没有要求
|
|
[InlineData("", "0.4.2", false)] // 认不出来的版本号不拒绝
|
|
[InlineData("not-a-version", "0.4.2", false)]
|
|
[InlineData("0.4.2", "garbage", false)]
|
|
public void IsBelow_ComparesCoreThenReleaseThenTheDevCounter(string actual, string required, bool expected) =>
|
|
Assert.Equal(expected, NodeVersions.IsBelow(actual, required));
|
|
}
|