-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve socat conn success detection
It appears that Go's MatchReader() returns true only if some new lines are written to the writer after the searched word. It mostly all right because socat actually writes several more lines to stderr. However this new implementation is better it should signal immediately when searched patter is written to the writer. Signed-off-by: Matej Vašek <[email protected]>
- Loading branch information
1 parent
42ed4d8
commit 783cd20
Showing
2 changed files
with
88 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package k8s | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
) | ||
|
||
func TestDetectSocatSuccess(t *testing.T) { | ||
ch := make(chan struct{}, 1) | ||
w := detectConnSuccess(ch) | ||
_, err := w.Write([]byte("some data successucces")) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
_, err = w.Write([]byte("sfully connected")) | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
select { | ||
case <-ch: | ||
t.Log("OK") | ||
case <-time.After(time.Millisecond * 100): | ||
t.Error("NOK") | ||
} | ||
} |