-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
node-installer: add test for kata config
- Loading branch information
Showing
3 changed files
with
48 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// Copyright 2024 Edgeless Systems GmbH | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
package config_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/edgelesssys/contrast/internal/platforms" | ||
"github.com/edgelesssys/contrast/nodeinstaller/internal/constants" | ||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestKataConfig(t *testing.T) { | ||
// This is a regression test that ensures the `agent.kata` section is not optimized away. Empty | ||
// section and no section are handled differently by Kata, so we make sure that this section is | ||
// always present. | ||
for _, platform := range platforms.All() { | ||
t.Run(platform.String(), func(t *testing.T) { | ||
require := require.New(t) | ||
assert := assert.New(t) | ||
cfg, err := constants.KataRuntimeConfig("/", platform, "", false) | ||
require.NoError(err) | ||
configBytes, err := cfg.Marshal() | ||
require.NoError(err) | ||
assert.Contains(string(configBytes), "[Agent.kata]") | ||
assert.Contains(string(configBytes), "[Runtime]") | ||
|
||
switch platform { | ||
case platforms.K3sQEMUSNP, platforms.K3sQEMUTDX, platforms.MetalQEMUSNP, platforms.MetalQEMUTDX, platforms.RKE2QEMUTDX: | ||
assert.Contains(string(configBytes), "[Hypervisor.qemu]") | ||
case platforms.AKSCloudHypervisorSNP: | ||
assert.Contains(string(configBytes), "[Hypervisor.clh]") | ||
default: | ||
assert.Fail("missing hypervisor test expectations") | ||
} | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters