|
| 1 | +/* |
| 2 | +Copyright 2024 Feast Community. |
| 3 | +
|
| 4 | +Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +you may not use this file except in compliance with the License. |
| 6 | +You may obtain a copy of the License at |
| 7 | +
|
| 8 | + http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +
|
| 10 | +Unless required by applicable law or agreed to in writing, software |
| 11 | +distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +See the License for the specific language governing permissions and |
| 14 | +limitations under the License. |
| 15 | +*/ |
| 16 | + |
| 17 | +package services |
| 18 | + |
| 19 | +import ( |
| 20 | + . "github.com/onsi/ginkgo/v2" |
| 21 | + . "github.com/onsi/gomega" |
| 22 | + |
| 23 | + feastdevv1 "github.com/feast-dev/feast/infra/feast-operator/api/v1" |
| 24 | +) |
| 25 | + |
| 26 | +var _ = Describe("ApplyDefaultsToStatus", func() { |
| 27 | + It("deploys the online store with defaults when it is not declared", func() { |
| 28 | + cr := &feastdevv1.FeatureStore{ |
| 29 | + Spec: feastdevv1.FeatureStoreSpec{ |
| 30 | + FeastProject: "test_project", |
| 31 | + Services: &feastdevv1.FeatureStoreServices{}, |
| 32 | + }, |
| 33 | + } |
| 34 | + |
| 35 | + ApplyDefaultsToStatus(cr) |
| 36 | + |
| 37 | + online := cr.Status.Applied.Services.OnlineStore |
| 38 | + Expect(online).ToNot(BeNil()) |
| 39 | + Expect(online.Disabled).To(BeFalse()) |
| 40 | + Expect(online.Persistence).ToNot(BeNil()) |
| 41 | + Expect(online.Server).ToNot(BeNil()) |
| 42 | + }) |
| 43 | + |
| 44 | + It("applies online store defaults when it is declared", func() { |
| 45 | + cr := &feastdevv1.FeatureStore{ |
| 46 | + Spec: feastdevv1.FeatureStoreSpec{ |
| 47 | + FeastProject: "test_project", |
| 48 | + Services: &feastdevv1.FeatureStoreServices{ |
| 49 | + OnlineStore: &feastdevv1.OnlineStore{}, |
| 50 | + }, |
| 51 | + }, |
| 52 | + } |
| 53 | + |
| 54 | + ApplyDefaultsToStatus(cr) |
| 55 | + |
| 56 | + online := cr.Status.Applied.Services.OnlineStore |
| 57 | + Expect(online).ToNot(BeNil()) |
| 58 | + Expect(online.Persistence).ToNot(BeNil()) |
| 59 | + Expect(online.Server).ToNot(BeNil()) |
| 60 | + }) |
| 61 | + |
| 62 | + // #6586: disabling the online store opts out of its persistence and serving |
| 63 | + // pod, letting a registry-only or offline-only FeatureStore skip it while |
| 64 | + // leaving the default-on behavior unchanged for everyone else. |
| 65 | + It("does not apply persistence or server defaults when the online store is disabled", func() { |
| 66 | + cr := &feastdevv1.FeatureStore{ |
| 67 | + Spec: feastdevv1.FeatureStoreSpec{ |
| 68 | + FeastProject: "test_project", |
| 69 | + Services: &feastdevv1.FeatureStoreServices{ |
| 70 | + OnlineStore: &feastdevv1.OnlineStore{Disabled: true}, |
| 71 | + }, |
| 72 | + }, |
| 73 | + } |
| 74 | + |
| 75 | + ApplyDefaultsToStatus(cr) |
| 76 | + |
| 77 | + online := cr.Status.Applied.Services.OnlineStore |
| 78 | + Expect(online).ToNot(BeNil()) |
| 79 | + Expect(online.Disabled).To(BeTrue()) |
| 80 | + Expect(online.Persistence).To(BeNil()) |
| 81 | + Expect(online.Server).To(BeNil()) |
| 82 | + }) |
| 83 | +}) |
0 commit comments