@@ -22,6 +22,7 @@ import (
22
22
. "github.com/onsi/gomega"
23
23
v1 "k8s.io/api/apps/v1"
24
24
corev1 "k8s.io/api/core/v1"
25
+ apierrors "k8s.io/apimachinery/pkg/api/errors"
25
26
"k8s.io/apimachinery/pkg/api/meta"
26
27
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
27
28
"k8s.io/apimachinery/pkg/types"
@@ -31,6 +32,7 @@ import (
31
32
testobjects "github.com/ydb-platform/ydb-kubernetes-operator/e2e/tests/test-objects"
32
33
. "github.com/ydb-platform/ydb-kubernetes-operator/internal/controllers/constants"
33
34
"github.com/ydb-platform/ydb-kubernetes-operator/internal/resources"
35
+ "github.com/ydb-platform/ydb-kubernetes-operator/internal/test"
34
36
)
35
37
36
38
const (
@@ -158,7 +160,7 @@ func bringYdbCliToPod(podName, podNamespace string) {
158
160
}, Timeout , Interval ).Should (BeNil ())
159
161
}
160
162
161
- func executeSimpleQuery (ctx context. Context , podName , podNamespace , storageEndpoint string ) {
163
+ func executeSimpleQuery (podName , podNamespace , storageEndpoint string ) {
162
164
Eventually (func (g Gomega ) string {
163
165
args := []string {
164
166
"-n" ,
@@ -345,7 +347,7 @@ var _ = Describe("Operator smoke test", func() {
345
347
bringYdbCliToPod (podName , testobjects .YdbNamespace )
346
348
347
349
By ("execute simple query inside ydb database pod..." )
348
- executeSimpleQuery (ctx , podName , testobjects .YdbNamespace , storageEndpoint )
350
+ executeSimpleQuery (podName , testobjects .YdbNamespace , storageEndpoint )
349
351
})
350
352
351
353
It ("pause and un-pause Storage, should destroy and bring up Pods" , func () {
@@ -492,7 +494,6 @@ var _ = Describe("Operator smoke test", func() {
492
494
It ("create storage and database with nodeSets" , func () {
493
495
By ("issuing create commands..." )
494
496
storageSample = testobjects .DefaultStorage (filepath .Join ("." , "data" , "storage-block-4-2-config-nodeSets.yaml" ))
495
- databaseSample = testobjects .DefaultDatabase ()
496
497
testNodeSetName := "nodeset"
497
498
for idx := 1 ; idx <= 2 ; idx ++ {
498
499
storageSample .Spec .NodeSets = append (storageSample .Spec .NodeSets , v1alpha1.StorageNodeSetSpecInline {
@@ -572,7 +573,7 @@ var _ = Describe("Operator smoke test", func() {
572
573
bringYdbCliToPod (podName , testobjects .YdbNamespace )
573
574
574
575
By ("execute simple query inside ydb database pod..." )
575
- executeSimpleQuery (ctx , podName , testobjects .YdbNamespace , storageEndpoint )
576
+ executeSimpleQuery (podName , testobjects .YdbNamespace , storageEndpoint )
576
577
})
577
578
578
579
It ("operatorConnection check, create storage with default staticCredentials" , func () {
@@ -652,28 +653,115 @@ var _ = Describe("Operator smoke test", func() {
652
653
LocalObjectReference : corev1.LocalObjectReference {Name : testobjects .CertificateSecretName },
653
654
Key : "ca.crt" ,
654
655
}
655
-
656
656
Expect (k8sClient .Create (ctx , storageSample )).Should (Succeed ())
657
657
defer func () {
658
658
Expect (k8sClient .Delete (ctx , storageSample )).Should (Succeed ())
659
659
}()
660
+
661
+ By ("waiting until Storage is ready..." )
662
+ waitUntilStorageReady (ctx , storageSample .Name , testobjects .YdbNamespace )
663
+
664
+ By ("checking that all the storage pods are running and ready..." )
665
+ checkPodsRunningAndReady (ctx , "ydb-cluster" , "kind-storage" , storageSample .Spec .Nodes )
666
+
660
667
By ("create database..." )
668
+ databaseSample .Spec .Service .GRPC .TLSConfiguration .Enabled = true
669
+ databaseSample .Spec .Service .GRPC .TLSConfiguration .Certificate = corev1.SecretKeySelector {
670
+ LocalObjectReference : corev1.LocalObjectReference {Name : testobjects .CertificateSecretName },
671
+ Key : "tls.crt" ,
672
+ }
673
+ databaseSample .Spec .Service .GRPC .TLSConfiguration .Key = corev1.SecretKeySelector {
674
+ LocalObjectReference : corev1.LocalObjectReference {Name : testobjects .CertificateSecretName },
675
+ Key : "tls.key" ,
676
+ }
677
+ databaseSample .Spec .Service .GRPC .TLSConfiguration .CertificateAuthority = corev1.SecretKeySelector {
678
+ LocalObjectReference : corev1.LocalObjectReference {Name : testobjects .CertificateSecretName },
679
+ Key : "ca.crt" ,
680
+ }
661
681
Expect (k8sClient .Create (ctx , databaseSample )).Should (Succeed ())
662
682
defer func () {
663
683
Expect (k8sClient .Delete (ctx , databaseSample )).Should (Succeed ())
664
684
}()
665
685
686
+ By ("waiting until database is ready..." )
687
+ waitUntilDatabaseReady (ctx , databaseSample .Name , testobjects .YdbNamespace )
688
+
689
+ By ("checking that all the database pods are running and ready..." )
690
+ checkPodsRunningAndReady (ctx , "ydb-cluster" , "kind-database" , databaseSample .Spec .Nodes )
691
+
692
+ storagePods := corev1.PodList {}
693
+ Expect (k8sClient .List (ctx , & storagePods ,
694
+ client .InNamespace (testobjects .YdbNamespace ),
695
+ client.MatchingLabels {
696
+ "ydb-cluster" : "kind-database" ,
697
+ })).Should (Succeed ())
698
+ podName := storagePods .Items [0 ].Name
699
+
700
+ By ("bring YDB CLI inside ydb storage pod..." )
701
+ bringYdbCliToPod (podName , testobjects .YdbNamespace )
702
+
703
+ By ("execute simple query inside ydb storage pod..." )
704
+ storageEndpoint := fmt .Sprintf ("grpcs://%s:%d" , testobjects .StorageGRPCService , testobjects .StorageGRPCPort )
705
+ executeSimpleQuery (podName , testobjects .YdbNamespace , storageEndpoint )
706
+ })
707
+
708
+ It ("Check that Storage deleted after Database..." , func () {
709
+ By ("create storage..." )
710
+ Expect (k8sClient .Create (ctx , storageSample )).Should (Succeed ())
711
+
712
+ By ("create database..." )
713
+ Expect (k8sClient .Create (ctx , databaseSample )).Should (Succeed ())
714
+
666
715
By ("waiting until Storage is ready..." )
667
716
waitUntilStorageReady (ctx , storageSample .Name , testobjects .YdbNamespace )
668
717
669
718
By ("checking that all the storage pods are running and ready..." )
670
719
checkPodsRunningAndReady (ctx , "ydb-cluster" , "kind-storage" , storageSample .Spec .Nodes )
671
720
672
- By ("waiting until database is ready..." )
721
+ By ("waiting until Database is ready..." )
673
722
waitUntilDatabaseReady (ctx , databaseSample .Name , testobjects .YdbNamespace )
674
723
675
724
By ("checking that all the database pods are running and ready..." )
676
725
checkPodsRunningAndReady (ctx , "ydb-cluster" , "kind-database" , databaseSample .Spec .Nodes )
726
+
727
+ By ("delete Storage..." )
728
+ Expect (k8sClient .Delete (ctx , storageSample )).Should (Succeed ())
729
+
730
+ By ("checking that Storage deletionTimestamp is not nil..." )
731
+ Eventually (func () bool {
732
+ foundStorage := v1alpha1.Storage {}
733
+ err := k8sClient .Get (ctx , types.NamespacedName {
734
+ Name : storageSample .Name ,
735
+ Namespace : testobjects .YdbNamespace ,
736
+ }, & foundStorage )
737
+ if err != nil {
738
+ return false
739
+ }
740
+ return ! foundStorage .DeletionTimestamp .IsZero ()
741
+ }, test .Timeout , test .Interval ).Should (BeTrue ())
742
+
743
+ By ("checking that Storage is present in cluster..." )
744
+ Consistently (func () error {
745
+ foundStorage := v1alpha1.Storage {}
746
+ err := k8sClient .Get (ctx , types.NamespacedName {
747
+ Name : storageSample .Name ,
748
+ Namespace : testobjects .YdbNamespace ,
749
+ }, & foundStorage )
750
+ return err
751
+ }, test .Timeout , test .Interval ).ShouldNot (HaveOccurred ())
752
+
753
+ By ("delete Database..." )
754
+ Expect (k8sClient .Delete (ctx , databaseSample )).Should (Succeed ())
755
+
756
+ By ("checking that Storage deleted from cluster..." )
757
+ Eventually (func () bool {
758
+ foundStorage := v1alpha1.Storage {}
759
+ err := k8sClient .Get (ctx , types.NamespacedName {
760
+ Name : storageSample .Name ,
761
+ Namespace : testobjects .YdbNamespace ,
762
+ }, & foundStorage )
763
+ return apierrors .IsNotFound (err )
764
+ }, test .Timeout , test .Interval ).Should (BeTrue ())
677
765
})
678
766
679
767
It ("TLS for status service" , func () {
@@ -740,13 +828,18 @@ var _ = Describe("Operator smoke test", func() {
740
828
Key : "ca.crt" ,
741
829
},
742
830
}
743
-
744
831
Expect (k8sClient .Create (ctx , storageSample )).Should (Succeed ())
832
+ defer func () {
833
+ Expect (k8sClient .Delete (ctx , storageSample )).Should (Succeed ())
834
+ }()
745
835
746
836
By ("create database..." )
747
837
databaseSample .Spec .Nodes = 1
748
838
databaseSample .Spec .Service .Status = * storageSample .Spec .Service .Status .DeepCopy ()
749
839
Expect (k8sClient .Create (ctx , databaseSample )).Should (Succeed ())
840
+ defer func () {
841
+ Expect (k8sClient .Delete (ctx , databaseSample )).Should (Succeed ())
842
+ }()
750
843
751
844
By ("waiting until Storage is ready..." )
752
845
waitUntilStorageReady (ctx , storageSample .Name , testobjects .YdbNamespace )
0 commit comments