Skip to content

Commit 57b3d08

Browse files
Integration test framework (#49)
* Introduce integration test framework * Improve configuration of OVS database connections * Improve validation of command execution results +semver: major
1 parent 2f8fd2d commit 57b3d08

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1421
-162
lines changed

.gitattributes

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
###############################################################################
44
* text=auto
55

6+
###############################################################################
7+
# Recommended setings for Verify.
8+
###############################################################################
9+
*.verified.txt text eol=lf working-tree-encoding=UTF-8
10+
*.verified.xml text eol=lf working-tree-encoding=UTF-8
11+
*.verified.json text eol=lf working-tree-encoding=UTF-8
12+
*.verified.bin binary
13+
614
###############################################################################
715
# Set default behavior for command prompt diff.
816
#

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,4 +261,7 @@ __pycache__/
261261
*.pyc
262262

263263

264-
.idea
264+
.idea
265+
266+
# Verify results
267+
*.received.*

OVNAgent.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OVNAgent", "src\OVNAgent\OV
2323
EndProject
2424
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OVN.Windows", "src\OVN.Windows\OVN.Windows.csproj", "{19E88AFC-25A8-45A2-8F45-FD5A4BC9883B}"
2525
EndProject
26+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OVN.Core.IntegrationTests", "test\OVN.Core.IntegrationTests\OVN.Core.IntegrationTests.csproj", "{AFB92E98-3FAD-4EE5-B154-336E9715EABA}"
27+
EndProject
2628
Global
2729
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2830
Debug|Any CPU = Debug|Any CPU
@@ -65,6 +67,10 @@ Global
6567
{19E88AFC-25A8-45A2-8F45-FD5A4BC9883B}.Debug|Any CPU.Build.0 = Debug|Any CPU
6668
{19E88AFC-25A8-45A2-8F45-FD5A4BC9883B}.Release|Any CPU.ActiveCfg = Release|Any CPU
6769
{19E88AFC-25A8-45A2-8F45-FD5A4BC9883B}.Release|Any CPU.Build.0 = Release|Any CPU
70+
{AFB92E98-3FAD-4EE5-B154-336E9715EABA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
71+
{AFB92E98-3FAD-4EE5-B154-336E9715EABA}.Debug|Any CPU.Build.0 = Debug|Any CPU
72+
{AFB92E98-3FAD-4EE5-B154-336E9715EABA}.Release|Any CPU.ActiveCfg = Release|Any CPU
73+
{AFB92E98-3FAD-4EE5-B154-336E9715EABA}.Release|Any CPU.Build.0 = Release|Any CPU
6874
EndGlobalSection
6975
GlobalSection(SolutionProperties) = preSolution
7076
HideSolutionNode = FALSE
@@ -73,6 +79,7 @@ Global
7379
{C59D1A52-ED62-485C-8D53-D247E64AFDF8} = {F3C9BF77-FF83-4BE3-8E8F-06A0C65CF5D3}
7480
{E765A6A4-ADE6-46E1-B1FC-BEBC362897F1} = {F3C9BF77-FF83-4BE3-8E8F-06A0C65CF5D3}
7581
{A4AADA77-425D-4E63-816D-6FDC21A40A94} = {F3C9BF77-FF83-4BE3-8E8F-06A0C65CF5D3}
82+
{AFB92E98-3FAD-4EE5-B154-336E9715EABA} = {F3C9BF77-FF83-4BE3-8E8F-06A0C65CF5D3}
7683
EndGlobalSection
7784
GlobalSection(ExtensibilityGlobals) = postSolution
7885
SolutionGuid = {0FDDB177-FC3D-4D1E-BE62-EEF24847FB47}

azure-piplines.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ steps:
3030
projects: '**/*.csproj'
3131
arguments: '--configuration $(buildConfiguration)'
3232

33+
- task: PowerShell@2
34+
displayName: Install OVS
35+
condition: true
36+
inputs:
37+
pwsh: true
38+
targetType: 'inline'
39+
script: |
40+
# Expand-Archive is a script module and will take its preferences from the global scope.
41+
# See https://github.com/PowerShell/Microsoft.PowerShell.Archive/issues/77#issuecomment-601947496
42+
$global:ProgressPreference = 'SilentlyContinue'
43+
44+
Invoke-WebRequest -Uri 'https://github.com/eryph-org/eryph/raw/refs/heads/main/ovspackage-3.5.0-exp.zip' -OutFile C:\ovspackage.zip -UseBasicParsing
45+
Expand-Archive -Path C:\ovspackage.zip -DestinationPath C:\openvswitch\usr
46+
3347
- task: DotNetCoreCLI@2
3448
displayName: dotnet test
3549
inputs:

gitversion.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ branches: {}
44
ignore:
55
sha: []
66
merge-message-formats: {}
7+
next-version: 1.0.0
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
namespace Dbosoft.OVN;
2+
3+
/// <summary>
4+
/// Defines a generator which can be used to generate the
5+
/// UUIDs for new OVS database records.
6+
/// </summary>
7+
public interface IGuidGenerator
8+
{
9+
/// <summary>
10+
/// Returns a new <see cref="Guid"/>.
11+
/// </summary>
12+
Guid GenerateGuid();
13+
}

src/OVN.Abstractions/ISystemEnvironment.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,9 @@ public interface ISystemEnvironment
3030
/// to check the availability of the OVS kernel extensions.
3131
/// </summary>
3232
IOvsExtensionManager GetOvsExtensionManager();
33+
34+
/// <summary>
35+
/// Returns a generator which can be used to generate <see cref="Guid"/>s.
36+
/// </summary>
37+
IGuidGenerator GuidGenerator { get; }
3338
}

src/OVN.Abstractions/OSCommands/IProcess.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,17 @@ public interface IProcess : IDisposable
3333
/// See <see cref="Process.HasExited"/>
3434
/// </summary>
3535
bool HasExited { get; }
36-
36+
37+
/// <summary>
38+
/// See <see cref="Process.StandardOutput"/>
39+
/// </summary>
40+
StreamReader StandardOutput { get; }
41+
42+
/// <summary>
43+
/// See <see cref="Process.StandardError"/>
44+
/// </summary>
45+
StreamReader StandardError { get; }
46+
3747
/// <summary>
3848
/// See <see cref="Process.OutputDataReceived"/>
3949
/// </summary>

src/OVN.Core/DefaultFileSystem.cs

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public string ResolveOvsFilePath(OvsFile file, bool platformNeutral = true)
3131
{
3232
var basePath = "";
3333
var pathRoot = file.Path.Split('/', StringSplitOptions.RemoveEmptyEntries);
34-
basePath = FindBasePath(pathRoot.Length == 0
34+
basePath = ResolveBasePath(pathRoot.Length == 0
3535
? file.Path
3636
: pathRoot[0]);
3737

@@ -89,17 +89,18 @@ private string ConvertPathToPlatform(string inputPath)
8989
return inputPath;
9090
}
9191

92-
protected virtual string FindBasePath(string pathRoot)
92+
private string ResolveBasePath(string pathRoot)
9393
{
94-
var basePath = "/";
95-
if (_platform != OSPlatform.Windows) return $"{basePath}{pathRoot}";
96-
97-
if (pathRoot.StartsWith("usr"))
98-
basePath = "c:/openvswitch/";
99-
else
100-
basePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData),
101-
"openvswitch").Replace("\\", "/") + "/";
102-
103-
return $"{basePath}{pathRoot}";
94+
return pathRoot.StartsWith("usr")
95+
? $"{GetProgramRootPath()}{pathRoot}"
96+
: $"{GetDataRootPath()}{pathRoot}";
10497
}
105-
}
98+
99+
protected virtual string GetDataRootPath() =>
100+
_platform == OSPlatform.Windows
101+
? Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "openvswitch").Replace(@"\", "/") + "/"
102+
: "/";
103+
104+
protected virtual string GetProgramRootPath() =>
105+
_platform == OSPlatform.Windows ? "C:/openvswitch/" : "/";
106+
}

src/OVN.Core/LocalConnections.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
namespace Dbosoft.OVN;
2+
3+
public static class LocalConnections
4+
{
5+
public static readonly OvsDbConnection Northbound = new(new OvsFile("/var/run/ovn", "ovnnb_db.sock"));
6+
7+
public static readonly OvsDbConnection Southbound = new(new OvsFile("/var/run/ovn", "ovnsb_db.sock"));
8+
9+
public static readonly OvsDbConnection Switch = new(new OvsFile("/var/run/openvswitch", "db.sock"));
10+
}

0 commit comments

Comments
 (0)