1+ /*
2+ * Copyright (c) 2023, NVIDIA CORPORATION. All rights reserved.
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
116package templates
217
318import (
@@ -11,8 +26,8 @@ import (
1126func TestNewContainerd_Defaults (t * testing.T ) {
1227 env := v1alpha1.Environment {}
1328 c := NewContainerd (env )
14- if c .Version != "1.7.26 " {
15- t .Errorf ("expected default Version to be '1.7.26 ', got '%s'" , c .Version )
29+ if c .Version != "1.7.28 " {
30+ t .Errorf ("expected default Version to be '1.7.28 ', got '%s'" , c .Version )
1631 }
1732}
1833
@@ -39,8 +54,8 @@ func TestNewContainerd_EmptyVersion(t *testing.T) {
3954 },
4055 }
4156 c := NewContainerd (env )
42- if c .Version != "1.7.26 " {
43- t .Errorf ("expected default Version to be '1.7.26 ' when empty, got '%s'" , c .Version )
57+ if c .Version != "1.7.28 " {
58+ t .Errorf ("expected default Version to be '1.7.28 ' when empty, got '%s'" , c .Version )
4459 }
4560}
4661
@@ -74,26 +89,29 @@ func TestContainerd_Execute_Version1(t *testing.T) {
7489 }
7590 out := buf .String ()
7691
77- // Test version detection
78- if ! strings .Contains (out , "MAJOR_VERSION=$(echo $CONTAINERD_VERSION | cut -d. -f1)" ) {
79- t .Error ("template output missing version detection" )
80- }
81-
82- // Test 1.x specific configuration
83- if ! strings .Contains (out , "version = 1" ) {
84- t .Error ("template output missing version 1 configuration" )
92+ // Test unified configuration (we now use version = 2 for all containerd versions)
93+ if ! strings .Contains (out , "version = 2" ) {
94+ t .Error ("template output missing version 2 configuration" )
8595 }
86- if ! strings .Contains (out , "runtime_type = \" io.containerd.runtime.v1.linux \" " ) {
87- t .Error ("template output missing 1.x runtime configuration" )
96+ if ! strings .Contains (out , "runtime_type = \" io.containerd.runc.v2 \" " ) {
97+ t .Error ("template output missing runc v2 runtime configuration" )
8898 }
8999
90100 // Test common configuration
91- if ! strings .Contains (out , "systemd_cgroup = true" ) {
92- t .Error ("template output missing systemd cgroup configuration" )
101+ if ! strings .Contains (out , "SystemdCgroup = true" ) {
102+ t .Error ("template output missing SystemdCgroup configuration" )
93103 }
94104 if ! strings .Contains (out , "sandbox_image = \" registry.k8s.io/pause:3.9\" " ) {
95105 t .Error ("template output missing sandbox image configuration" )
96106 }
107+
108+ // Test CNI configuration
109+ if ! strings .Contains (out , "bin_dir = \" /opt/cni/bin:/usr/libexec/cni\" " ) {
110+ t .Error ("template output missing CNI bin_dir configuration" )
111+ }
112+ if ! strings .Contains (out , "conf_dir = \" /etc/cni/net.d\" " ) {
113+ t .Error ("template output missing CNI conf_dir configuration" )
114+ }
97115}
98116
99117func TestContainerd_Execute_Version2 (t * testing.T ) {
@@ -112,26 +130,29 @@ func TestContainerd_Execute_Version2(t *testing.T) {
112130 }
113131 out := buf .String ()
114132
115- // Test version detection
116- if ! strings .Contains (out , "MAJOR_VERSION=$(echo $CONTAINERD_VERSION | cut -d. -f1)" ) {
117- t .Error ("template output missing version detection" )
118- }
119-
120- // Test 2.x specific configuration
133+ // Test unified configuration (we now use version = 2 for all containerd versions)
121134 if ! strings .Contains (out , "version = 2" ) {
122135 t .Error ("template output missing version 2 configuration" )
123136 }
124137 if ! strings .Contains (out , "runtime_type = \" io.containerd.runc.v2\" " ) {
125- t .Error ("template output missing 2.x runtime configuration" )
138+ t .Error ("template output missing runc v2 runtime configuration" )
126139 }
127140
128141 // Test common configuration
129- if ! strings .Contains (out , "systemd_cgroup = true" ) {
130- t .Error ("template output missing systemd cgroup configuration" )
142+ if ! strings .Contains (out , "SystemdCgroup = true" ) {
143+ t .Error ("template output missing SystemdCgroup configuration" )
131144 }
132145 if ! strings .Contains (out , "sandbox_image = \" registry.k8s.io/pause:3.9\" " ) {
133146 t .Error ("template output missing sandbox image configuration" )
134147 }
148+
149+ // Test CNI configuration
150+ if ! strings .Contains (out , "bin_dir = \" /opt/cni/bin:/usr/libexec/cni\" " ) {
151+ t .Error ("template output missing CNI bin_dir configuration" )
152+ }
153+ if ! strings .Contains (out , "conf_dir = \" /etc/cni/net.d\" " ) {
154+ t .Error ("template output missing CNI conf_dir configuration" )
155+ }
135156}
136157
137158func TestContainerd_Execute_SystemChecks (t * testing.T ) {
0 commit comments