-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix TLS setup when cluster driver notifies plugin with client updates
- Loading branch information
1 parent
6323bd1
commit 2ce8d10
Showing
5 changed files
with
79 additions
and
7 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
plugins/alerting/pkg/alerting/drivers/alerting_manager/alerting_manager_suite_test.go
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,15 @@ | ||
package alerting_manager_test | ||
|
||
import ( | ||
"testing" | ||
|
||
_ "github.com/rancher/opni/pkg/test/setup" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
) | ||
|
||
func TestAlertingManager(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "AlertingManager Suite") | ||
} |
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
48 changes: 48 additions & 0 deletions
48
plugins/alerting/pkg/alerting/drivers/alerting_manager/driver_test.go
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,48 @@ | ||
package alerting_manager_test | ||
|
||
import ( | ||
"crypto/tls" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
"github.com/rancher/opni/pkg/alerting/client" | ||
"github.com/rancher/opni/pkg/alerting/shared" | ||
"github.com/rancher/opni/pkg/logger" | ||
"github.com/rancher/opni/pkg/plugins/driverutil" | ||
"github.com/rancher/opni/plugins/alerting/pkg/alerting/drivers/alerting_manager" | ||
) | ||
|
||
var _ = Describe("", Label("unit"), func() { | ||
When("We register the alering cluster driver", func() { | ||
It("should apply the tls config via driver options", func() { | ||
tlsConfig := &tls.Config{} | ||
opts := []driverutil.Option{ | ||
driverutil.NewOption("tlsConfig", tlsConfig), | ||
} | ||
|
||
options := alerting_manager.AlertingDriverOptions{ | ||
ConfigKey: shared.AlertManagerConfigKey, | ||
InternalRoutingKey: shared.InternalRoutingConfigKey, | ||
Logger: logger.NewPluginLogger().WithGroup("alerting").WithGroup("alerting-manager"), | ||
} | ||
driverutil.ApplyOptions(&options, opts...) | ||
Expect(options.TlsConfig).NotTo(BeNil()) | ||
}) | ||
|
||
It("should apply cluster driver subscribers via driver options", func() { | ||
subscriberA := make(chan client.AlertingClient) | ||
subscriberB := make(chan client.AlertingClient) | ||
opts := []driverutil.Option{ | ||
driverutil.NewOption("subscribers", []chan client.AlertingClient{subscriberA, subscriberB}), | ||
} | ||
|
||
options := alerting_manager.AlertingDriverOptions{ | ||
ConfigKey: shared.AlertManagerConfigKey, | ||
InternalRoutingKey: shared.InternalRoutingConfigKey, | ||
Logger: logger.NewPluginLogger().WithGroup("alerting").WithGroup("alerting-manager"), | ||
} | ||
driverutil.ApplyOptions(&options, opts...) | ||
Expect(options.Subscribers).To(HaveLen(2)) | ||
}) | ||
}) | ||
}) |
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