Files
csharp/tests/Kubectl.Tests/KubectlTests.cs
Shenglong Li e1508370f5 Dispose certificates in Kubernetes.Dispose() (#1191)
* Dispose certs created by Kuberentes

* Update tests
2023-02-01 15:47:29 -08:00

44 lines
978 B
C#

using System.Diagnostics;
namespace k8s.kubectl.Tests;
public partial class KubectlTests
{
private string RunKubectl(string args)
{
var p = new Process
{
StartInfo = new ProcessStartInfo
{
FileName = "kubectl",
Arguments = args,
UseShellExecute = false,
RedirectStandardOutput = true,
RedirectStandardError = true,
CreateNoWindow = true,
},
};
p.Start();
try
{
if (!p.WaitForExit((int)TimeSpan.FromSeconds(30).TotalMilliseconds))
{
throw new Exception("kubectl timed out");
}
if (p.ExitCode != 0)
{
throw new Exception(p.StandardError.ReadToEnd());
}
return p.StandardOutput.ReadToEnd();
}
finally
{
p.Kill(true);
}
}
}