Add logs to try to diagnose #17181
This commit is contained in:
		| @@ -70,16 +70,17 @@ func installPluginUnderTest(t *testing.T, vendorName, testPluginPath, plugName s | ||||
| 	pluginDir := path.Join(testPluginPath, vendoredName) | ||||
| 	err := os.MkdirAll(pluginDir, 0777) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("Failed to create plugin: %v", err) | ||||
| 		t.Errorf("Failed to create plugin dir %q: %v", pluginDir, err) | ||||
| 	} | ||||
| 	pluginExec := path.Join(pluginDir, plugName) | ||||
| 	f, err := os.Create(pluginExec) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("Failed to install plugin") | ||||
| 		t.Errorf("Failed to install plugin %q: %v", pluginExec, err) | ||||
| 	} | ||||
| 	defer f.Close() | ||||
| 	err = f.Chmod(0777) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("Failed to set exec perms on plugin") | ||||
| 		t.Errorf("Failed to set exec perms on plugin %q: %v", pluginExec, err) | ||||
| 	} | ||||
| 	const execScriptTempl = `#!/bin/bash | ||||
|  | ||||
| @@ -91,7 +92,7 @@ if [ "$1" == "status" ]; then | ||||
| fi | ||||
|  | ||||
| # Direct the arguments to a file to be tested against later | ||||
| echo -n $@ &> {{.OutputFile}} | ||||
| echo -n "$@" &> {{.OutputFile}} | ||||
| ` | ||||
| 	if execTemplateData == nil { | ||||
| 		execTemplateData = &map[string]interface{}{ | ||||
| @@ -103,14 +104,13 @@ echo -n $@ &> {{.OutputFile}} | ||||
| 	tObj := template.Must(template.New("test").Parse(execScriptTempl)) | ||||
| 	buf := &bytes.Buffer{} | ||||
| 	if err := tObj.Execute(buf, *execTemplateData); err != nil { | ||||
| 		t.Errorf("Error in executing script template - %v", err) | ||||
| 		t.Errorf("Error in executing script template: %v", err) | ||||
| 	} | ||||
| 	execScript := buf.String() | ||||
| 	_, err = f.WriteString(execScript) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("Failed to write plugin exec") | ||||
| 		t.Errorf("Failed to write plugin %q: %v", pluginExec, err) | ||||
| 	} | ||||
| 	f.Close() | ||||
| } | ||||
|  | ||||
| func tearDownPlugin(testPluginPath string) { | ||||
| @@ -313,19 +313,23 @@ func TestPluginStatusHookIPv6(t *testing.T) { | ||||
| 	installPluginUnderTest(t, "", testPluginPath, pluginName, execTemplate) | ||||
|  | ||||
| 	plug, err := network.InitNetworkPlugin(ProbeNetworkPlugins(testPluginPath), pluginName, network.NewFakeHost(nil)) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("InitNetworkPlugin() failed: %v", err) | ||||
| 	} | ||||
|  | ||||
| 	ip, err := plug.Status("namespace", "name", "dockerid2345") | ||||
| 	if err != nil { | ||||
| 		t.Errorf("Expected nil got %v", err) | ||||
| 		t.Errorf("Status() failed: %v", err) | ||||
| 	} | ||||
| 	// check output of status hook | ||||
| 	output, err := ioutil.ReadFile(path.Join(testPluginPath, pluginName, pluginName+".out")) | ||||
| 	outPath := path.Join(testPluginPath, pluginName, pluginName+".out") | ||||
| 	output, err := ioutil.ReadFile(outPath) | ||||
| 	if err != nil { | ||||
| 		t.Errorf("Expected nil") | ||||
| 		t.Errorf("ReadFile(%q) failed: %v", outPath, err) | ||||
| 	} | ||||
| 	expectedOutput := "status namespace name dockerid2345" | ||||
| 	if string(output) != expectedOutput { | ||||
| 		t.Errorf("Mismatch in expected output for status hook. Expected '%s', got '%s'", expectedOutput, string(output)) | ||||
| 		t.Errorf("Mismatch in expected output for status hook. Expected %q, got %q", expectedOutput, string(output)) | ||||
| 	} | ||||
| 	if ip.IP.String() != "fe80::e2cb:4eff:fef9:6710" { | ||||
| 		t.Errorf("Mismatch in expected output for status hook. Expected 'fe80::e2cb:4eff:fef9:6710', got '%s'", ip.IP.String()) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Tim Hockin
					Tim Hockin