-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ENV variables to configure GRPC Keep Alive Time
Signed-off-by: Bhavika Sharma <bsharma@splunk.com>
- Loading branch information
1 parent
43fe01a
commit b7b051f
Showing
7 changed files
with
71 additions
and
7 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package common | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
// Test env var not set for EnvGRPCKeepAliveMin | ||
func Test_GRPCKeepAliveMinNotSet(t *testing.T) { | ||
grpcKeepAliveMin := GetGRPCKeepAliveEnforcementMinimum() | ||
grpcKeepAliveExpectedMin := defaultGRPCKeepAliveEnforcementMinimum | ||
assert.Equal(t, grpcKeepAliveExpectedMin, grpcKeepAliveMin) | ||
|
||
grpcKeepAliveTime := GetGRPCKeepAliveTime() | ||
assert.Equal(t, 2*grpcKeepAliveExpectedMin, grpcKeepAliveTime) | ||
} | ||
|
||
// Test valid env var set for EnvGRPCKeepAliveMin | ||
func Test_GRPCKeepAliveMinIsSet(t *testing.T) { | ||
numSeconds := 15 | ||
os.Setenv(EnvGRPCKeepAliveMin, fmt.Sprintf("%ds", numSeconds)) | ||
|
||
grpcKeepAliveMin := GetGRPCKeepAliveEnforcementMinimum() | ||
grpcKeepAliveExpectedMin := time.Duration(numSeconds) * time.Second | ||
assert.Equal(t, grpcKeepAliveExpectedMin, grpcKeepAliveMin) | ||
|
||
grpcKeepAliveTime := GetGRPCKeepAliveTime() | ||
assert.Equal(t, 2*grpcKeepAliveExpectedMin, grpcKeepAliveTime) | ||
} | ||
|
||
// Test invalid env var set for EnvGRPCKeepAliveMin | ||
func Test_GRPCKeepAliveMinIncorrectlySet(t *testing.T) { | ||
numSeconds := 15 | ||
os.Setenv(EnvGRPCKeepAliveMin, fmt.Sprintf("%d", numSeconds)) | ||
|
||
grpcKeepAliveMin := GetGRPCKeepAliveEnforcementMinimum() | ||
grpcKeepAliveExpectedMin := defaultGRPCKeepAliveEnforcementMinimum | ||
assert.Equal(t, grpcKeepAliveExpectedMin, grpcKeepAliveMin) | ||
|
||
grpcKeepAliveTime := GetGRPCKeepAliveTime() | ||
assert.Equal(t, 2*grpcKeepAliveExpectedMin, grpcKeepAliveTime) | ||
} |
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