forked from apache/dubbo-go
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ftr: Add integration test multi-server support (apache#161)
Fix: add consumer config for middle Ftr: add multi-zone to integration testing Fix: start_integrate_test.sh Fix: start_integrate_test.sh Fix: test.sh Tst: Add multi-zone tests Fix: start_integrate_test.sh
- Loading branch information
1 parent
c875ae7
commit 6ff8949
Showing
10 changed files
with
445 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# 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, softwarek | ||
# 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. | ||
|
||
# This file is for integration testing only | ||
|
||
P_DIR="$1" | ||
|
||
# start zookeeper | ||
make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" BASE_DIR="$P_DIR"/dist -f build/Makefile docker-up | ||
|
||
# start server | ||
make PROJECT_DIR="$P_DIR"/backend PROJECT_NAME="$(basename "$P_DIR"/backend)" BASE_DIR="$P_DIR"/backend/dist -f build/Makefile start | ||
make PROJECT_DIR="$P_DIR"/middle PROJECT_NAME="$(basename "$P_DIR"/middle)" CONF_CONSUMER_FILE_PATH="$P_DIR"/middle/conf/client.yml BASE_DIR="$P_DIR"/middle/dist -f build/Makefile start | ||
|
||
# start integration testing | ||
make PROJECT_DIR="$P_DIR"/backend PROJECT_NAME="$(basename "$P_DIR"/backend)" BASE_DIR="$P_DIR"/backend/dist -f build/Makefile integration | ||
result=$? | ||
|
||
make PROJECT_DIR="$P_DIR"/middle PROJECT_NAME="$(basename "$P_DIR"/middle)" BASE_DIR="$P_DIR"/middle/dist CONF_CONSUMER_FILE_PATH="$P_DIR"/middle/conf/test.yml -f build/Makefile integration | ||
result2=$? | ||
|
||
if [ $result -eq 0 ]; then | ||
result=$result2 | ||
fi | ||
|
||
# stop server and clean | ||
make PROJECT_DIR="$P_DIR"/backend PROJECT_NAME="$(basename "$P_DIR"/backend)" BASE_DIR="$P_DIR"/backend/dist -f build/Makefile clean | ||
make PROJECT_DIR="$P_DIR"/middle PROJECT_NAME="$(basename "$P_DIR"/middle)" BASE_DIR="$P_DIR"/middle/dist -f build/Makefile clean | ||
|
||
make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" BASE_DIR="$P_DIR"/dist -f build/Makefile docker-down | ||
|
||
exit $result |
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,45 @@ | ||
# 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, softwarek | ||
# 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. | ||
|
||
# This file is for integration testing only | ||
|
||
P_DIR="$1" | ||
|
||
# start zookeeper | ||
make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" BASE_DIR="$P_DIR"/dist -f build/Makefile docker-up | ||
|
||
# start server | ||
make PROJECT_DIR="$P_DIR"/go-server-hz PROJECT_NAME="$(basename "$P_DIR"/go-server-hz)" BASE_DIR="$P_DIR"/go-server-hz/dist -f build/Makefile start | ||
make PROJECT_DIR="$P_DIR"/go-server-sh PROJECT_NAME="$(basename "$P_DIR"/go-server-sh)" BASE_DIR="$P_DIR"/go-server-sh/dist -f build/Makefile start | ||
|
||
# start integration testing | ||
make PROJECT_DIR="$P_DIR"/go-server-hz PROJECT_NAME="$(basename "$P_DIR"/go-server-hz)" BASE_DIR="$P_DIR"/go-server-hz/dist -f build/Makefile integration | ||
result=$? | ||
|
||
make PROJECT_DIR="$P_DIR"/go-server-sh PROJECT_NAME="$(basename "$P_DIR"/go-server-sh)" BASE_DIR="$P_DIR"/go-server-sh/dist -f build/Makefile integration | ||
result2=$? | ||
|
||
if [ $result -eq 0 ]; then | ||
result=$result2 | ||
fi | ||
|
||
# stop server and clean | ||
make PROJECT_DIR="$P_DIR"/go-server-hz PROJECT_NAME="$(basename "$P_DIR"/go-server-hz)" BASE_DIR="$P_DIR"/go-server-hz/dist -f build/Makefile clean | ||
make PROJECT_DIR="$P_DIR"/go-server-sh PROJECT_NAME="$(basename "$P_DIR"/go-server-sh)" BASE_DIR="$P_DIR"/go-server-sh/dist -f build/Makefile clean | ||
|
||
# stop zookeeper | ||
make PROJECT_DIR="$P_DIR" PROJECT_NAME="$(basename "$P_DIR")" BASE_DIR="$P_DIR"/dist -f build/Makefile docker-down | ||
|
||
exit $result |
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,61 @@ | ||
# dubbo client yaml configure file | ||
|
||
check: true | ||
# client | ||
request_timeout: "3s" | ||
# connect timeout | ||
connect_timeout: "3s" | ||
|
||
# application config | ||
application: | ||
organization: "dubbo.io" | ||
name: "UserInfoClient" | ||
module: "dubbo-go user-info client" | ||
version: "0.0.1" | ||
environment: "dev" | ||
|
||
# registry config | ||
registries: | ||
"demoZk": | ||
protocol: "zookeeper" | ||
timeout: "3s" | ||
address: "127.0.0.1:2183" | ||
username: "" | ||
password: "" | ||
zone: hangzhou | ||
weight: 50 | ||
|
||
# reference config | ||
references: | ||
"UserProvider": | ||
registry: "demoZk" | ||
protocol: "dubbo" | ||
interface: "org.apache.dubbo.UserProvider" | ||
cluster: "failover" | ||
methods: | ||
- name: "GetUser" | ||
retries: 3 | ||
|
||
# protocol config | ||
protocol_conf: | ||
dubbo: | ||
reconnect_interval: 0 | ||
connection_number: 1 | ||
heartbeat_period: "5s" | ||
session_timeout: "180s" | ||
pool_size: 64 | ||
pool_ttl: 600 | ||
getty_session_param: | ||
compress_encoding: false | ||
tcp_no_delay: true | ||
tcp_keep_alive: true | ||
keep_alive_period: "120s" | ||
tcp_r_buf_size: 262144 | ||
tcp_w_buf_size: 65536 | ||
pkg_rq_size: 1024 | ||
pkg_wq_size: 512 | ||
tcp_read_timeout: "1s" | ||
tcp_write_timeout: "5s" | ||
wait_timeout: "1s" | ||
max_msg_len: 1024000 | ||
session_name: "client" |
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,70 @@ | ||
// +build integration | ||
|
||
/* | ||
* 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 integration | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"testing" | ||
"time" | ||
) | ||
|
||
import ( | ||
hessian "github.com/apache/dubbo-go-hessian2" | ||
_ "github.com/apache/dubbo-go/cluster/cluster_impl" | ||
_ "github.com/apache/dubbo-go/cluster/loadbalance" | ||
_ "github.com/apache/dubbo-go/common/proxy/proxy_factory" | ||
"github.com/apache/dubbo-go/config" | ||
_ "github.com/apache/dubbo-go/filter/filter_impl" | ||
_ "github.com/apache/dubbo-go/metadata/service/inmemory" | ||
_ "github.com/apache/dubbo-go/protocol/dubbo" | ||
_ "github.com/apache/dubbo-go/registry/protocol" | ||
_ "github.com/apache/dubbo-go/registry/zookeeper" | ||
) | ||
|
||
var userProvider = new(UserProvider) | ||
|
||
func TestMain(m *testing.M) { | ||
config.SetConsumerService(userProvider) | ||
hessian.RegisterPOJO(&User{}) | ||
config.Load() | ||
time.Sleep(3 * time.Second) | ||
|
||
os.Exit(m.Run()) | ||
} | ||
|
||
type User struct { | ||
ID string | ||
Name string | ||
Age int32 | ||
Time time.Time | ||
} | ||
|
||
type UserProvider struct { | ||
GetUser func(ctx context.Context, req []interface{}, rsp *User) error | ||
} | ||
|
||
func (u *UserProvider) Reference() string { | ||
return "UserProvider" | ||
} | ||
|
||
func (User) JavaClassName() string { | ||
return "org.apache.dubbo.User" | ||
} |
38 changes: 38 additions & 0 deletions
38
multi-zone/go-server-hz/tests/integration/userprovider_test.go
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,38 @@ | ||
// +build integration | ||
|
||
/* | ||
* 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 integration | ||
|
||
import ( | ||
"context" | ||
"testing" | ||
) | ||
import ( | ||
"github.com/stretchr/testify/assert" | ||
) | ||
|
||
func TestGetUser(t *testing.T) { | ||
user := &User{} | ||
err := userProvider.GetUser(context.TODO(), []interface{}{"A001"}, user) | ||
assert.Nil(t, err) | ||
assert.Equal(t, "dev-hz", user.ID) | ||
assert.Equal(t, "Alex Stocks", user.Name) | ||
assert.Equal(t, int32(18), user.Age) | ||
assert.NotNil(t, user.Time) | ||
} |
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,61 @@ | ||
# dubbo client yaml configure file | ||
|
||
check: true | ||
# client | ||
request_timeout: "3s" | ||
# connect timeout | ||
connect_timeout: "3s" | ||
|
||
# application config | ||
application: | ||
organization: "dubbo.io" | ||
name: "UserInfoClient" | ||
module: "dubbo-go user-info client" | ||
version: "0.0.1" | ||
environment: "dev" | ||
|
||
# registry config | ||
registries: | ||
"demoZk": | ||
protocol: "zookeeper" | ||
timeout: "3s" | ||
address: "127.0.0.1:2182" | ||
username: "" | ||
password: "" | ||
zone: shanghai | ||
weight: 50 | ||
|
||
# reference config | ||
references: | ||
"UserProvider": | ||
registry: "demoZk" | ||
protocol: "dubbo" | ||
interface: "org.apache.dubbo.UserProvider" | ||
cluster: "failover" | ||
methods: | ||
- name: "GetUser" | ||
retries: 3 | ||
|
||
# protocol config | ||
protocol_conf: | ||
dubbo: | ||
reconnect_interval: 0 | ||
connection_number: 1 | ||
heartbeat_period: "5s" | ||
session_timeout: "180s" | ||
pool_size: 64 | ||
pool_ttl: 600 | ||
getty_session_param: | ||
compress_encoding: false | ||
tcp_no_delay: true | ||
tcp_keep_alive: true | ||
keep_alive_period: "120s" | ||
tcp_r_buf_size: 262144 | ||
tcp_w_buf_size: 65536 | ||
pkg_rq_size: 1024 | ||
pkg_wq_size: 512 | ||
tcp_read_timeout: "1s" | ||
tcp_write_timeout: "5s" | ||
wait_timeout: "1s" | ||
max_msg_len: 1024000 | ||
session_name: "client" |
Oops, something went wrong.