@@ -121,45 +121,54 @@ func runDumpCmd(args ...string) (string, error) {
121
121
}
122
122
123
123
func TestKmeshctlDump (t * testing.T ) {
124
- pod := findKmeshPod (t )
125
- waitForPodRunning (t , pod )
126
-
127
-
128
- t .Run ("kernel-native" , func (t * testing.T ) {
129
- out , err := runDumpCmd (pod , "kernel-native" )
130
- t .Logf ("Output of 'kmeshctl dump %s kernel-native':\n %s" , pod , out )
131
- if err != nil {
132
- t .Fatalf ("dump kernel-native failed: %v" , err )
133
- }
134
- if strings .TrimSpace (out ) == "" {
135
- t .Errorf ("expected non-empty output for kernel-native, got empty" )
136
- }
137
- })
138
-
139
-
140
- t .Run ("dual-engine" , func (t * testing.T ) {
141
- out , err := runDumpCmd (pod , "dual-engine" )
142
- t .Logf ("Output of 'kmeshctl dump %s dual-engine':\n %s" , pod , out )
143
- if err != nil {
144
- t .Fatalf ("dump dual-engine failed: %v" , err )
145
- }
146
- if strings .TrimSpace (out ) == "" {
147
- t .Errorf ("expected non-empty output for dual-engine, got empty" )
148
- }
149
- })
150
-
151
-
152
- t .Run ("invalid-mode" , func (t * testing.T ) {
153
- out , err := runDumpCmd (pod , "invalid-mode" )
154
- t .Logf ("Output of 'kmeshctl dump %s invalid-mode':\n %s" , pod , out )
155
- if err == nil {
156
- t .Fatal ("expected error for invalid mode, but command succeeded" )
157
- }
158
- if ! strings .Contains (out , "Argument must be 'kernel-native' or 'dual-engine'" ) {
159
- t .Errorf ("expected error message about valid modes, got:\n %s" , out )
160
- }
161
- })
162
- }
124
+ pod := findKmeshPod (t )
125
+ waitForPodRunning (t , pod )
126
+
127
+ t .Run ("kernel-native" , func (t * testing.T ) {
128
+ out , err := runDumpCmd (pod , "kernel-native" )
129
+ t .Logf ("Output of 'kmeshctl dump %s kernel-native':\n %s" , pod , out )
130
+
131
+ if strings .Contains (out , "Invalid Client Mode" ) {
132
+ t .Log ("kernel-native not supported; got expected error" )
133
+ return
134
+ }
135
+
136
+ if err != nil {
137
+ t .Fatalf ("dump kernel-native failed: %v" , err )
138
+ }
139
+ if ! strings .Contains (out , `"mode":"kernel-native"` ) {
140
+ t .Errorf ("expected JSON to contain \" mode\" :\" kernel-native\" , got:\n %s" , out )
141
+ }
142
+ if ! strings .Contains (out , `"workloads"` ) {
143
+ t .Errorf ("expected JSON to contain \" workloads\" array, got:\n %s" , out )
144
+ }
145
+ })
146
+
147
+ t .Run ("dual-engine" , func (t * testing.T ) {
148
+ out , err := runDumpCmd (pod , "dual-engine" )
149
+ t .Logf ("Output of 'kmeshctl dump %s dual-engine':\n %s" , pod , out )
150
+ if err != nil {
151
+ t .Fatalf ("dump dual-engine failed: %v\n %s" , err , out )
152
+ }
153
+ if ! strings .Contains (out , `"mode":"dual-engine"` ) {
154
+ t .Errorf ("expected JSON to contain \" mode\" :\" dual-engine\" , got:\n %s" , out )
155
+ }
156
+ if ! strings .Contains (out , `"services"` ) {
157
+ t .Errorf ("expected JSON to contain \" services\" array, got:\n %s" , out )
158
+ }
159
+ })
160
+
161
+ t .Run ("invalid-mode" , func (t * testing.T ) {
162
+ out , err := runDumpCmd (pod , "invalid-mode" )
163
+ t .Logf ("Output of 'kmeshctl dump %s invalid-mode':\n %s" , pod , out )
164
+ if err == nil {
165
+ t .Fatal ("expected error for invalid mode, but command succeeded" )
166
+ }
167
+ if ! strings .Contains (out , "Argument must be 'kernel-native' or 'dual-engine'" ) {
168
+ t .Errorf ("expected usage error, got:\n %s" , out )
169
+ }
170
+ })
171
+ }
163
172
164
173
func runAccesslogCmd (args ... string ) (string , error ) {
165
174
cmdArgs := append ([]string {"monitoring" }, args ... )
0 commit comments