Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions integrate_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ if [ -z "${1:-}" ]; then
fi

SAMPLE="$1"
if [ "$SAMPLE" = "rpc/triple/compatibility" ]; then
exec bash "$(dirname "${BASH_SOURCE[0]}")/rpc/triple/compatibility/run.sh"
fi

P_DIR="$(pwd)/$SAMPLE"
PROJECT_NAME="$(basename "$P_DIR")"
GO_SERVER_LOG="/tmp/.${PROJECT_NAME}.go-server.log"
Expand All @@ -32,6 +36,8 @@ PID_FILE="/tmp/.${PROJECT_NAME}.pid"
GO_CLIENT_BIN=""
HISTOGRAM_READY_FILE=""
GO_CLIENT_TIMEOUT_SECONDS="${GO_CLIENT_TIMEOUT_SECONDS:-90}"
GO_SERVER_READY_TIMEOUT_SECONDS="${GO_SERVER_READY_TIMEOUT_SECONDS:-15}"
GO_SERVER_READY_PORTS="${GO_SERVER_READY_PORTS:-20000 20001 20002 20022 50051 50052}"
JAVA_SERVER_READY_TIMEOUT_SECONDS="${JAVA_SERVER_READY_TIMEOUT_SECONDS:-60}"
JAVA_SERVER_HOST="${JAVA_SERVER_HOST:-127.0.0.1}"
JAVA_SERVER_PORT="${JAVA_SERVER_PORT:-20000}"
Expand Down Expand Up @@ -345,6 +351,22 @@ PY
return 1
}

go_server_ports_ready() {
python3 - "$GO_SERVER_READY_PORTS" <<'PY' >/dev/null 2>&1
import socket
import sys

for port in sys.argv[1].split():
try:
with socket.create_connection(("127.0.0.1", int(port)), timeout=0.5):
sys.exit(0)
except OSError:
continue

sys.exit(1)
PY
}

wait_for_tcp_port_closed() {
local host="$1"
local port="$2"
Expand Down Expand Up @@ -580,6 +602,24 @@ start_go_server() {
[ -f "$app_log" ] && cat "$app_log" || true
return 1
fi

# A fixed sleep is not enough on cold CI runners. Wait until one of the
# sample ports accepts connections, then fall back to the previous behavior
# for samples that listen on a port that is not listed above.
local ready_elapsed=0
while [ "$ready_elapsed" -lt "$GO_SERVER_READY_TIMEOUT_SECONDS" ]; do
if go_server_ports_ready; then
return 0
fi
if ! kill -0 "$server_pid" 2>/dev/null; then
echo "Go server exited before accepting connections: $SAMPLE"
cat "$GO_SERVER_LOG" || true
return 1
fi
sleep 1
ready_elapsed=$((ready_elapsed + 1))
done
echo "Go server ports did not accept connections within ${GO_SERVER_READY_TIMEOUT_SECONDS}s, continuing: $SAMPLE"
}

stop_go_server() {
Expand Down
19 changes: 19 additions & 0 deletions rpc/triple/compatibility/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Triple compatibility and Java interoperability

From the repository root, run:

```bash
bash ./integrate_test.sh rpc/triple/compatibility
```

The same scenario is included in `start_integrate_test.sh`. It runs:

1. A dubbo-go `v3.3.2` client against the server built with this repository's selected dubbo-go dependency.
2. The current client against a separately built dubbo-go `v3.3.2` server.
3. The existing `java_interop/non-protobuf-triple` sample in all four Go/Java client-server combinations.

All calls use Hessian2 over Triple. Both cross-version calls assert the returned greeting, and the Java matrix checks the expected response from each direction. The existing Java sample pins Dubbo `3.3.0-beta.3`.

Go, Java, Maven, Make, Python 3, and network access for dependencies are required. TCP port `20000` must be free. Binaries and matrix logs are created in a temporary directory; the script cleans up its servers and temporary files on exit.

The current client and server use the root module's dubbo-go dependency, including any replacement configured by the caller or CI. The `legacy-client` nested module deliberately pins `v3.3.2` without inheriting that replacement: Go cannot load two versions of the same module path in one build. Root `go test ./...` does not run this integration scenario.
97 changes: 97 additions & 0 deletions rpc/triple/compatibility/legacy-client/cmd/server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// 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.

// This server is intentionally pinned to dubbo-go v3.3.2 through the parent
// module. It lets the current checkout's Go client test the reverse direction.
package main

import (
"context"
"fmt"
)

import (
"dubbo.apache.org/dubbo-go/v3/common"
"dubbo.apache.org/dubbo-go/v3/common/constant"
_ "dubbo.apache.org/dubbo-go/v3/imports"
"dubbo.apache.org/dubbo-go/v3/protocol"
"dubbo.apache.org/dubbo-go/v3/protocol/triple/triple_protocol"
"dubbo.apache.org/dubbo-go/v3/server"

hessian "github.com/apache/dubbo-go-hessian2"
)

const serviceName = "org.apache.dubbo.tri.hessian2.api.GreetingsService"

type GreetRequest struct {
Name string
}

func (*GreetRequest) JavaClassName() string {
return "org.apache.dubbo.tri.hessian2.api.GreetRequest"
}

type GreetResponse struct {
Greeting string
}

func (*GreetResponse) JavaClassName() string {
return "org.apache.dubbo.tri.hessian2.api.GreetResponse"
}

type GreetService struct{}

type greetings interface {
Greet(context.Context, *GreetRequest) (*GreetResponse, error)
}

func (*GreetService) Greet(_ context.Context, request *GreetRequest) (*GreetResponse, error) {
return &GreetResponse{Greeting: fmt.Sprintf("The name of the request is:\t %s", request.Name)}, nil
}

func main() {
hessian.RegisterPOJO(new(GreetRequest))
hessian.RegisterPOJO(new(GreetResponse))

srv, err := server.NewServer(
server.WithServerProtocol(protocol.WithPort(20000), protocol.WithTriple()),
server.WithServerSerialization(constant.Hessian2Serialization),
)
if err != nil {
panic(err)
}
info := &common.ServiceInfo{
InterfaceName: serviceName,
ServiceType: (*greetings)(nil),
Methods: []common.MethodInfo{{
Name: "Greet",
Type: constant.CallUnary,
ReqInitFunc: func() any { return new(GreetRequest) },
MethodFunc: func(ctx context.Context, args []any, handler any) (any, error) {
response, callErr := handler.(greetings).Greet(ctx, args[0].(*GreetRequest))
if callErr != nil {
return nil, callErr
}
return triple_protocol.NewResponse(response), nil
},
}},
}
if err := srv.Register(&GreetService{}, info); err != nil {
panic(err)
}
if err := srv.Serve(); err != nil {
panic(err)
}
}
141 changes: 141 additions & 0 deletions rpc/triple/compatibility/legacy-client/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
module github.com/apache/dubbo-go-samples/rpc/triple/compatibility/legacy-client

go 1.25.0

require (
dubbo.apache.org/dubbo-go/v3 v3.3.2
github.com/apache/dubbo-go-hessian2 v1.12.5
)

require (
github.com/RoaringBitmap/roaring v1.2.3 // indirect
github.com/Workiva/go-datastructures v1.0.52 // indirect
github.com/alibaba/sentinel-golang v1.0.4 // indirect
github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 // indirect
github.com/alibabacloud-go/tea v1.1.17 // indirect
github.com/alibabacloud-go/tea-utils v1.4.4 // indirect
github.com/aliyun/alibaba-cloud-sdk-go v1.61.1800 // indirect
github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.2.2 // indirect
github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7 // indirect
github.com/apache/dubbo-getty v1.4.10 // indirect
github.com/apolloconfig/agollo/v4 v4.4.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/bits-and-blooms/bitset v1.2.0 // indirect
github.com/buger/jsonparser v1.2.0 // indirect
github.com/cenkalti/backoff/v4 v4.2.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/coreos/go-semver v0.3.0 // indirect
github.com/coreos/go-systemd/v22 v22.3.2 // indirect
github.com/creasty/defaults v1.5.2 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/dlclark/regexp2 v1.7.0 // indirect
github.com/dop251/goja v0.0.0-20240220182346-e401ed450204 // indirect
github.com/dubbogo/go-zookeeper v1.0.4-0.20211212162352-f9d2183d89d5 // indirect
github.com/dubbogo/gost v1.14.3 // indirect
github.com/dubbogo/grpc-go v1.42.10 // indirect
github.com/dubbogo/triple v1.2.2-rc4 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/emicklei/go-restful/v3 v3.10.1 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/go-logr/logr v1.4.3 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.14.1 // indirect
github.com/go-playground/universal-translator v0.18.1 // indirect
github.com/go-playground/validator/v10 v10.12.0 // indirect
github.com/go-resty/resty/v2 v2.7.0 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/mock v1.6.0 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.4 // indirect
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
github.com/google/uuid v1.6.0 // indirect
github.com/gorilla/websocket v1.4.2 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.16.0 // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/vault/sdk v0.7.0 // indirect
github.com/influxdata/tdigest v0.0.1 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/k0kubun/pp v3.0.1+incompatible // indirect
github.com/knadh/koanf v1.5.0 // indirect
github.com/leodido/go-urn v1.2.2 // indirect
github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 // indirect
github.com/magiconair/properties v1.8.5 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.16 // indirect
github.com/mitchellh/copystructure v1.2.0 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mitchellh/reflectwalk v1.0.2 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/mschoch/smat v0.2.0 // indirect
github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 // indirect
github.com/natefinch/lumberjack v2.0.0+incompatible // indirect
github.com/oliveagle/jsonpath v0.0.0-20180606110733-2e52cf6e6852 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/openzipkin/zipkin-go v0.4.2 // indirect
github.com/pelletier/go-toml v1.9.3 // indirect
github.com/pierrec/lz4 v2.6.1+incompatible // indirect
github.com/pkg/errors v0.9.1 // indirect
github.com/polarismesh/polaris-go v1.3.0 // indirect
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c // indirect
github.com/prometheus/client_golang v1.19.1 // indirect
github.com/prometheus/client_model v0.5.0 // indirect
github.com/prometheus/common v0.48.0 // indirect
github.com/prometheus/procfs v0.12.0 // indirect
github.com/quic-go/qpack v0.6.0 // indirect
github.com/quic-go/quic-go v0.59.1 // indirect
github.com/shirou/gopsutil/v3 v3.22.2 // indirect
github.com/sirupsen/logrus v1.9.4 // indirect
github.com/spaolacci/murmur3 v1.1.0 // indirect
github.com/spf13/afero v1.6.0 // indirect
github.com/spf13/cast v1.3.1 // indirect
github.com/spf13/jwalterweatherman v1.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.8.1 // indirect
github.com/subosito/gotenv v1.2.0 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
github.com/tklauser/numcpus v0.4.0 // indirect
github.com/uber/jaeger-client-go v2.29.1+incompatible // indirect
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
github.com/ugorji/go/codec v1.2.6 // indirect
github.com/yusufpapurcu/wmi v1.2.2 // indirect
go.etcd.io/etcd/api/v3 v3.5.7 // indirect
go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect
go.etcd.io/etcd/client/v3 v3.5.7 // indirect
go.opentelemetry.io/contrib/propagators/b3 v1.10.0 // indirect
go.opentelemetry.io/otel v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/jaeger v1.17.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/stdout/stdouttrace v1.21.0 // indirect
go.opentelemetry.io/otel/exporters/zipkin v1.21.0 // indirect
go.opentelemetry.io/otel/metric v1.21.0 // indirect
go.opentelemetry.io/otel/sdk v1.21.0 // indirect
go.opentelemetry.io/otel/trace v1.21.0 // indirect
go.opentelemetry.io/proto/otlp v1.0.0 // indirect
go.uber.org/atomic v1.10.0 // indirect
go.uber.org/multierr v1.8.0 // indirect
go.uber.org/zap v1.21.0 // indirect
golang.org/x/crypto v0.53.0 // indirect
golang.org/x/net v0.56.0 // indirect
golang.org/x/sync v0.21.0 // indirect
golang.org/x/sys v0.46.0 // indirect
golang.org/x/text v0.39.0 // indirect
golang.org/x/time v0.15.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect
google.golang.org/grpc v1.64.1 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/ini.v1 v1.66.2 // indirect
gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
Loading
Loading