Merge pull request #290 from ztelur/0.4.0
delete zk jar file and useless test code
Former-commit-id: 3962203abe270dc2be2ae0a2804c6c8fb41ac70d [formerly 544d1017ca7a587a48ece54df61bf6c74a7f5ec1]
Former-commit-id: 216a2e25d3b4c03deac1ea2fbeb385ae40ef1882
diff --git a/.gitignore b/.gitignore
index b590313..8b4d6ae 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,7 +12,6 @@
/logs
/.idea
/.vscode
-pkg/registry/zookeeper-4unittest/contrib/fatjar
.DS_Store
diff --git a/pkg/adapter/dubboregistry/registry/zookeeper/interface_listener_test.go b/pkg/adapter/dubboregistry/registry/zookeeper/interface_listener_test.go
deleted file mode 100644
index e386d95..0000000
--- a/pkg/adapter/dubboregistry/registry/zookeeper/interface_listener_test.go
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package zookeeper
diff --git a/pkg/adapter/dubboregistry/registry/zookeeper/service_listener_test.go b/pkg/adapter/dubboregistry/registry/zookeeper/service_listener_test.go
deleted file mode 100644
index e386d95..0000000
--- a/pkg/adapter/dubboregistry/registry/zookeeper/service_listener_test.go
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package zookeeper
diff --git a/pkg/adapter/dubboregistry/registry/zookeeper/zookeeper-4unittest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar.REMOVED.git-id b/pkg/adapter/dubboregistry/registry/zookeeper/zookeeper-4unittest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar.REMOVED.git-id
deleted file mode 100644
index 9eac4b4..0000000
--- a/pkg/adapter/dubboregistry/registry/zookeeper/zookeeper-4unittest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-839531b8b8762a9c19e334a5cbf79314cb16f945
\ No newline at end of file
diff --git a/pkg/adapter/dubboregistry/remoting/zookeeper/client_test.go b/pkg/adapter/dubboregistry/remoting/zookeeper/client_test.go
deleted file mode 100644
index e55270a..0000000
--- a/pkg/adapter/dubboregistry/remoting/zookeeper/client_test.go
+++ /dev/null
@@ -1,166 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package zookeeper
-
-import (
- "fmt"
- "testing"
- "time"
-)
-import (
- "github.com/dubbogo/go-zookeeper/zk"
- "github.com/pkg/errors"
- "github.com/stretchr/testify/assert"
-)
-import (
- "github.com/apache/dubbo-go-pixiu/pkg/logger"
-)
-
-func verifyEventStateOrder(t *testing.T, c <-chan zk.Event, expectedStates []zk.State, source string) {
- for _, state := range expectedStates {
- for {
- event, ok := <-c
- if !ok {
- t.Fatalf("unexpected channel close for %s", source)
- }
- logger.Debug(event)
- if event.Type != zk.EventSession {
- continue
- }
- assert.Equal(t, event.State, state)
- break
- }
- }
-}
-
-// NewMockZooKeeperClient returns a mock client instance
-func NewMockZooKeeperClient(name string, timeout time.Duration, opts ...Option) (*zk.TestCluster, *ZooKeeperClient, <-chan zk.Event, error) {
- var (
- err error
- event <-chan zk.Event
- z *ZooKeeperClient
- ts *zk.TestCluster
- )
-
- z = &ZooKeeperClient{
- name: name,
- ZkAddrs: []string{},
- Timeout: timeout,
- exit: make(chan struct{}),
- eventRegistry: make(map[string][]*chan struct{}),
- }
-
- options := &Options{}
- for _, opt := range opts {
- opt(options)
- }
-
- // connect to zookeeper
- if options.ts != nil {
- ts = options.ts
- } else {
- ts, err = zk.StartTestCluster(1, nil, nil)
- if err != nil {
- return nil, nil, nil, errors.WithMessagef(err, "zk.Connect")
- }
- }
-
- z.conn, event, err = ts.ConnectWithOptions(timeout)
- if err != nil {
- return nil, nil, nil, errors.WithMessagef(err, "zk.Connect")
- }
-
- return ts, z, event, nil
-}
-
-func TestNewZooKeeperClient(t *testing.T) {
- tc, err := zk.StartTestCluster(1, nil, nil)
- if err != nil {
- t.Fatal(err)
- }
- defer func(tc *zk.TestCluster) {
- err := tc.Stop()
- if err != nil {
- t.Errorf("failed to stop cluster, %s", err.Error())
- }
- }(tc)
-
- hosts := make([]string, len(tc.Servers))
- for i, srv := range tc.Servers {
- hosts[i] = fmt.Sprintf("127.0.0.1:%d", srv.Port)
- }
- zkClient, eventChan, err := NewZooKeeperClient("testZK", hosts, 30*time.Second)
- if err != nil {
- t.Fatalf("Connect returned error: %+v", err)
- }
-
- states := []zk.State{zk.StateConnecting, zk.StateConnected, zk.StateHasSession}
- verifyEventStateOrder(t, eventChan, states, "event channel")
-
- zkClient.getConn().Close()
- verifyEventStateOrder(t, eventChan, []zk.State{zk.StateDisconnected}, "event channel")
-}
-
-func TestGetChildren(t *testing.T) {
- tc, err := zk.StartTestCluster(1, nil, nil)
- if err != nil {
- t.Fatal(err)
- }
- defer func(tc *zk.TestCluster) {
- err := tc.Stop()
- if err != nil {
- t.Errorf("failed to stop cluster, %s", err.Error())
- }
- }(tc)
-
- conn, _, _ := tc.ConnectAll()
- _, err = conn.Create("/test", nil, 0, zk.WorldACL(zk.PermAll))
- assert.NoError(t, err)
- _, err = conn.Create("/test/testchild1", nil, 0, zk.WorldACL(zk.PermAll))
- assert.NoError(t, err)
- _, err = conn.Create("/test/testchild2", nil, 0, zk.WorldACL(zk.PermAll))
- assert.NoError(t, err)
-
- hosts := make([]string, len(tc.Servers))
- for i, srv := range tc.Servers {
- hosts[i] = fmt.Sprintf("127.0.0.1:%d", srv.Port)
- }
- zkClient, eventChan, err := NewZooKeeperClient("testZK", hosts, 30*time.Second)
- assert.Nil(t, err)
-wait:
- for {
- e := <-eventChan
- switch e.State {
- case zk.StateDisconnected:
- break wait
- case zk.StateConnected:
- children, err := zkClient.GetChildren("/test")
- assert.Nil(t, err)
- assert.Equal(t, children[1], "testchild1")
- assert.Equal(t, children[0], "testchild2")
-
- children, err = zkClient.GetChildren("/vacancy")
- assert.EqualError(t, err, "path{/vacancy} does not exist: node does not exist")
- assert.Nil(t, children)
- children, err = zkClient.GetChildren("/test/testchild1")
- assert.EqualError(t, err, "has none children")
- assert.Empty(t, children)
- zkClient.conn.Close()
- }
- }
-}
diff --git a/pkg/adapter/dubboregistry/remoting/zookeeper/zookeeper-4unittest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar.REMOVED.git-id b/pkg/adapter/dubboregistry/remoting/zookeeper/zookeeper-4unittest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar.REMOVED.git-id
deleted file mode 100644
index 9eac4b4..0000000
--- a/pkg/adapter/dubboregistry/remoting/zookeeper/zookeeper-4unittest/contrib/fatjar/zookeeper-3.4.9-fatjar.jar.REMOVED.git-id
+++ /dev/null
@@ -1 +0,0 @@
-839531b8b8762a9c19e334a5cbf79314cb16f945
\ No newline at end of file