Skip to content

Commit b521d26

Browse files
debug: minor changes in code
code Signed-off-by: Jyoti-Prakash-Muddanna <[email protected]>
1 parent 92bb138 commit b521d26

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

src/cloud-api-adaptor/test/e2e/libvirt_common.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -122,27 +122,37 @@ func (l LibvirtAssert) VerifyPodvmConsole(t *testing.T, podvmName, expectedStrin
122122
}
123123

124124
stream, err := l.conn.NewStream(0)
125-
if err != nil {
126-
t.Errorf("Failed to create stream : %v", err)
125+
for err != nil {
126+
t.Logf("Warning: Failed to create stream : %v", err)
127127
}
128128

129129
defer stream.Free()
130130

131131
err = dom.OpenConsole("", stream, libvirt.DOMAIN_CONSOLE_FORCE)
132+
start := time.Now()
133+
duration := 1 * time.Minute
134+
for err != nil && time.Since(start) < duration {
135+
t.Logf("Warning: Failed to open console : %v", err)
136+
err = dom.OpenConsole("", stream, libvirt.DOMAIN_CONSOLE_FORCE)
137+
}
138+
132139
if err != nil {
133-
t.Errorf("Failed to open console : %v", err)
140+
t.Logf("Warning: Failed to open console after retries : %v", err)
141+
return
134142
}
135143

136144
buf := make([]byte, 4096)
137145
var output strings.Builder
138146
var LibvirtLog = ""
139147

140-
start := time.Now()
141-
duration := 3 * time.Minute
148+
start = time.Now()
149+
duration = 3 * time.Minute
150+
maxBytes := 0
142151

143152
for time.Since(start) < duration {
144153
n, err := stream.Recv(buf)
145-
if n > 0 {
154+
if maxBytes < n {
155+
maxBytes = n
146156
output.Write(buf[:n])
147157
if len(output.String()) > len(LibvirtLog) {
148158
LibvirtLog = output.String()
@@ -154,11 +164,10 @@ func (l LibvirtAssert) VerifyPodvmConsole(t *testing.T, podvmName, expectedStrin
154164
}
155165
if err != nil && LibvirtLog != "" {
156166
t.Logf("Warning: Did not find expected String :%s in \n console :%s", expectedString, LibvirtLog)
157-
return
158167
} else if err != nil {
159168
t.Logf("Warning: Did not receive any data from console yet, err: %v", err)
160169
}
161-
time.Sleep(6 * time.Second)
170+
time.Sleep(1 * time.Second)
162171
}
163172

164173
t.Logf("Warning: Timed out waiting for expected String :%s in \n console :%s", expectedString, LibvirtLog)

0 commit comments

Comments
 (0)