forked from TrueCloudLab/xk6-frostfs
[#4] s3: Include error message in responses
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
822c674c92
commit
0cafcd2375
2 changed files with 17 additions and 7 deletions
|
@ -13,7 +13,7 @@ export const options = {
|
||||||
|
|
||||||
export default function () {
|
export default function () {
|
||||||
const key = uuidv4();
|
const key = uuidv4();
|
||||||
if (s3_cli.put(bucket, key, payload)) {
|
if (s3_cli.put(bucket, key, payload).success) {
|
||||||
s3_cli.get(bucket, key )
|
s3_cli.get(bucket, key )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,9 +17,19 @@ type (
|
||||||
vu modules.VU
|
vu modules.VU
|
||||||
cli *s3.Client
|
cli *s3.Client
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PutResponse struct {
|
||||||
|
Success bool
|
||||||
|
Error string
|
||||||
|
}
|
||||||
|
|
||||||
|
GetResponse struct {
|
||||||
|
Success bool
|
||||||
|
Error string
|
||||||
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
func (c *Client) Put(bucket, key string, payload []byte) bool {
|
func (c *Client) Put(bucket, key string, payload []byte) PutResponse {
|
||||||
rdr := bytes.NewReader(payload)
|
rdr := bytes.NewReader(payload)
|
||||||
sz := rdr.Size()
|
sz := rdr.Size()
|
||||||
|
|
||||||
|
@ -33,15 +43,15 @@ func (c *Client) Put(bucket, key string, payload []byte) bool {
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.Report(c.vu, objPutFails, 1)
|
stats.Report(c.vu, objPutFails, 1)
|
||||||
return false
|
return PutResponse{Success: false, Error: err.Error()}
|
||||||
}
|
}
|
||||||
|
|
||||||
stats.ReportDataSent(c.vu, float64(sz))
|
stats.ReportDataSent(c.vu, float64(sz))
|
||||||
stats.Report(c.vu, objPutDuration, metrics.D(time.Since(start)))
|
stats.Report(c.vu, objPutDuration, metrics.D(time.Since(start)))
|
||||||
return true
|
return PutResponse{Success: true}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) Get(bucket, key string) bool {
|
func (c *Client) Get(bucket, key string) GetResponse {
|
||||||
var (
|
var (
|
||||||
buf = make([]byte, 4*1024)
|
buf = make([]byte, 4*1024)
|
||||||
sz int
|
sz int
|
||||||
|
@ -54,7 +64,7 @@ func (c *Client) Get(bucket, key string) bool {
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
stats.Report(c.vu, objGetFails, 1)
|
stats.Report(c.vu, objGetFails, 1)
|
||||||
return false
|
return GetResponse{Success: false, Error: err.Error()}
|
||||||
}
|
}
|
||||||
stats.Report(c.vu, objGetDuration, metrics.D(time.Since(start)))
|
stats.Report(c.vu, objGetDuration, metrics.D(time.Since(start)))
|
||||||
for {
|
for {
|
||||||
|
@ -67,5 +77,5 @@ func (c *Client) Get(bucket, key string) bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
stats.ReportDataReceived(c.vu, float64(sz))
|
stats.ReportDataReceived(c.vu, float64(sz))
|
||||||
return true
|
return GetResponse{Success: true}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue