mirror of https://github.com/k3s-io/k3s
Merge pull request #20004 from thockin/logs-for-17181-flake
Add logs to try to diagnose #17181pull/6/head
commit
1087803e12
|
@ -70,16 +70,17 @@ func installPluginUnderTest(t *testing.T, vendorName, testPluginPath, plugName s
|
||||||
pluginDir := path.Join(testPluginPath, vendoredName)
|
pluginDir := path.Join(testPluginPath, vendoredName)
|
||||||
err := os.MkdirAll(pluginDir, 0777)
|
err := os.MkdirAll(pluginDir, 0777)
|
||||||
if err != nil {
|
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)
|
pluginExec := path.Join(pluginDir, plugName)
|
||||||
f, err := os.Create(pluginExec)
|
f, err := os.Create(pluginExec)
|
||||||
if err != nil {
|
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)
|
err = f.Chmod(0777)
|
||||||
if err != nil {
|
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
|
const execScriptTempl = `#!/bin/bash
|
||||||
|
|
||||||
|
@ -91,7 +92,7 @@ if [ "$1" == "status" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Direct the arguments to a file to be tested against later
|
# Direct the arguments to a file to be tested against later
|
||||||
echo -n $@ &> {{.OutputFile}}
|
echo -n "$@" &> {{.OutputFile}}
|
||||||
`
|
`
|
||||||
if execTemplateData == nil {
|
if execTemplateData == nil {
|
||||||
execTemplateData = &map[string]interface{}{
|
execTemplateData = &map[string]interface{}{
|
||||||
|
@ -103,14 +104,13 @@ echo -n $@ &> {{.OutputFile}}
|
||||||
tObj := template.Must(template.New("test").Parse(execScriptTempl))
|
tObj := template.Must(template.New("test").Parse(execScriptTempl))
|
||||||
buf := &bytes.Buffer{}
|
buf := &bytes.Buffer{}
|
||||||
if err := tObj.Execute(buf, *execTemplateData); err != nil {
|
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()
|
execScript := buf.String()
|
||||||
_, err = f.WriteString(execScript)
|
_, err = f.WriteString(execScript)
|
||||||
if err != nil {
|
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) {
|
func tearDownPlugin(testPluginPath string) {
|
||||||
|
@ -313,19 +313,23 @@ func TestPluginStatusHookIPv6(t *testing.T) {
|
||||||
installPluginUnderTest(t, "", testPluginPath, pluginName, execTemplate)
|
installPluginUnderTest(t, "", testPluginPath, pluginName, execTemplate)
|
||||||
|
|
||||||
plug, err := network.InitNetworkPlugin(ProbeNetworkPlugins(testPluginPath), pluginName, network.NewFakeHost(nil))
|
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")
|
ip, err := plug.Status("namespace", "name", "dockerid2345")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Errorf("Expected nil got %v", err)
|
t.Errorf("Status() failed: %v", err)
|
||||||
}
|
}
|
||||||
// check output of status hook
|
// 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 {
|
if err != nil {
|
||||||
t.Errorf("Expected nil")
|
t.Errorf("ReadFile(%q) failed: %v", outPath, err)
|
||||||
}
|
}
|
||||||
expectedOutput := "status namespace name dockerid2345"
|
expectedOutput := "status namespace name dockerid2345"
|
||||||
if string(output) != expectedOutput {
|
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" {
|
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())
|
t.Errorf("Mismatch in expected output for status hook. Expected 'fe80::e2cb:4eff:fef9:6710', got '%s'", ip.IP.String())
|
||||||
|
|
Loading…
Reference in New Issue