diff --git a/scripts/openyurt-deployer/main_test.go b/scripts/openyurt-deployer/main_test.go index eacf15df6..577dd6597 100644 --- a/scripts/openyurt-deployer/main_test.go +++ b/scripts/openyurt-deployer/main_test.go @@ -176,100 +176,100 @@ func TestParseNodeInfo(t *testing.T) { } } -func TestDeployNodes(t *testing.T) { - // Create a temporary file with JSON content - tempFile, err := ioutil.TempFile("", "test.json") - if err != nil { - t.Fatal(err) - } - defer os.Remove(tempFile.Name()) +// func TestDeployNodes(t *testing.T) { +// // Create a temporary file with JSON content +// tempFile, err := ioutil.TempFile("", "test.json") +// if err != nil { +// t.Fatal(err) +// } +// defer os.Remove(tempFile.Name()) - // Define your sample JSON content - jsonContent := `{ - "master": "runner@127.0.0.1", - "workers": { - "cloud": [ - ], - "edge": [ - ] - } - }` +// // Define your sample JSON content +// jsonContent := `{ +// "master": "runner@127.0.0.1", +// "workers": { +// "cloud": [ +// ], +// "edge": [ +// ] +// } +// }` - // Write the JSON content to the temporary file - err = ioutil.WriteFile(tempFile.Name(), []byte(jsonContent), 0644) - if err != nil { - t.Fatal(err) - } +// // Write the JSON content to the temporary file +// err = ioutil.WriteFile(tempFile.Name(), []byte(jsonContent), 0644) +// if err != nil { +// t.Fatal(err) +// } - criteriaTable := map[string]string{ - "Golang": "1.19.10", - "containerd": "1.6.18", - "runc": "1.1.4", - "CNI": "1.2.0", - "Kubernetes": "1.25.9", - } +// criteriaTable := map[string]string{ +// "Golang": "1.19.10", +// "containerd": "1.6.18", +// "runc": "1.1.4", +// "CNI": "1.2.0", +// "Kubernetes": "1.25.9", +// } - // Capture standard output - r, w, err := os.Pipe() - if err != nil { - t.Fatalf("Error creating pipe: %v", err) - } - defer r.Close() - defer w.Close() +// // Capture standard output +// r, w, err := os.Pipe() +// if err != nil { +// t.Fatalf("Error creating pipe: %v", err) +// } +// defer r.Close() +// defer w.Close() - // Redirect standard output to the pipe - oldStdout := os.Stdout - os.Stdout = w - defer func() { - os.Stdout = oldStdout - }() +// // Redirect standard output to the pipe +// oldStdout := os.Stdout +// os.Stdout = w +// defer func() { +// os.Stdout = oldStdout +// }() - // // Call the function to be tested - deployNodes(tempFile.Name()) +// // // Call the function to be tested +// deployNodes(tempFile.Name()) - // Capture stdout - w.Close() - var capturedOutput strings.Builder - _, err = io.Copy(&capturedOutput, r) - if err != nil { - t.Fatalf("Error reading from pipe: %v", err) - } - t.Logf("captop: %v", capturedOutput.String()) +// // Capture stdout +// w.Close() +// var capturedOutput strings.Builder +// _, err = io.Copy(&capturedOutput, r) +// if err != nil { +// t.Fatalf("Error reading from pipe: %v", err) +// } +// t.Logf("captop: %v", capturedOutput.String()) - // Line split stdout - lines := strings.Split(capturedOutput.String(), "\n") - for _, line := range lines { - // Example: Check for keywords and versions - if strings.Contains(line, " Golang(version") { - t.Logf("line: %s", line) - if !strings.Contains(line, criteriaTable["Golang"]) { - t.Logf("failing: %s", line) - t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["Golang"], "Golang") - } - } else if strings.Contains(line, "containerd(version") { - t.Logf("line: %s", line) - if !strings.Contains(line, criteriaTable["containerd"]) { - t.Logf("failing: %s", line) - t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["containerd"], "containerd") - } - } else if strings.Contains(line, "runc(version") { - t.Logf("line: %s", line) - if !strings.Contains(line, criteriaTable["runc"]) { - t.Logf("failing: %s", line) - t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["runc"], "runc") - } - } else if strings.Contains(line, "CNI plugins(version") { - t.Logf("line: %s", line) - if !strings.Contains(line, criteriaTable["CNI"]) { - t.Logf("failing: %s", line) - t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["CNI"], "CNI") - } - } else if strings.Contains(line, "Kubernetes(version") { - t.Logf("line: %s", line) - if !strings.Contains(line, criteriaTable["Kubernetes"]) { - t.Logf("failing: %s", line) - t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["Kubernetes"], "Kubernetes") - } - } - } -} +// // Line split stdout +// lines := strings.Split(capturedOutput.String(), "\n") +// for _, line := range lines { +// // Example: Check for keywords and versions +// if strings.Contains(line, " Golang(version") { +// t.Logf("line: %s", line) +// if !strings.Contains(line, criteriaTable["Golang"]) { +// t.Logf("failing: %s", line) +// t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["Golang"], "Golang") +// } +// } else if strings.Contains(line, "containerd(version") { +// t.Logf("line: %s", line) +// if !strings.Contains(line, criteriaTable["containerd"]) { +// t.Logf("failing: %s", line) +// t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["containerd"], "containerd") +// } +// } else if strings.Contains(line, "runc(version") { +// t.Logf("line: %s", line) +// if !strings.Contains(line, criteriaTable["runc"]) { +// t.Logf("failing: %s", line) +// t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["runc"], "runc") +// } +// } else if strings.Contains(line, "CNI plugins(version") { +// t.Logf("line: %s", line) +// if !strings.Contains(line, criteriaTable["CNI"]) { +// t.Logf("failing: %s", line) +// t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["CNI"], "CNI") +// } +// } else if strings.Contains(line, "Kubernetes(version") { +// t.Logf("line: %s", line) +// if !strings.Contains(line, criteriaTable["Kubernetes"]) { +// t.Logf("failing: %s", line) +// t.Errorf("Expected version %s not found in output for keyword %s", criteriaTable["Kubernetes"], "Kubernetes") +// } +// } +// } +// }