mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-03 14:54:53 -04:00

keyservice joinservice upgrade-agent measurement-reader debugd disk-mapper rewrote joinservice main rewrote some unit tests rewrote upgrade-agent + some grpc functions rewrote measurement-reader rewrote debugd removed unused import removed forgotten zap reference in measurements reader rewrote disk-mapper + tests rewrote packages verify disk-mapper malicious join bootstrapper attestationconfigapi versionapi internal/cloud/azure disk-mapper tests image/upload/internal/cmd rewrote verify (WIP with loglevel increase) rewrote forgotten zap references in disk-mapper rewrote malicious join rewrote bootstrapper rewrote parts of internal/ rewrote attestationconfigapi (WIP) rewrote versionapi cli rewrote internal/cloud/azure rewrote disk-mapper tests (untested by me rn) rewrote image/upload/internal/cmd removed forgotten zap references in verify/cmd rewrote packages hack/oci-pin hack/qemu-metadata-api debugd/internal/debugd/deploy hack/bazel-deps-mirror cli/internal/cmd cli-k8s-compatibility rewrote hack/qemu-metadata-api/server rewrote debugd/internal/debugd/deploy rewrote hack/bazel-deps-mirror rewrote rest of hack/qemu-metadata-api rewrote forgotten zap references in joinservice server rewrote cli/internal/cmd rewrote cli-k8s-compatibility rewrote packages internal/staticupload e2d/internal/upgrade internal/constellation/helm internal/attestation/aws/snp internal/attestation/azure/trustedlaunch joinservice/internal/certcache/amkds some missed unit tests rewrote e2e/internal/upgrade rewrote internal/constellation/helm internal/attestation/aws/snp internal/attestation/azure/trustedlaunch joinservice/internal/certcache/amkds search and replace test logging over all left *_test.go
113 lines
2.3 KiB
Go
113 lines
2.3 KiB
Go
//go:build integration && cgo && linux
|
|
|
|
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package integration
|
|
|
|
import (
|
|
"fmt"
|
|
"math"
|
|
"testing"
|
|
"log/slog"
|
|
|
|
"github.com/edgelesssys/constellation/v2/disk-mapper/internal/diskencryption"
|
|
"github.com/martinjungblut/go-cryptsetup"
|
|
)
|
|
|
|
func BenchmarkMapper(b *testing.B) {
|
|
cryptsetup.SetDebugLevel(cryptsetup.CRYPT_LOG_ERROR)
|
|
cryptsetup.SetLogCallback(func(_ int, message string) { fmt.Println(message) })
|
|
|
|
testPath := *diskPath
|
|
if testPath == "" {
|
|
// no disk specified, use 1GB loopback disk
|
|
testPath = devicePath
|
|
if err := setup(1); err != nil {
|
|
b.Fatal("Failed to setup test environment:", err)
|
|
}
|
|
|
|
defer func() {
|
|
if err := teardown(); err != nil {
|
|
b.Fatal("failed to delete test disk:", err)
|
|
}
|
|
}()
|
|
}
|
|
|
|
passphrase := "benchmark"
|
|
mapper, free, err := diskencryption.New(testPath, slog.New(slog.NewPlainTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo})))
|
|
if err != nil {
|
|
b.Fatal("Failed to create mapper:", err)
|
|
}
|
|
defer free()
|
|
|
|
if err := mapper.FormatDisk(passphrase); err != nil {
|
|
b.Fatal("Failed to format disk:", err)
|
|
}
|
|
|
|
testCases := map[string]struct {
|
|
wipeBlockSize int
|
|
}{
|
|
"16KiB": {
|
|
wipeBlockSize: int(math.Pow(2, 14)),
|
|
},
|
|
"32KiB": {
|
|
wipeBlockSize: int(math.Pow(2, 15)),
|
|
},
|
|
"64KiB": {
|
|
wipeBlockSize: int(math.Pow(2, 16)),
|
|
},
|
|
"128KiB": {
|
|
wipeBlockSize: int(math.Pow(2, 17)),
|
|
},
|
|
"256KiB": {
|
|
wipeBlockSize: int(math.Pow(2, 18)),
|
|
},
|
|
"512KiB": {
|
|
wipeBlockSize: int(math.Pow(2, 19)),
|
|
},
|
|
"1MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 20)),
|
|
},
|
|
"2MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 21)),
|
|
},
|
|
"4MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 22)),
|
|
},
|
|
"8MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 23)),
|
|
},
|
|
"16MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 24)),
|
|
},
|
|
"32MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 25)),
|
|
},
|
|
"64MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 26)),
|
|
},
|
|
"128MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 27)),
|
|
},
|
|
"256MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 28)),
|
|
},
|
|
"512MiB": {
|
|
wipeBlockSize: int(math.Pow(2, 29)),
|
|
},
|
|
}
|
|
|
|
for name, tc := range testCases {
|
|
b.Run(name, func(b *testing.B) {
|
|
for i := 0; i < b.N; i++ {
|
|
if err := mapper.Wipe(tc.wipeBlockSize); err != nil {
|
|
b.Fatal("Failed to wipe disk:", err)
|
|
}
|
|
}
|
|
})
|
|
}
|
|
}
|