-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from ernoaapa/fix-discovery-server-stop
Fix discovery server not stopping properly
- Loading branch information
Showing
4 changed files
with
55 additions
and
28 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,20 @@ | ||
package discovery | ||
|
||
import ( | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestClientNodes(t *testing.T) { | ||
server := NewServer("testing", 1234, "v1.0") | ||
go server.Serve() | ||
defer server.Stop() | ||
|
||
nodes, err := Nodes(1 * time.Second) | ||
assert.NoError(t, err) | ||
assert.Len(t, nodes, 1) | ||
assert.Equal(t, int64(1234), nodes[0].GrpcPort) | ||
assert.Equal(t, "v1.0", nodes[0].Version) | ||
} |
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,19 @@ | ||
package discovery | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
) | ||
|
||
func TestServerServeStop(t *testing.T) { | ||
var wg sync.WaitGroup | ||
server := NewServer("testing", 1234, "v1.0") | ||
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
server.Serve() | ||
}() | ||
|
||
server.Stop() | ||
wg.Wait() | ||
} |