forked from projectcontour/contour
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
internal: test reliability improvements (projectcontour#2780)
* Switch from shutting down gRPC server with `Stop()` to `GracefulStop()`. which waits for current requests to drain before returning. This means that tests which log to the test runner won't ever attempt to log after the test has completed. * Hoist test loggers into the fixtures package and use them from there. * Add a workgroup context cancellation test. This updates projectcontour#2775. Signed-off-by: James Peach <jpeach@vmware.com>
- Loading branch information
Showing
7 changed files
with
83 additions
and
47 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
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
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,36 @@ | ||
package fixture | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/sirupsen/logrus" | ||
) | ||
|
||
type testWriter struct { | ||
*testing.T | ||
} | ||
|
||
func (t *testWriter) Write(buf []byte) (int, error) { | ||
t.Logf("%s", buf) | ||
return len(buf), nil | ||
} | ||
|
||
// NewTestLogger returns logrus.Logger that writes messages using (*testing.T)Logf. | ||
func NewTestLogger(t *testing.T) *logrus.Logger { | ||
log := logrus.New() | ||
log.Out = &testWriter{t} | ||
return log | ||
} | ||
|
||
type discardWriter struct{} | ||
|
||
func (d *discardWriter) Write(buf []byte) (int, error) { | ||
return len(buf), nil | ||
} | ||
|
||
// NewDiscardLogger returns logrus.Logger that discards log messages. | ||
func NewDiscardLogger() *logrus.Logger { | ||
log := logrus.New() | ||
log.Out = &discardWriter{} | ||
return log | ||
} |
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