Files
my-rook-config/tests/framework/clients/notification.go
T
Joshua Hoblitt dcd4dfb2bd docs: fix function comments to match their declaration names
Several godoc comments led with a stale or incorrect identifier, left
over from renames, exported/unexported changes, copy-paste between
sibling declarations, or plain typos. As a result the documented name no
longer matched the function, method, type, or var it describes. Correct
each leading word to the name of the declaration it documents.

Signed-off-by: Joshua Hoblitt <josh@hoblitt.com>
(cherry picked from commit 49612461a4)
2026-06-29 19:04:45 +00:00

76 lines
2.6 KiB
Go

/*
Copyright 2021 The Rook Authors. All rights reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package clients
import (
"strings"
"time"
"github.com/rook/rook/tests/framework/installer"
"github.com/rook/rook/tests/framework/utils"
)
// TopicOperation is a wrapper for rook notification operations
type NotificationOperation struct {
k8sh *utils.K8sHelper
manifests installer.CephManifests
}
// CreateTopicOperation creates a new topic client
func CreateNotificationOperation(k8sh *utils.K8sHelper, manifests installer.CephManifests) *NotificationOperation {
return &NotificationOperation{k8sh, manifests}
}
func (n *NotificationOperation) CreateNotification(notificationName string, topicName string) error {
return n.k8sh.ResourceOperation("create", n.manifests.GetBucketNotification(notificationName, topicName))
}
func (n *NotificationOperation) DeleteNotification(notificationName string, topicName string) error {
return n.k8sh.ResourceOperation("delete", n.manifests.GetBucketNotification(notificationName, topicName))
}
func (n *NotificationOperation) UpdateNotification(notificationName string, topicName string) error {
return n.k8sh.ResourceOperation("apply", n.manifests.GetBucketNotification(notificationName, topicName))
}
// CheckNotificationCR if notification was set
func (t *NotificationOperation) CheckNotificationCR(notificationName string) bool {
// TODO: return result based on reconcile status of the CR
const resourceName = "cephbucketnotification"
_, err := t.k8sh.GetResource(resourceName, notificationName)
if err != nil {
logger.Infof("%q %q does not exist", resourceName, notificationName)
return false
}
return true
}
func (t *NotificationOperation) CheckNotificationFromHTTPEndPoint(appLabel, eventName, fileName string) (bool, error) {
// wait for the notification to reach http-server
time.Sleep(5 * time.Second)
selectorName := "--selector=" + appLabel
l, err := t.k8sh.Kubectl("logs", selectorName, "--tail", "5")
if err != nil {
return false, err
}
if strings.Contains(l, eventName) && strings.Contains(l, fileName) {
return true, nil
}
return false, nil
}