Gen v1.21.0 (#603)

* gen v1.21.0

* update version converter

* bump version to 5

* remove support of netstandard2.0

* update test dependency
This commit is contained in:
Boshi Lian
2021-04-09 13:37:17 -07:00
committed by GitHub
parent 7d66489cb4
commit 225bb1f59b
108 changed files with 39288 additions and 29898 deletions

View File

@@ -10,7 +10,7 @@
<PackageReference Include="Microsoft.AspNetCore.JsonPatch" Version="5.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="Nito.AsyncEx.Coordination" Version="5.1.0" />
<PackageReference Include="xunit" Version="2.4.1" />

View File

@@ -165,7 +165,6 @@ namespace k8s.Tests
}
}
#if NETSTANDARD2_1 || NET5_0 // The functionality under test, here, is dependent on managed HTTP / WebSocket in .NET Core 2.1 or newer.
// this test doesn't work on OSX and is inconsistent on windows
[OperatingSystemDependentFact(Exclude = OperatingSystems.OSX | OperatingSystems.Windows)]
public void Cert()
@@ -338,7 +337,6 @@ namespace k8s.Tests
}
}
}
#endif // NETSTANDARD2_1 || NET5_0
[Fact]
public void ExternalToken()

View File

@@ -21,7 +21,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.9.4" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<PrivateAssets>all</PrivateAssets>

View File

@@ -1,4 +1,3 @@
#if !NETSTANDARD2_1 || NET5_0
/*
* These tests are only for the netstandard version of the client (there are separate tests for netcoreapp that connect to a local test-hosted server).
*/
@@ -157,4 +156,3 @@ namespace k8s.Tests
}
}
}
#endif

View File

@@ -1,4 +1,3 @@
#if !NETSTANDARD2_1 || NET5_0
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -42,5 +41,3 @@ namespace k8s.Tests.Mock
}
}
}
#endif // !NETSTANDARD2_1 || NET5_0

View File

@@ -6,6 +6,7 @@ using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using k8s.Models;
@@ -649,5 +650,39 @@ namespace k8s.Tests
}).ConfigureAwait(false);
}
}
[Fact]
public void ReadError()
{
var data = Encoding.UTF8.GetBytes(
"{\"type\":\"ERROR\",\"object\":{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"too old resource version: 44982(53593)\",\"reason\":\"Gone\",\"code\":410}}");
using (var stream = new MemoryStream(data))
using (var reader = new StreamReader(stream))
{
Exception recordedException = null;
var mre = new ManualResetEvent(false);
var watcher = new Watcher<V1Pod>(
() => Task.FromResult(reader),
null,
(exception) =>
{
recordedException = exception;
mre.Set();
});
mre.WaitOne();
Assert.NotNull(recordedException);
var k8sException = recordedException as KubernetesException;
Assert.NotNull(k8sException);
Assert.NotNull(k8sException.Status);
Assert.Equal("too old resource version: 44982(53593)", k8sException.Message);
Assert.Equal("too old resource version: 44982(53593)", k8sException.Status.Message);
}
}
}
}

View File

@@ -1,47 +0,0 @@
using k8s.Models;
using System;
using System.IO;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Xunit;
namespace k8s.Tests
{
public class WatcherTests
{
[Fact]
public void ReadError()
{
var data = Encoding.UTF8.GetBytes(
"{\"type\":\"ERROR\",\"object\":{\"kind\":\"Status\",\"apiVersion\":\"v1\",\"metadata\":{},\"status\":\"Failure\",\"message\":\"too old resource version: 44982(53593)\",\"reason\":\"Gone\",\"code\":410}}");
using (var stream = new MemoryStream(data))
using (var reader = new StreamReader(stream))
{
Exception recordedException = null;
var mre = new ManualResetEvent(false);
var watcher = new Watcher<V1Pod>(
() => Task.FromResult(reader),
null,
(exception) =>
{
recordedException = exception;
mre.Set();
});
mre.WaitOne();
Assert.NotNull(recordedException);
var k8sException = recordedException as KubernetesException;
Assert.NotNull(k8sException);
Assert.NotNull(k8sException.Status);
Assert.Equal("too old resource version: 44982(53593)", k8sException.Message);
Assert.Equal("too old resource version: 44982(53593)", k8sException.Status.Message);
}
}
}
}