[#50] Use native.connect timeouts everywhere

Also, use defaults from the SDK itself, allow user to provide 0.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2023-01-10 10:29:50 +03:00 committed by Alex Vanin
parent b24baf06ca
commit e52a315752
6 changed files with 17 additions and 6 deletions

View file

@ -45,10 +45,12 @@ xk6 build --with github.com/TrueCloudLab/xk6-frostfs=.
Create native client with `connect` method. Arguments:
- frostfs storage node endpoint
- hex encoded private key (empty value produces random key)
- dial timeout in seconds (0 for the default value)
- stream timeout in seconds (0 for the default value)
```js
import native from 'k6/x/frostfs/native';
const frostfs_cli = native.connect("s01.frostfs.devenv:8080", "")
const frostfs_cli = native.connect("s01.frostfs.devenv:8080", "", 0, 0)
```
### Methods

View file

@ -3,7 +3,7 @@ import {fail} from "k6";
import native from 'k6/x/frostfs/native';
const payload = open('../go.sum', 'b');
const frostfs_cli = native.connect("s01.frostfs.devenv:8080", "1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb")
const frostfs_cli = native.connect("s01.frostfs.devenv:8080", "1dd37fba80fec4e6a6f13fd708d8dcb3b29def768017052f6c930fa1c5d90bbb", 0, 0)
export const options = {
stages: [

View file

@ -3,7 +3,7 @@ import native from 'k6/x/frostfs/native';
const payload = open('../go.sum', 'b');
const container = "AjSxSNNXbJUDPqqKYm1VbFVDGCakbpUNH8aGjPmGAH3B"
const frostfs_cli = native.connect("s01.frostfs.devenv:8080", "")
const frostfs_cli = native.connect("s01.frostfs.devenv:8080", "", 0, 0)
const frostfs_obj = frostfs_cli.onsite(container, payload)
export const options = {

View file

@ -74,8 +74,13 @@ func (n *Native) Connect(endpoint, hexPrivateKey string, dialTimeout, streamTime
var prmDial client.PrmDial
prmDial.SetServerURI(endpoint)
prmDial.SetTimeout(time.Duration(dialTimeout) * time.Second)
prmDial.SetStreamTimeout(time.Duration(streamTimeout) * time.Second)
if dialTimeout > 0 {
prmDial.SetTimeout(time.Duration(dialTimeout) * time.Second)
}
if streamTimeout > 0 {
prmDial.SetStreamTimeout(time.Duration(streamTimeout) * time.Second)
}
err = cli.Dial(prmDial)
if err != nil {

View file

@ -39,6 +39,8 @@ Options (in addition to the common options):
* `DELETERS` - number of VUs performing delete operations (using deleters requires that options `DELETE_AGE` and `REGISTRY_FILE` are specified as well).
* `DELETE_AGE` - age of object in seconds before which it can not be deleted. This parameter can be used to control how many objects we have in the system under load.
* `SLEEP_DELETE` - time interval (in seconds) between deleting VU iterations.
* `DIAL_TIMEOUT` - timeout to connect to a node (in seconds).
* `STREAM_TIMEOUT` - timeout for a single stream message for `PUT`/`GET` operations (in seconds).
## HTTP
@ -121,6 +123,8 @@ Options:
* `REGISTRY_FILE` - database file from which objects for verification should be read.
* `SLEEP` - time interval (in seconds) between VU iterations.
* `SELECTION_SIZE` - size of batch to select for deletion (default: 1000).
* `DIAL_TIMEOUT` - timeout to connect to a node (in seconds).
* `STREAM_TIMEOUT` - timeout for a single stream message for `PUT`/`GET` operations (in seconds).
## Verify preset

View file

@ -25,7 +25,7 @@ let grpc_client = undefined;
if (__ENV.GRPC_ENDPOINTS) {
const grpcEndpoints = __ENV.GRPC_ENDPOINTS.split(',');
const grpcEndpoint = grpcEndpoints[Math.floor(Math.random() * grpcEndpoints.length)];
grpc_client = native.connect(grpcEndpoint, '');
grpc_client = native.connect(grpcEndpoint, '', __ENV.DIAL_TIMEOUT ? parseInt(__ENV.DIAL_TIMEOUT) : 0, __ENV.STREAM_TIMEOUT ? parseInt(__ENV.STREAM_TIMEOUT) : 0);
}
// Connect to random S3 endpoint