Documentation
¶
Index ¶
- Constants
- Variables
- func NewConfigMapMessage(configMap *v1.ConfigMap, operation string) *beehivemodel.Message
- func NewObjectSync(object v12.Object, kind string) *v1alpha1.ObjectSync
- func NewPodMessage(pod *v1.Pod, operation string) *beehivemodel.Message
- func NewTestConfigMapResource(name, UID, resourceVersion string) *v1.ConfigMap
- func NewTestPodResource(name, UID, resourceVersion string) *v1.Pod
- type ObjectSyncReactor
- func (r *ObjectSyncReactor) AddObjectSync(objectSync *v1alpha1.ObjectSync)
- func (r *ObjectSyncReactor) AddObjectSyncs(objectSyncs []*v1alpha1.ObjectSync)
- func (r *ObjectSyncReactor) CheckObjectSyncs(expectedObjectSyncs []*v1alpha1.ObjectSync) error
- func (r *ObjectSyncReactor) DeleteObjectSync(name string)
- func (r *ObjectSyncReactor) React(action core.Action) (handled bool, ret runtime.Object, err error)
- type ReactorError
- type TestCase
Constants ¶
const ( TestNodeID = "foo-node" TestProjectID = "foo-project" TestNamespace = "foo-ns" TestPodName = "foo-pod" TestConfigMapName = "foo-config" TestPodUID = "c7399134-f4fb-43e6-8088-c273bfffe7af" TestDiffPodUID = "c7399134-f4fb-43e6-8088-c273bfffe999" TestConfigMapUID = "22b0074a-8c07-4fc2-adad-1589f7f6f8b1" KeepaliveInterval = 2 * time.Second NormalSendKeepaliveInterval = 1 * time.Second AbnormalSendKeepaliveInterval = 3 * time.Second )
Variables ¶
var ( NoErrors []ReactorError NoObjectSyncs []*v1alpha1.ObjectSync )
var ErrVersionConflict = errors.New("VersionError")
ErrVersionConflict is the error returned when resource version of requested object conflicts with the object in storage.
Functions ¶
func NewConfigMapMessage ¶
func NewConfigMapMessage(configMap *v1.ConfigMap, operation string) *beehivemodel.Message
func NewObjectSync ¶
func NewObjectSync(object v12.Object, kind string) *v1alpha1.ObjectSync
func NewPodMessage ¶
func NewPodMessage(pod *v1.Pod, operation string) *beehivemodel.Message
func NewTestPodResource ¶
Types ¶
type ObjectSyncReactor ¶
type ObjectSyncReactor struct {
// contains filtered or unexported fields
}
ObjectSyncReactor is a core.Reactor that simulates etcd and API server. It stores:
- Latest version of objectSyncs saved by the session.
- Optionally, list of error that should be returned by reactor, simulating etcd / API server failures. These errors are evaluated in order and every error is returned only once. I.e. when the reactor finds matching ReactorError, it return appropriate error and removes the ReactorError from the list.
func NewObjectSyncReactor ¶
func NewObjectSyncReactor(client *fake.Clientset, errors []ReactorError) *ObjectSyncReactor
NewObjectSyncReactor creates a ObjectSync reactor.
func (*ObjectSyncReactor) AddObjectSync ¶
func (r *ObjectSyncReactor) AddObjectSync(objectSync *v1alpha1.ObjectSync)
AddObjectSync adds a objectSync into ObjectSyncReactor.
func (*ObjectSyncReactor) AddObjectSyncs ¶
func (r *ObjectSyncReactor) AddObjectSyncs(objectSyncs []*v1alpha1.ObjectSync)
AddObjectSyncs adds objectSyncs into ObjectSyncReactor.
func (*ObjectSyncReactor) CheckObjectSyncs ¶
func (r *ObjectSyncReactor) CheckObjectSyncs(expectedObjectSyncs []*v1alpha1.ObjectSync) error
CheckObjectSyncs compares all expectedObjectSyncs with set of objectSyncs at the end of the test and reports differences.
func (*ObjectSyncReactor) DeleteObjectSync ¶
func (r *ObjectSyncReactor) DeleteObjectSync(name string)
DeleteObjectSync deletes a objectSync by name.
func (*ObjectSyncReactor) React ¶
React is a callback called by fake kubeClient from the controller. In other words, every objectSync change performed by the session ends here. This callback checks versions of the updated objects and refuse those that are too old (simulating real etcd). All updated objects are stored locally to keep track of object versions and to evaluate test results.
type ReactorError ¶
ReactorError is an error that is returned by test reactor (=simulated etcd+/API server) when an action performed by the reactor matches given verb ("get", "update", "create", "delete" or "*"") on given resource ("objectsyncs" or "*").
type TestCase ¶
type TestCase struct { // Name of the test, for logging Name string // Initial content of ObjectSync cache. InitialObjectSyncs []*v1alpha1.ObjectSync // Expected content of ObjectSync cache at the end of the test. ExpectedObjectSyncs []*v1alpha1.ObjectSync // Expected message store in node message pool ExpectedStoreMessage *beehivemodel.Message // reactorErrors to produce on matching ObjectSync action ReactorErrors []ReactorError // injectedConnErrTimes the connection write err times, used for node session test InjectedConnErrTimes int // Initial content of message cache. InitialMessages []*beehivemodel.Message // CurrentArriveMessage current arrive message CurrentArriveMessage *beehivemodel.Message // Simulate downstream message from edgeController or syncController SimulateMessageFunc func(pool *common.NodeMessagePool, messages []*beehivemodel.Message) }