tests should run in debug mode. Don't attempt to hot-restore SAM sessions by replacing the net.Conn parts inside if they go down, just let it die and tell the user to restart.

This commit is contained in:
idk
2022-02-01 20:03:13 -05:00
parent c6d9c0e340
commit 23c45022b3
5 changed files with 18 additions and 18 deletions

View File

@ -1,3 +1,4 @@
//go:build nettest
// +build nettest
package goSam
@ -45,7 +46,7 @@ func TestCompositeClient(t *testing.T) {
// http.HandleFunc("/", HelloServer)
go http.Serve(listener3, nil)
sam, err := NewClientFromOptions(SetDebug(false))
sam, err := NewClientFromOptions(SetDebug(true))
if err != nil {
t.Fatalf("NewDefaultClient() Error: %q\n", err)
}
@ -83,7 +84,7 @@ func TestCompositeClient(t *testing.T) {
}
func TestClientHello(t *testing.T) {
client, err := NewClientFromOptions(SetDebug(false))
client, err := NewClientFromOptions(SetDebug(true))
if err != nil {
t.Fatalf("NewDefaultClient() Error: %q\n", err)
}
@ -94,7 +95,7 @@ func TestClientHello(t *testing.T) {
}
func TestNewDestination(t *testing.T) {
client, err := NewClientFromOptions(SetDebug(false))
client, err := NewClientFromOptions(SetDebug(true))
if err != nil {
t.Fatalf("NewDefaultClient() Error: %q\n", err)
}

View File

@ -74,13 +74,9 @@ func (c *Client) DialStreamingContextFree(addr string) (net.Conn, error) {
}
}
d, err := c.NewClient(c.NewID())
err = c.StreamConnect(addr)
if err != nil {
return nil, err
}
err = d.StreamConnect(addr)
if err != nil {
return nil, err
}
return d.SamConn, nil
return c.SamConn, nil
}

View File

@ -1,3 +1,4 @@
//go:build nettest
// +build nettest
package goSam
@ -10,7 +11,7 @@ import (
func TestClientLookupInvalid(t *testing.T) {
var err error
client, err := NewClientFromOptions(SetDebug(false))
client, err := NewClientFromOptions(SetDebug(true))
if err != nil {
t.Fatalf("NewDefaultClient() Error: %q\n", err)
}

View File

@ -1,3 +1,4 @@
//go:build nettest
// +build nettest
package goSam
@ -36,7 +37,7 @@ func (c *Client) validCreate() (string, error) {
}
func TestOptionAddrString(t *testing.T) {
client, err := NewClientFromOptions(SetAddr("127.0.0.1:7656"), SetDebug(false))
client, err := NewClientFromOptions(SetAddr("127.0.0.1:7656"), SetDebug(true))
if err != nil {
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
}
@ -55,7 +56,7 @@ func TestOptionAddrString(t *testing.T) {
}
func TestOptionAddrStringLh(t *testing.T) {
client, err := NewClientFromOptions(SetAddr("localhost:7656"), SetDebug(false))
client, err := NewClientFromOptions(SetAddr("localhost:7656"), SetDebug(true))
if err != nil {
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
}
@ -74,7 +75,7 @@ func TestOptionAddrStringLh(t *testing.T) {
}
func TestOptionAddrSlice(t *testing.T) {
client, err := NewClientFromOptions(SetAddr("127.0.0.1", "7656"), SetDebug(false))
client, err := NewClientFromOptions(SetAddr("127.0.0.1", "7656"), SetDebug(true))
if err != nil {
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
}
@ -93,7 +94,7 @@ func TestOptionAddrSlice(t *testing.T) {
}
func TestOptionAddrMixedSlice(t *testing.T) {
client, err := NewClientFromOptions(SetAddrMixed("127.0.0.1", 7656), SetDebug(false))
client, err := NewClientFromOptions(SetAddrMixed("127.0.0.1", 7656), SetDebug(true))
if err != nil {
t.Fatalf("NewClientFromOptions() Error: %q\n", err)
}
@ -124,7 +125,7 @@ func TestOptionHost(t *testing.T) {
SetInBackups(2),
SetOutBackups(2),
SetEncrypt(true),
SetDebug(false),
SetDebug(true),
SetUnpublished(true),
SetReduceIdle(true),
SetReduceIdleTime(300001),
@ -162,7 +163,7 @@ func TestOptionPortInt(t *testing.T) {
SetInBackups(2),
SetOutBackups(2),
SetEncrypt(true),
SetDebug(false),
SetDebug(true),
SetUnpublished(true),
SetReduceIdle(true),
SetReduceIdleTime(300001),

View File

@ -11,8 +11,9 @@ func init() {
rand.Seed(time.Now().UnixNano())
}
// CreateSession creates a new STREAM Session.
// Returns the Id for the new Client.
// CreateSession creates a new Session of type style, with an optional destination.
// an empty destination is interpreted as "TRANSIENT"
// Returns the destination for the new Client or an error.
func (c *Client) CreateSession(style, dest string) (string, error) {
if dest == "" {
dest = "TRANSIENT"