@@ -1884,8 +1884,8 @@ func TestMIGManager(t *testing.T) {
18841884 }
18851885}
18861886
1887- // TestDriverPrecompiledLibModules tests that /lib/modules is mounted when precompiled drivers are used
1888- func TestDriverPrecompiledLibModules (t * testing.T ) {
1887+ // TestDriverPrecompiledLibModulesUbuntu tests that /lib/modules is NOT mounted for precompiled drivers on Ubuntu
1888+ func TestDriverPrecompiledLibModulesUbuntu (t * testing.T ) {
18891889 cp := getDriverTestInput ("precompiled" )
18901890 output := getDriverTestOutput ("precompiled" )
18911891
@@ -1895,29 +1895,17 @@ func TestDriverPrecompiledLibModules(t *testing.T) {
18951895 }
18961896 require .NotNil (t , ds )
18971897
1898- // Check for /lib/modules volume and mount
1899- foundVolume := false
1898+ // Check that /lib/modules volume and mount are NOT present
19001899 for _ , vol := range ds .Spec .Template .Spec .Volumes {
1901- if vol .Name == "lib-modules" {
1902- foundVolume = true
1903- require .NotNil (t , vol .HostPath )
1904- require .Equal (t , "/lib/modules" , vol .HostPath .Path )
1905- }
1900+ require .NotEqual (t , "lib-modules" , vol .Name , "lib-modules volume should not be present for ubuntu" )
19061901 }
1907- require .True (t , foundVolume , "lib-modules volume not found for precompiled drivers" )
19081902
1909- foundMount := false
19101903 driverContainer := findContainerByName (ds .Spec .Template .Spec .Containers , "nvidia-driver-ctr" )
19111904 require .NotNil (t , driverContainer )
19121905
19131906 for _ , mount := range driverContainer .VolumeMounts {
1914- if mount .Name == "lib-modules" {
1915- foundMount = true
1916- require .Equal (t , "/run/host/lib/modules" , mount .MountPath )
1917- require .True (t , mount .ReadOnly )
1918- }
1907+ require .NotEqual (t , "lib-modules" , mount .Name , "lib-modules volume mount should not be present for ubuntu" )
19191908 }
1920- require .True (t , foundMount , "lib-modules volume mount not found for precompiled drivers" )
19211909
19221910 // Cleanup
19231911 err = removeState (& clusterPolicyController , clusterPolicyController .idx - 1 )
@@ -1926,3 +1914,60 @@ func TestDriverPrecompiledLibModules(t *testing.T) {
19261914 }
19271915 clusterPolicyController .idx --
19281916}
1917+
1918+ // TestDriverPrecompiledLibModulesSuse tests that /lib/modules is mounted for precompiled drivers on SLES and SL-Micro
1919+ func TestDriverPrecompiledLibModulesSuse (t * testing.T ) {
1920+ osTags := []string {"sles16.0" , "sl-micro6.1" }
1921+
1922+ for _ , osTag := range osTags {
1923+ t .Run (osTag , func (t * testing.T ) {
1924+ // Save original OS tag and restore after test
1925+ originalOSTag := clusterPolicyController .gpuNodeOSTag
1926+ defer func () {
1927+ clusterPolicyController .gpuNodeOSTag = originalOSTag
1928+ }()
1929+
1930+ clusterPolicyController .gpuNodeOSTag = osTag
1931+
1932+ cp := getDriverTestInput ("precompiled" )
1933+ output := getDriverTestOutput ("precompiled" )
1934+
1935+ ds , err := testDaemonsetCommon (t , cp , "Driver" , output ["numDaemonsets" ].(int ))
1936+ if err != nil {
1937+ t .Fatalf ("error in testDaemonsetCommon(): %v" , err )
1938+ }
1939+ require .NotNil (t , ds )
1940+
1941+ // Check for /lib/modules volume and mount
1942+ foundVolume := false
1943+ for _ , vol := range ds .Spec .Template .Spec .Volumes {
1944+ if vol .Name == "lib-modules" {
1945+ foundVolume = true
1946+ require .NotNil (t , vol .HostPath )
1947+ require .Equal (t , "/lib/modules" , vol .HostPath .Path )
1948+ }
1949+ }
1950+ require .Truef (t , foundVolume , "lib-modules volume not found for precompiled drivers on %s" , osTag )
1951+
1952+ foundMount := false
1953+ driverContainer := findContainerByName (ds .Spec .Template .Spec .Containers , "nvidia-driver-ctr" )
1954+ require .NotNil (t , driverContainer )
1955+
1956+ for _ , mount := range driverContainer .VolumeMounts {
1957+ if mount .Name == "lib-modules" {
1958+ foundMount = true
1959+ require .Equal (t , "/run/host/lib/modules" , mount .MountPath )
1960+ require .True (t , mount .ReadOnly )
1961+ }
1962+ }
1963+ require .Truef (t , foundMount , "lib-modules volume mount not found for precompiled drivers on %s" , osTag )
1964+
1965+ // Cleanup
1966+ err = removeState (& clusterPolicyController , clusterPolicyController .idx - 1 )
1967+ if err != nil {
1968+ t .Fatalf ("error removing state %v:" , err )
1969+ }
1970+ clusterPolicyController .idx --
1971+ })
1972+ }
1973+ }
0 commit comments