server/config: fix MonitorPluginConfiguration test

The test was comparing the same configuration to itself, since
nothing in the changed CNI configuration is used in the written
multus configuration.

Instead make sure the updated CNI config contains something
that will be reflected in the written multus configuration,
and while we're there use a more robust way to wait for the
config to be written via gomega.Eventually().

Signed-off-by: Dan Williams <dcbw@redhat.com>
This commit is contained in:
Dan Williams
2023-09-12 21:18:32 -05:00
parent 8539a476fd
commit c2add82b93

View File

@@ -20,7 +20,6 @@ import (
"fmt"
"os"
"sync"
"time"
. "github.com/onsi/ginkgo/v2"
. "github.com/onsi/gomega"
@@ -104,12 +103,9 @@ var _ = Describe("Configuration Manager", func() {
})
It("Check MonitorPluginConfiguration", func() {
config, err := configManager.GenerateConfig()
Expect(err).NotTo(HaveOccurred())
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
err = configManager.Start(ctx, wg)
err := configManager.Start(ctx, wg)
Expect(err).NotTo(HaveOccurred())
updatedCNIConfig := `
@@ -117,6 +113,7 @@ var _ = Describe("Configuration Manager", func() {
"cniVersion": "0.4.0",
"name": "mycni-name",
"type": "mycni2",
"capabilities": {"portMappings": true},
"ipam": {},
"dns": {}
}
@@ -125,10 +122,11 @@ var _ = Describe("Configuration Manager", func() {
Expect(os.WriteFile(defaultCniConfig, []byte(updatedCNIConfig), UserRWPermission)).To(Succeed())
// wait for a while to get fsnotify event
time.Sleep(100 * time.Millisecond)
file, err := os.ReadFile(configManager.multusConfigFilePath)
Expect(err).NotTo(HaveOccurred())
Expect(string(file)).To(Equal(config))
Eventually(func() string {
file, err := os.ReadFile(configManager.multusConfigFilePath)
Expect(err).NotTo(HaveOccurred())
return string(file)
}, 2).Should(ContainSubstring("portMappings"))
})
When("the user requests the name of the multus configuration to be overridden", func() {