Skip to content

Commit

Permalink
Merge pull request #3149 from ipfs/test/fdlimit-raising
Browse files Browse the repository at this point in the history
fdlimit: improve fdlimit autoraising tests
  • Loading branch information
whyrusleeping authored Sep 3, 2016
2 parents 309535c + af914c5 commit 1f387af
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
9 changes: 8 additions & 1 deletion cmd/ipfs/ulimit_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,25 @@ func checkAndSetUlimit() error {
return fmt.Errorf("error getting rlimit: %s", err)
}

var setting bool
if rLimit.Cur < ipfsFileDescNum {
if rLimit.Max < ipfsFileDescNum {
log.Error("adjusting max")
rLimit.Max = ipfsFileDescNum
}
fmt.Printf("Adjusting current ulimit to %d.\n", ipfsFileDescNum)
fmt.Printf("Adjusting current ulimit to %d...\n", ipfsFileDescNum)
rLimit.Cur = ipfsFileDescNum
setting = true
}

err = syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit)
if err != nil {
return fmt.Errorf("error setting ulimit: %s", err)
}

if setting {
fmt.Printf("Successfully raised file descriptor limit to %d.\n", ipfsFileDescNum)
}

return nil
}
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,12 @@
"hash": "QmVvJ27GcLaLSXvcB4auk3Gn3xuWK5ti5ENkZ2pCoJEYW4",
"name": "autobatch",
"version": "0.2.0"
},
{
"author": "whyrusleeping",
"hash": "QmdCL8M8DXJdSRnwhpDhukX5r8ydjxnzPJpaKrFudDA8yn",
"name": "hang-fds",
"version": "0.0.0"
}
],
"gxVersion": "0.4.0",
Expand Down
8 changes: 8 additions & 0 deletions test/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,18 @@ multihash_src:
$(eval MULTIHASH_HASH := $(shell cd .. && bin/gx deps find go-multihash))
$(eval MULTIHASH_SRC := gx/ipfs/$(MULTIHASH_HASH)/go-multihash)

hang-fds_src:
$(eval HANG_FDS_HASH := $(shell cd .. && bin/gx deps find hang-fds))
$(eval HANG_FDS_SRC := gx/ipfs/$(HANG_FDS_HASH)/hang-fds)

bin/multihash: multihash_src $(call find_go_files, $(MULTIHASH_SRC)) IPFS-BUILD-OPTIONS
@echo "*** installing $@ ***"
go build $(GOFLAGS) -o bin/multihash $(MULTIHASH_SRC)/multihash

bin/hang-fds: hang-fds_src $(call find_go_files, $(HANG_FDS_SRC)) IPFS-BUILD-OPTIONS
@echo "*** installing $@ ***"
go build $(GOFLAGS) -o bin/hang-fds $(HANG_FDS_SRC)

iptb_src:
$(eval IPTB_HASH := $(shell cd .. && bin/gx deps find iptb))
$(eval IPTB_SRC := gx/ipfs/$(IPTB_HASH)/iptb)
Expand Down
2 changes: 1 addition & 1 deletion test/sharness/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
BINS = bin/random bin/multihash bin/ipfs bin/pollEndpoint \
bin/iptb bin/go-sleep bin/random-files bin/go-timeout
bin/iptb bin/go-sleep bin/random-files bin/go-timeout bin/hang-fds
SHARNESS = lib/sharness/sharness.sh
IPFS_ROOT = ../..

Expand Down
12 changes: 10 additions & 2 deletions test/sharness/t0060-daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,20 @@ test_expect_success "daemon with pipe eventually becomes live" '
test_fsh cat stdin_daemon_out || test_fsh cat stdin_daemon_err || test_fsh cat stdin_poll_apiout || test_fsh cat stdin_poll_apierr
'

ulimit -n 512
ulimit -S -n 512
TEST_ULIMIT_PRESET=1
test_launch_ipfs_daemon

test_expect_success "daemon raised its fd limit" '
grep "ulimit" actual_daemon > /dev/null
grep "raised file descriptor limit to 1024." actual_daemon > /dev/null
'

test_expect_success "daemon actually can handle 1024 file descriptors" '
hang-fds -hold=2s 1000 '$API_MADDR'
'

test_expect_success "daemon didnt throw any errors" '
test_expect_code 1 grep "too many open files" daemon_err
'

test_kill_ipfs_daemon
Expand Down

0 comments on commit 1f387af

Please sign in to comment.