-
-
Notifications
You must be signed in to change notification settings - Fork 524
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix panic due to early onEvent Logger call
- Loading branch information
Showing
2 changed files
with
74 additions
and
78 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 |
---|---|---|
@@ -1,78 +1,76 @@ | ||
package zk | ||
|
||
//TODO: fix this | ||
// | ||
//import ( | ||
// "sync/atomic" | ||
// "testing" | ||
// "time" | ||
// | ||
// "github.com/asynkron/protoactor-go/actor" | ||
// "github.com/asynkron/protoactor-go/cluster" | ||
// "github.com/asynkron/protoactor-go/cluster/identitylookup/disthash" | ||
// "github.com/asynkron/protoactor-go/remote" | ||
// "github.com/stretchr/testify/suite" | ||
//) | ||
// | ||
//type ZookeeperTestSuite struct { | ||
// suite.Suite | ||
//} | ||
// | ||
//func (suite *ZookeeperTestSuite) SetupTest() { | ||
// | ||
//} | ||
// | ||
//func (suite *ZookeeperTestSuite) TearDownTest() { | ||
//} | ||
// | ||
//func TestZookeeperTestSuite(t *testing.T) { | ||
// suite.Run(t, new(ZookeeperTestSuite)) | ||
//} | ||
// | ||
//type ClusterAndSystem struct { | ||
// Cluster *cluster.Cluster | ||
// System *actor.ActorSystem | ||
//} | ||
// | ||
//func (self *ClusterAndSystem) Shutdown() { | ||
// self.Cluster.Shutdown(true) | ||
//} | ||
// | ||
//func (suite *ZookeeperTestSuite) start(name string, opts ...cluster.ConfigOption) *ClusterAndSystem { | ||
// cp, _ := New([]string{`localhost:8000`}) | ||
// remoteConfig := remote.Configure("localhost", 0) | ||
// config := cluster.Configure(name, cp, disthash.New(), remoteConfig, opts...) | ||
// system := actor.NewActorSystem() | ||
// c := cluster.New(system, config) | ||
// c.StartMember() | ||
// return &ClusterAndSystem{Cluster: c, System: system} | ||
//} | ||
// | ||
//func (suite *ZookeeperTestSuite) TestEmptyExecute() { | ||
// name := `cluster0` | ||
// suite.start(name).Shutdown() | ||
//} | ||
// | ||
//func (suite *ZookeeperTestSuite) TestMultiNodes() { | ||
// var actorCount int32 | ||
// props := actor.PropsFromFunc(func(ctx actor.Context) { | ||
// switch ctx.Message().(type) { | ||
// case *actor.Started: | ||
// atomic.AddInt32(&actorCount, 1) | ||
// } | ||
// }) | ||
// helloKind := cluster.NewKind("hello", props) | ||
// | ||
// name := `cluster1` | ||
// c1 := suite.start(name, cluster.WithKinds(helloKind)) | ||
// defer c1.Shutdown() | ||
// c2 := suite.start(name, cluster.WithKinds(helloKind)) | ||
// defer c2.Shutdown() | ||
// c1.Cluster.Get(`a1`, `hello`) | ||
// c2.Cluster.Get(`a2`, `hello`) | ||
// for actorCount != 2 { | ||
// time.Sleep(time.Microsecond * 5) | ||
// } | ||
// suite.Assert().Equal(2, c1.Cluster.MemberList.Members().Len(), "Expected 2 members in the cluster") | ||
// suite.Assert().Equal(2, c2.Cluster.MemberList.Members().Len(), "Expected 2 members in the cluster") | ||
//} | ||
import ( | ||
"sync/atomic" | ||
"testing" | ||
"time" | ||
|
||
"github.com/asynkron/protoactor-go/actor" | ||
"github.com/asynkron/protoactor-go/cluster" | ||
"github.com/asynkron/protoactor-go/cluster/identitylookup/disthash" | ||
"github.com/asynkron/protoactor-go/remote" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ZookeeperTestSuite struct { | ||
suite.Suite | ||
} | ||
|
||
func (suite *ZookeeperTestSuite) SetupTest() { | ||
|
||
} | ||
|
||
func (suite *ZookeeperTestSuite) TearDownTest() { | ||
} | ||
|
||
func TestZookeeperTestSuite(t *testing.T) { | ||
suite.Run(t, new(ZookeeperTestSuite)) | ||
} | ||
|
||
type ClusterAndSystem struct { | ||
Cluster *cluster.Cluster | ||
System *actor.ActorSystem | ||
} | ||
|
||
func (self *ClusterAndSystem) Shutdown() { | ||
self.Cluster.Shutdown(true) | ||
} | ||
|
||
func (suite *ZookeeperTestSuite) start(name string, opts ...cluster.ConfigOption) *ClusterAndSystem { | ||
cp, _ := New([]string{`localhost:8000`}) | ||
remoteConfig := remote.Configure("localhost", 0) | ||
config := cluster.Configure(name, cp, disthash.New(), remoteConfig, opts...) | ||
system := actor.NewActorSystem() | ||
c := cluster.New(system, config) | ||
c.StartMember() | ||
return &ClusterAndSystem{Cluster: c, System: system} | ||
} | ||
|
||
func (suite *ZookeeperTestSuite) TestEmptyExecute() { | ||
name := `cluster0` | ||
suite.start(name).Shutdown() | ||
} | ||
|
||
func (suite *ZookeeperTestSuite) TestMultiNodes() { | ||
var actorCount int32 | ||
props := actor.PropsFromFunc(func(ctx actor.Context) { | ||
switch ctx.Message().(type) { | ||
case *actor.Started: | ||
atomic.AddInt32(&actorCount, 1) | ||
} | ||
}) | ||
helloKind := cluster.NewKind("hello", props) | ||
|
||
name := `cluster1` | ||
c1 := suite.start(name, cluster.WithKinds(helloKind)) | ||
defer c1.Shutdown() | ||
c2 := suite.start(name, cluster.WithKinds(helloKind)) | ||
defer c2.Shutdown() | ||
c1.Cluster.Get(`a1`, `hello`) | ||
c2.Cluster.Get(`a2`, `hello`) | ||
for actorCount != 2 { | ||
time.Sleep(time.Microsecond * 5) | ||
} | ||
suite.Assert().Equal(2, c1.Cluster.MemberList.Members().Len(), "Expected 2 members in the cluster") | ||
suite.Assert().Equal(2, c2.Cluster.MemberList.Members().Len(), "Expected 2 members in the cluster") | ||
} |