mirror of
https://github.com/hashicorp/vault.git
synced 2026-04-04 21:32:21 +02:00
* Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Adding explicit MPL license for sub-package. This directory and its subdirectories (packages) contain files licensed with the MPLv2 `LICENSE` file in this directory and are intentionally licensed separately from the BSL `LICENSE` file at the root of this repository. * Updating the license from MPL to Business Source License. Going forward, this project will be licensed under the Business Source License v1.1. Please see our blog post for more details at https://hashi.co/bsl-blog, FAQ at www.hashicorp.com/licensing-faq, and details of the license at www.hashicorp.com/bsl. * add missing license headers * Update copyright file headers to BUS-1.1 * Fix test that expected exact offset on hcl file --------- Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com> Co-authored-by: Sarah Thompson <sthompson@hashicorp.com> Co-authored-by: Brian Kassouf <bkassouf@hashicorp.com>
72 lines
1.6 KiB
Go
72 lines
1.6 KiB
Go
// Copyright (c) HashiCorp, Inc.
|
|
// SPDX-License-Identifier: BUSL-1.1
|
|
|
|
package transit
|
|
|
|
import (
|
|
"context"
|
|
"testing"
|
|
|
|
"github.com/hashicorp/vault/sdk/logical"
|
|
)
|
|
|
|
func BenchmarkTransit_BatchEncryption1(b *testing.B) {
|
|
BTransit_BatchEncryption(b, 1)
|
|
}
|
|
|
|
func BenchmarkTransit_BatchEncryption10(b *testing.B) {
|
|
BTransit_BatchEncryption(b, 10)
|
|
}
|
|
|
|
func BenchmarkTransit_BatchEncryption50(b *testing.B) {
|
|
BTransit_BatchEncryption(b, 50)
|
|
}
|
|
|
|
func BenchmarkTransit_BatchEncryption100(b *testing.B) {
|
|
BTransit_BatchEncryption(b, 100)
|
|
}
|
|
|
|
func BenchmarkTransit_BatchEncryption1000(b *testing.B) {
|
|
BTransit_BatchEncryption(b, 1_000)
|
|
}
|
|
|
|
func BenchmarkTransit_BatchEncryption10000(b *testing.B) {
|
|
BTransit_BatchEncryption(b, 10_000)
|
|
}
|
|
|
|
func BTransit_BatchEncryption(b *testing.B, bsize int) {
|
|
b.StopTimer()
|
|
|
|
var resp *logical.Response
|
|
var err error
|
|
|
|
backend, s := createBackendWithStorage(b)
|
|
|
|
batchEncryptionInput := make([]interface{}, 0, bsize)
|
|
for i := 0; i < bsize; i++ {
|
|
batchEncryptionInput = append(
|
|
batchEncryptionInput,
|
|
map[string]interface{}{"plaintext": "dGhlIHF1aWNrIGJyb3duIGZveA=="},
|
|
)
|
|
}
|
|
|
|
batchEncryptionData := map[string]interface{}{
|
|
"batch_input": batchEncryptionInput,
|
|
}
|
|
|
|
batchEncryptionReq := &logical.Request{
|
|
Operation: logical.CreateOperation,
|
|
Path: "encrypt/upserted_key",
|
|
Storage: s,
|
|
Data: batchEncryptionData,
|
|
}
|
|
|
|
b.StartTimer()
|
|
for i := 0; i < b.N; i++ {
|
|
resp, err = backend.HandleRequest(context.Background(), batchEncryptionReq)
|
|
if err != nil || (resp != nil && resp.IsError()) {
|
|
b.Fatalf("err:%v resp:%#v", err, resp)
|
|
}
|
|
}
|
|
}
|