Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ci #39

Closed
wants to merge 6 commits into from
Closed
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
30 changes: 30 additions & 0 deletions .github/workflow/go.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# This workflow will build a golang project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-go

name: Go

on:
push:
branches:
- "master"
- "ci"
pull_request:
branches: [ "master" ]

jobs:

build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3

- name: Set up Go
uses: actions/setup-go@v4
with:
go-version: '1.20'

- name: Build
run: go build -v ./...

- name: Test
run: go test -v ./...
6 changes: 3 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
language: go

go:
- 1.13.x
- 1.12.x
- 1.11.x
- 1.18.x
- 1.19.x
- 1.20.x
before_script:
- GO_FILES=$(find . -iname '*.go' -type f | grep -v /vendor/)
- go get golang.org/x/lint
Expand Down
42 changes: 22 additions & 20 deletions channel_rpc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,8 @@ var (
MaximumCap = 100
network = "tcp"
address = "127.0.0.1:7777"
//factory = func() (interface{}, error) { return net.Dial(network, address) }
factory = func() (interface{}, error) {
return rpc.DialHTTP("tcp", address)
factory = func() (interface{}, error) {
return rpc.DialHTTP(network, address)
}
closeFac = func(v interface{}) error {
nc := v.(*rpc.Client)
Expand All @@ -30,7 +29,6 @@ func init() {
// used for factory function
go rpcServer()
time.Sleep(time.Millisecond * 300) // wait until tcp server has been settled

rand.Seed(time.Now().UTC().UnixNano())
}

Expand Down Expand Up @@ -67,8 +65,7 @@ func TestPool_Get(t *testing.T) {

// after one get, current capacity should be lowered by one.
if p.Len() != (InitialCap - 1) {
t.Errorf("Get error. Expecting %d, got %d",
(InitialCap - 1), p.Len())
t.Errorf("Get error. Expecting %d, got %d", InitialCap-1, p.Len())
}

// get them all
Expand All @@ -86,20 +83,19 @@ func TestPool_Get(t *testing.T) {
wg.Wait()

if p.Len() != 0 {
t.Errorf("Get error. Expecting %d, got %d",
(InitialCap - 1), p.Len())
}

_, err = p.Get()
if err != ErrMaxActiveConnReached {
t.Errorf("Get error: %s", err)
t.Errorf("Get error. Expecting %d, got %d", InitialCap-1, p.Len())
}

}

func TestPool_Put(t *testing.T) {
pconf := Config{InitialCap: InitialCap, MaxCap: MaximumCap, Factory: factory, Close: closeFac, IdleTimeout: time.Second * 20,
MaxIdle:MaxIdleCap}
pconf := Config{
InitialCap: InitialCap,
MaxCap: MaximumCap,
Factory: factory,
Close: closeFac,
IdleTimeout: time.Second * 20,
MaxIdle: MaxIdleCap,
}
p, err := NewChannelPool(&pconf)
if err != nil {
t.Fatal(err)
Expand Down Expand Up @@ -254,8 +250,14 @@ func TestPoolConcurrent2(t *testing.T) {
//}

func newChannelPool() (Pool, error) {
pconf := Config{InitialCap: InitialCap, MaxCap: MaximumCap, Factory: factory, Close: closeFac, IdleTimeout: time.Second * 20,
MaxIdle:MaxIdleCap}
pconf := Config{
InitialCap: InitialCap,
MaxCap: MaximumCap,
Factory: factory,
Close: closeFac,
IdleTimeout: time.Second * 20,
MaxIdle: MaxIdleCap,
}
return NewChannelPool(&pconf)
}

Expand All @@ -264,11 +266,11 @@ func rpcServer() {
rpc.Register(arith)
rpc.HandleHTTP()

l, e := net.Listen("tcp", address)
l, e := net.Listen(network, address)
if e != nil {
panic(e)
}
go http.Serve(l, nil)
http.Serve(l, nil)
}

type Args struct {
Expand Down