mirror of
https://github.com/codex-storage/cs-codex-dist-tests.git
synced 2025-02-13 20:46:37 +00:00
Fixes issue where occassionally a CID contains 'ERR' and fails the log assert.
This commit is contained in:
parent
770ba6dcdc
commit
3e2cad3c17
@ -6,6 +6,7 @@ namespace KubernetesWorkflow
|
|||||||
{
|
{
|
||||||
string ContainerName { get; }
|
string ContainerName { get; }
|
||||||
|
|
||||||
|
void IterateLines(Action<string> action);
|
||||||
void IterateLines(Action<string> action, params string[] thatContain);
|
void IterateLines(Action<string> action, params string[] thatContain);
|
||||||
string[] GetLinesContaining(string expectedString);
|
string[] GetLinesContaining(string expectedString);
|
||||||
string[] FindLinesThatContain(params string[] tags);
|
string[] FindLinesThatContain(params string[] tags);
|
||||||
@ -25,58 +26,39 @@ namespace KubernetesWorkflow
|
|||||||
|
|
||||||
public string ContainerName { get; }
|
public string ContainerName { get; }
|
||||||
|
|
||||||
public void IterateLines(Action<string> action, params string[] thatContain)
|
public void IterateLines(Action<string> action)
|
||||||
{
|
{
|
||||||
using var file = File.OpenRead(logFile.FullFilename);
|
using var file = File.OpenRead(logFile.FullFilename);
|
||||||
using var streamReader = new StreamReader(file);
|
using var streamReader = new StreamReader(file);
|
||||||
|
|
||||||
var line = streamReader.ReadLine();
|
var line = streamReader.ReadLine();
|
||||||
while (line != null)
|
while (line != null)
|
||||||
|
{
|
||||||
|
action(line);
|
||||||
|
line = streamReader.ReadLine();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void IterateLines(Action<string> action, params string[] thatContain)
|
||||||
|
{
|
||||||
|
IterateLines(line =>
|
||||||
{
|
{
|
||||||
if (thatContain.All(line.Contains))
|
if (thatContain.All(line.Contains))
|
||||||
{
|
{
|
||||||
action(line);
|
action(line);
|
||||||
}
|
}
|
||||||
line = streamReader.ReadLine();
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] GetLinesContaining(string expectedString)
|
public string[] GetLinesContaining(string expectedString)
|
||||||
{
|
{
|
||||||
using var file = File.OpenRead(logFile.FullFilename);
|
return FindLinesThatContain([expectedString]);
|
||||||
using var streamReader = new StreamReader(file);
|
|
||||||
var lines = new List<string>();
|
|
||||||
|
|
||||||
var line = streamReader.ReadLine();
|
|
||||||
while (line != null)
|
|
||||||
{
|
|
||||||
if (line.Contains(expectedString))
|
|
||||||
{
|
|
||||||
lines.Add(line);
|
|
||||||
}
|
|
||||||
line = streamReader.ReadLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
return lines.ToArray(); ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public string[] FindLinesThatContain(params string[] tags)
|
public string[] FindLinesThatContain(params string[] tags)
|
||||||
{
|
{
|
||||||
var result = new List<string>();
|
var result = new List<string>();
|
||||||
using var file = File.OpenRead(logFile.FullFilename);
|
IterateLines(result.Add, tags);
|
||||||
using var streamReader = new StreamReader(file);
|
|
||||||
|
|
||||||
var line = streamReader.ReadLine();
|
|
||||||
while (line != null)
|
|
||||||
{
|
|
||||||
if (tags.All(line.Contains))
|
|
||||||
{
|
|
||||||
result.Add(line);
|
|
||||||
}
|
|
||||||
|
|
||||||
line = streamReader.ReadLine();
|
|
||||||
}
|
|
||||||
|
|
||||||
return result.ToArray();
|
return result.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,5 +23,21 @@ namespace DistTestCore
|
|||||||
}
|
}
|
||||||
CollectionAssert.IsEmpty(errors);
|
CollectionAssert.IsEmpty(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AssertLogDoesNotContainLinesStartingWith(this IDownloadedLog log, params string[] unexpectedStrings)
|
||||||
|
{
|
||||||
|
var errors = new List<string>();
|
||||||
|
log.IterateLines(line =>
|
||||||
|
{
|
||||||
|
foreach (var str in unexpectedStrings)
|
||||||
|
{
|
||||||
|
if (line.StartsWith(str))
|
||||||
|
{
|
||||||
|
errors.Add($"Found '{str}' at start of line '{line}'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
CollectionAssert.IsEmpty(errors);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -99,7 +99,7 @@ namespace CodexTests
|
|||||||
var log = Ci.DownloadLog(node);
|
var log = Ci.DownloadLog(node);
|
||||||
|
|
||||||
log.AssertLogDoesNotContain("Block validation failed");
|
log.AssertLogDoesNotContain("Block validation failed");
|
||||||
log.AssertLogDoesNotContain("ERR ");
|
log.AssertLogDoesNotContainLinesStartingWith("ERR ");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void LogNodeStatus(ICodexNode node, IMetricsAccess? metrics = null)
|
public void LogNodeStatus(ICodexNode node, IMetricsAccess? metrics = null)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user