@@ -20,7 +20,17 @@ func TestPreflights(t *testing.T) {
2020 })
2121 defer tc .Cleanup ()
2222
23- _ , stderr , err := tc .RunCommandOnNode (0 , []string {"apt-get update && apt-get install -y apt-utils netcat-traditional" })
23+ // set up incorrect permissions on data dir and parent dir
24+ _ , stderr , err := tc .RunCommandOnNode (0 , []string {
25+ "mkdir -p /var/lib/embedded-cluster && " +
26+ "chmod 744 /var/lib/embedded-cluster && " + // remove execute from data dir
27+ "chmod 744 /var/lib" , // remove execute from parent dir
28+ })
29+ if err != nil {
30+ t .Fatalf ("failed to adjust dir permissions: err=%v, stderr=%s" , err , stderr )
31+ }
32+
33+ _ , stderr , err = tc .RunCommandOnNode (0 , []string {"apt-get update && apt-get install -y apt-utils netcat-traditional" })
2434 if err != nil {
2535 t .Fatalf ("failed to install deps: err=%v, stderr=%s" , err , stderr )
2636 }
@@ -95,6 +105,7 @@ func TestPreflights(t *testing.T) {
95105 "Kubelet Port Availability" : true ,
96106 "Calico Communication Port Availability" : true ,
97107 "Local Artifact Mirror Port Availability" : true ,
108+ "Data Directory Permissions" : true ,
98109 // as long as fio ran successfully, we're good
99110 "Filesystem Write Latency" : true ,
100111 }
@@ -142,6 +153,33 @@ func TestPreflights(t *testing.T) {
142153 }
143154 },
144155 },
156+ {
157+ name : "Should contain data directory permissions failures" ,
158+ assert : func (t * testing.T , results * types.Output ) {
159+ for _ , res := range results .Fail {
160+ if res .Title == "Data Directory Permissions" {
161+ // should not contain data dir as we automatically fix it
162+ if strings .Contains (res .Message , "/var/lib/embedded-cluster" ) {
163+ t .Errorf ("failure message should not contain /var/lib/embedded-cluster directory: %s" , res .Message )
164+ }
165+ // should contain parent dir as we don't automatically fix it
166+ if ! strings .Contains (res .Message , "/var/lib." ) {
167+ t .Errorf ("failure message should contain /var/lib directory: %s" , res .Message )
168+ }
169+ t .Logf ("directory permissions check failed as expected: %s" , res .Message )
170+ return
171+ }
172+ }
173+ // If we get here, check if it incorrectly passed
174+ for _ , res := range results .Pass {
175+ if res .Title == "Data Directory Permissions" {
176+ t .Errorf ("directory permissions check passed unexpectedly: %s" , res .Message )
177+ return
178+ }
179+ }
180+ t .Errorf ("directory permissions check not found in results" )
181+ },
182+ },
145183 }
146184 for _ , tt := range tests {
147185 t .Run (tt .name , func (t * testing.T ) {
0 commit comments