Skip to content

Commit

Permalink
rcmgr: test snapshot defaults and that we keep consistent defaults (#…
Browse files Browse the repository at this point in the history
…2315)

* Snapshot rcmgr defaults and test that we keep consistent defaults

* Don't use autoscaled defaults since we can't predict the env these tests will run in

* Normalize for windows
  • Loading branch information
MarcoPolo authored Jun 21, 2023
1 parent dfaeb7e commit acca7a6
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 0 deletions.
19 changes: 19 additions & 0 deletions p2p/host/resource-manager/limit_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,25 @@ func TestLimitConfigRoundTrip(t *testing.T) {
require.Equal(t, concreteCfg, concreteCfgRT)
}

func TestDefaultsDontChange(t *testing.T) {
concrete := DefaultLimits.Scale(8<<30, 16<<10) // 8GB, 16k fds
jsonBytes, err := json.MarshalIndent(concrete.ToPartialLimitConfig(), "", " ")
require.NoError(t, err)

// Uncomment to update the defaults file
// err = os.WriteFile("limit_config_test_default.json", jsonBytes, 0644)
// require.NoError(t, err)

defaultsFromFile, err := os.ReadFile("limit_config_test_default.json")
require.NoError(t, err)

// replace crlf with lf because of windows
defaultsFromFile = bytes.ReplaceAll(defaultsFromFile, []byte("\r\n"), []byte("\n"))
jsonBytes = bytes.ReplaceAll(jsonBytes, []byte("\r\n"), []byte("\n"))

require.Equal(t, string(defaultsFromFile), string(jsonBytes))
}

func TestReadmeLimitConfigSerialization(t *testing.T) {
noisyNeighbor, _ := peer.Decode("QmVvtzcZgCkMnSFf2dnrBPXrWuNFWNM9J3MpZQCvWPuVZf")
cfg := PartialLimitConfig{
Expand Down
112 changes: 112 additions & 0 deletions p2p/host/resource-manager/limit_config_test_default.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
{
"System": {
"Streams": 18432,
"StreamsInbound": 9216,
"StreamsOutbound": 18432,
"Conns": 1152,
"ConnsInbound": 576,
"ConnsOutbound": 1152,
"FD": 16384,
"Memory": "8724152320"
},
"Transient": {
"Streams": 2304,
"StreamsInbound": 1152,
"StreamsOutbound": 2304,
"Conns": 320,
"ConnsInbound": 160,
"ConnsOutbound": 320,
"FD": 4096,
"Memory": "1107296256"
},
"AllowlistedSystem": {
"Streams": 18432,
"StreamsInbound": 9216,
"StreamsOutbound": 18432,
"Conns": 1152,
"ConnsInbound": 576,
"ConnsOutbound": 1152,
"FD": 16384,
"Memory": "8724152320"
},
"AllowlistedTransient": {
"Streams": 2304,
"StreamsInbound": 1152,
"StreamsOutbound": 2304,
"Conns": 320,
"ConnsInbound": 160,
"ConnsOutbound": 320,
"FD": 4096,
"Memory": "1107296256"
},
"ServiceDefault": {
"Streams": 20480,
"StreamsInbound": 5120,
"StreamsOutbound": 20480,
"Conns": "blockAll",
"ConnsInbound": "blockAll",
"ConnsOutbound": "blockAll",
"FD": "blockAll",
"Memory": "1140850688"
},
"ServicePeerDefault": {
"Streams": 320,
"StreamsInbound": 160,
"StreamsOutbound": 320,
"Conns": "blockAll",
"ConnsInbound": "blockAll",
"ConnsOutbound": "blockAll",
"FD": "blockAll",
"Memory": "50331648"
},
"ProtocolDefault": {
"Streams": 6144,
"StreamsInbound": 2560,
"StreamsOutbound": 6144,
"Conns": "blockAll",
"ConnsInbound": "blockAll",
"ConnsOutbound": "blockAll",
"FD": "blockAll",
"Memory": "1442840576"
},
"ProtocolPeerDefault": {
"Streams": 384,
"StreamsInbound": 96,
"StreamsOutbound": 192,
"Conns": "blockAll",
"ConnsInbound": "blockAll",
"ConnsOutbound": "blockAll",
"FD": "blockAll",
"Memory": "16777248"
},
"PeerDefault": {
"Streams": 2560,
"StreamsInbound": 1280,
"StreamsOutbound": 2560,
"Conns": 8,
"ConnsInbound": 8,
"ConnsOutbound": 8,
"FD": 256,
"Memory": "1140850688"
},
"Conn": {
"Streams": "blockAll",
"StreamsInbound": "blockAll",
"StreamsOutbound": "blockAll",
"Conns": 1,
"ConnsInbound": 1,
"ConnsOutbound": 1,
"FD": 1,
"Memory": "33554432"
},
"Stream": {
"Streams": 1,
"StreamsInbound": 1,
"StreamsOutbound": 1,
"Conns": "blockAll",
"ConnsInbound": "blockAll",
"ConnsOutbound": "blockAll",
"FD": "blockAll",
"Memory": "16777216"
}
}

0 comments on commit acca7a6

Please sign in to comment.