-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
osversion: Add new versions, fix compat bug, improve tests
- Add V23H2 (annual channel) and LTSC2025 to the version list - Use the LTSC build naming in the compat checks and tests, to make intent clearer - Fix a bug in the compat check. A given LTSC release should be able to run everything from the previous LTSC up to itself - Add new test cases, including for the fixed compat check bug - Change the tests to use t.Run for each test case Signed-off-by: Kevin Parsons <[email protected]>
- Loading branch information
Showing
3 changed files
with
81 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,68 +1,86 @@ | ||
package osversion | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
) | ||
|
||
// Test the platform compatibility of the different | ||
// OS Versions considering two ltsc container image | ||
// versions (ltsc2019, ltsc2022) | ||
// Test the platform compatibility of the different OS Versions | ||
func Test_PlatformCompat(t *testing.T) { | ||
for testName, tc := range map[string]struct { | ||
hostOs uint16 | ||
ctrOs uint16 | ||
for _, tc := range []struct { | ||
hostOS uint16 | ||
ctrOS uint16 | ||
shouldRun bool | ||
}{ | ||
"RS5Host_ltsc2019": { | ||
hostOs: RS5, | ||
ctrOs: RS5, | ||
{ | ||
hostOS: LTSC2019, | ||
ctrOS: LTSC2019, | ||
shouldRun: true, | ||
}, | ||
"RS5Host_ltsc2022": { | ||
hostOs: RS5, | ||
ctrOs: V21H2Server, | ||
{ | ||
hostOS: LTSC2019, | ||
ctrOS: LTSC2022, | ||
shouldRun: false, | ||
}, | ||
"WS2022Host_ltsc2019": { | ||
hostOs: V21H2Server, | ||
ctrOs: RS5, | ||
{ | ||
hostOS: LTSC2022, | ||
ctrOS: LTSC2019, | ||
shouldRun: false, | ||
}, | ||
"WS2022Host_ltsc2022": { | ||
hostOs: V21H2Server, | ||
ctrOs: V21H2Server, | ||
{ | ||
hostOS: LTSC2022, | ||
ctrOS: LTSC2022, | ||
shouldRun: true, | ||
}, | ||
"Wind11Host_ltsc2019": { | ||
hostOs: V22H2Win11, | ||
ctrOs: RS5, | ||
{ | ||
hostOS: V22H2Win11, | ||
ctrOS: LTSC2019, | ||
shouldRun: false, | ||
}, | ||
"Wind11Host_ltsc2022": { | ||
hostOs: V22H2Win11, | ||
ctrOs: V21H2Server, | ||
{ | ||
hostOS: V22H2Win11, | ||
ctrOS: LTSC2022, | ||
shouldRun: true, | ||
}, | ||
{ | ||
hostOS: LTSC2025, | ||
ctrOS: LTSC2022, | ||
shouldRun: true, | ||
}, | ||
{ | ||
hostOS: LTSC2022, | ||
ctrOS: LTSC2025, | ||
shouldRun: false, | ||
}, | ||
{ | ||
hostOS: LTSC2022, | ||
ctrOS: V22H2Win11, | ||
shouldRun: false, | ||
}, | ||
{ | ||
hostOS: LTSC2025, | ||
ctrOS: V22H2Win11, | ||
shouldRun: true, | ||
}, | ||
} { | ||
// Check if ltsc2019/ltsc2022 guest images are compatible on | ||
// the given host OS versions | ||
// | ||
hostOSVersion := OSVersion{ | ||
MajorVersion: 10, | ||
MinorVersion: 0, | ||
Build: tc.hostOs, | ||
} | ||
ctrOSVersion := OSVersion{ | ||
MajorVersion: 10, | ||
MinorVersion: 0, | ||
Build: tc.ctrOs, | ||
} | ||
if CheckHostAndContainerCompat(hostOSVersion, ctrOSVersion) != tc.shouldRun { | ||
var expectedResultStr string | ||
if !tc.shouldRun { | ||
expectedResultStr = " NOT" | ||
t.Run(fmt.Sprintf("Host_%d_Ctr_%d", tc.hostOS, tc.ctrOS), func(t *testing.T) { | ||
hostOSVersion := OSVersion{ | ||
MajorVersion: 10, | ||
MinorVersion: 0, | ||
Build: tc.hostOS, | ||
} | ||
ctrOSVersion := OSVersion{ | ||
MajorVersion: 10, | ||
MinorVersion: 0, | ||
Build: tc.ctrOS, | ||
} | ||
if CheckHostAndContainerCompat(hostOSVersion, ctrOSVersion) != tc.shouldRun { | ||
var expectedResultStr string | ||
if !tc.shouldRun { | ||
expectedResultStr = " NOT" | ||
} | ||
t.Fatalf("host %v should%s be able to run guest %v", tc.hostOS, expectedResultStr, tc.ctrOS) | ||
} | ||
t.Fatalf("Failed %v: host %v should%s be able to run guest %v", testName, tc.hostOs, expectedResultStr, tc.ctrOs) | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters