@@ -61,12 +61,13 @@ import (
61
61
// every time the API is changed. The listing of all versions is here:
62
62
// https://docs.openstack.org/ironic/latest/contributor/webapi-version-history.html
63
63
const (
64
- // NOTE(dtantsur): latest is now at least 1.95 , so we can rely on this
65
- // value to check that specifying Version: 27 .0 actually installs 27 .0
64
+ // NOTE(dtantsur): latest is now at least 1.96 , so we can rely on this
65
+ // value to check that specifying Version: 29 .0 actually installs 29 .0
66
66
apiVersionIn270 = "1.94"
67
67
apiVersionIn280 = "1.95"
68
+ apiVersionIn290 = "1.96"
68
69
// Update this periodically to make sure we're installing the latest version by default
69
- knownAPIMinorVersion = 95
70
+ knownAPIMinorVersion = 96
70
71
71
72
numberOfNodes = 100
72
73
)
@@ -609,6 +610,109 @@ func saveEvents(namespace string) {
609
610
}
610
611
}
611
612
613
+ func testUpgrade (ironicVersionOld string , ironicVersionNew string , apiVersionOld string , apiVersionNew string , namespace string ) {
614
+ if customImage != "" || customImageVersion != "" {
615
+ Skip ("skipping because a custom image is provided" )
616
+ }
617
+
618
+ name := types.NamespacedName {
619
+ Name : "test-ironic" ,
620
+ Namespace : namespace ,
621
+ }
622
+
623
+ ironic := buildIronic (name , metal3api.IronicSpec {
624
+ Version : ironicVersionOld ,
625
+ })
626
+ err := k8sClient .Create (ctx , ironic )
627
+ Expect (err ).NotTo (HaveOccurred ())
628
+ DeferCleanup (func () {
629
+ CollectLogs (namespace )
630
+ DeleteAndWait (ironic )
631
+ })
632
+
633
+ ironic = WaitForIronic (name )
634
+ VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionOld })
635
+
636
+ By (fmt .Sprintf ("upgrading to Ironic %s" , ironicVersionNew ))
637
+
638
+ patch := client .MergeFrom (ironic .DeepCopy ())
639
+ ironic .Spec .Version = ironicVersionNew
640
+ err = k8sClient .Patch (ctx , ironic , patch )
641
+ Expect (err ).NotTo (HaveOccurred ())
642
+
643
+ ironic = WaitForUpgrade (name , ironicVersionOld , ironicVersionNew )
644
+ VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionNew })
645
+
646
+ By (fmt .Sprintf ("downgrading to Ironic %s (without a database)" , ironicVersionOld ))
647
+
648
+ patch = client .MergeFrom (ironic .DeepCopy ())
649
+ ironic .Spec .Version = ironicVersionOld
650
+ err = k8sClient .Patch (ctx , ironic , patch )
651
+ Expect (err ).NotTo (HaveOccurred ())
652
+
653
+ ironic = WaitForUpgrade (name , ironicVersionNew , ironicVersionOld )
654
+ VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionOld })
655
+ }
656
+
657
+ func testUpgradeHA (ironicVersionOld string , ironicVersionNew string , apiVersionOld string , apiVersionNew string , namespace string ) {
658
+ if customImage != "" || customImageVersion != "" {
659
+ Skip ("skipping because a custom image is provided" )
660
+ }
661
+
662
+ name := types.NamespacedName {
663
+ Name : "test-ironic" ,
664
+ Namespace : namespace ,
665
+ }
666
+
667
+ secret := & corev1.Secret {
668
+ ObjectMeta : metav1.ObjectMeta {
669
+ Name : fmt .Sprintf ("%s-api" , name .Name ),
670
+ Namespace : namespace ,
671
+ },
672
+ Data : map [string ][]byte {
673
+ corev1 .BasicAuthUsernameKey : []byte ("admin" ),
674
+ corev1 .BasicAuthPasswordKey : []byte ("test-password" ),
675
+ },
676
+ Type : corev1 .SecretTypeBasicAuth ,
677
+ }
678
+ err := k8sClient .Create (ctx , secret )
679
+ Expect (err ).NotTo (HaveOccurred ())
680
+
681
+ // FIXME(dtantsur): use a real database in this test, e.g. one deployed by mariadb-operator.
682
+ ironicDB := buildDatabase (name , secret .Name )
683
+ err = k8sClient .Create (ctx , ironicDB )
684
+ Expect (err ).NotTo (HaveOccurred ())
685
+
686
+ ironic := buildIronic (name , metal3api.IronicSpec {
687
+ Database : & metal3api.Database {
688
+ CredentialsName : secret .Name ,
689
+ Host : fmt .Sprintf ("%s-database.%s.svc" , ironicDB .Name , namespace ),
690
+ Name : "ironic" ,
691
+ },
692
+ HighAvailability : true ,
693
+ Version : ironicVersionOld ,
694
+ })
695
+ err = k8sClient .Create (ctx , ironic )
696
+ Expect (err ).NotTo (HaveOccurred ())
697
+ DeferCleanup (func () {
698
+ CollectLogs (namespace )
699
+ DeleteAndWait (ironic )
700
+ })
701
+
702
+ ironic = WaitForIronic (name )
703
+ VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionOld })
704
+
705
+ By (fmt .Sprintf ("upgrading to Ironic %s" , ironicVersionNew ))
706
+
707
+ patch := client .MergeFrom (ironic .DeepCopy ())
708
+ ironic .Spec .Version = ironicVersionNew
709
+ err = k8sClient .Patch (ctx , ironic , patch )
710
+ Expect (err ).NotTo (HaveOccurred ())
711
+
712
+ ironic = WaitForUpgrade (name , ironicVersionOld , ironicVersionNew )
713
+ VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionNew })
714
+ }
715
+
612
716
var _ = Describe ("Ironic object tests" , func () {
613
717
var namespace string
614
718
@@ -733,91 +837,15 @@ var _ = Describe("Ironic object tests", func() {
733
837
})
734
838
735
839
It ("creates Ironic 27.0 and upgrades to 28.0" , Label ("v270-to-280" ), func () {
736
- if customImage != "" || customImageVersion != "" {
737
- Skip ("skipping because a custom image is provided" )
738
- }
739
-
740
- name := types.NamespacedName {
741
- Name : "test-ironic" ,
742
- Namespace : namespace ,
743
- }
744
-
745
- ironic := buildIronic (name , metal3api.IronicSpec {
746
- Version : "27.0" ,
747
- })
748
- err := k8sClient .Create (ctx , ironic )
749
- Expect (err ).NotTo (HaveOccurred ())
750
- DeferCleanup (func () {
751
- CollectLogs (namespace )
752
- DeleteAndWait (ironic )
753
- })
754
-
755
- ironic = WaitForIronic (name )
756
- VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionIn270 })
757
-
758
- By ("upgrading to Ironic 28.0" )
759
-
760
- patch := client .MergeFrom (ironic .DeepCopy ())
761
- ironic .Spec .Version = "28.0"
762
- err = k8sClient .Patch (ctx , ironic , patch )
763
- Expect (err ).NotTo (HaveOccurred ())
764
-
765
- ironic = WaitForUpgrade (name , "27.0" , "28.0" )
766
- VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionIn280 })
767
-
768
- By ("downgrading to Ironic 27.0 (without a database)" )
769
-
770
- patch = client .MergeFrom (ironic .DeepCopy ())
771
- ironic .Spec .Version = "27.0"
772
- err = k8sClient .Patch (ctx , ironic , patch )
773
- Expect (err ).NotTo (HaveOccurred ())
774
-
775
- ironic = WaitForUpgrade (name , "28.0" , "27.0" )
776
- VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionIn270 })
840
+ testUpgrade ("27.0" , "28.0" , apiVersionIn270 , apiVersionIn280 , namespace )
777
841
})
778
842
779
- It ("creates Ironic 28.0 and upgrades to latest" , Label ("v280-to-latest" ), func () {
780
- if customImage != "" || customImageVersion != "" {
781
- Skip ("skipping because a custom image is provided" )
782
- }
783
-
784
- name := types.NamespacedName {
785
- Name : "test-ironic" ,
786
- Namespace : namespace ,
787
- }
788
-
789
- ironic := buildIronic (name , metal3api.IronicSpec {
790
- Version : "28.0" ,
791
- })
792
- err := k8sClient .Create (ctx , ironic )
793
- Expect (err ).NotTo (HaveOccurred ())
794
- DeferCleanup (func () {
795
- CollectLogs (namespace )
796
- DeleteAndWait (ironic )
797
- })
798
-
799
- ironic = WaitForIronic (name )
800
- VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionIn280 })
801
-
802
- By ("upgrading to Ironic latest" )
803
-
804
- patch := client .MergeFrom (ironic .DeepCopy ())
805
- ironic .Spec .Version = "latest"
806
- err = k8sClient .Patch (ctx , ironic , patch )
807
- Expect (err ).NotTo (HaveOccurred ())
808
-
809
- ironic = WaitForUpgrade (name , "28.0" , "latest" )
810
- VerifyIronic (ironic , TestAssumptions {})
811
-
812
- By ("downgrading to Ironic 28.0 (without a database)" )
813
-
814
- patch = client .MergeFrom (ironic .DeepCopy ())
815
- ironic .Spec .Version = "28.0"
816
- err = k8sClient .Patch (ctx , ironic , patch )
817
- Expect (err ).NotTo (HaveOccurred ())
843
+ It ("creates Ironic 28.0 and upgrades to 29.0" , Label ("v280-to-290" ), func () {
844
+ testUpgrade ("28.0" , "29.0" , apiVersionIn280 , apiVersionIn290 , namespace )
845
+ })
818
846
819
- ironic = WaitForUpgrade ( name , " latest" , "28.0" )
820
- VerifyIronic ( ironic , TestAssumptions { maxAPIVersion : apiVersionIn280 } )
847
+ It ( "creates Ironic 29.0 and upgrades to latest" , Label ( "v290-to-latest" ), func () {
848
+ testUpgrade ( "29.0" , "latest" , apiVersionIn290 , "" , namespace )
821
849
})
822
850
823
851
It ("refuses to downgrade Ironic with a database" , Label ("no-db-downgrade" ), func () {
@@ -854,63 +882,12 @@ var _ = Describe("Ironic object tests", func() {
854
882
_ = WaitForIronicFailure (name , "Ironic does not support downgrades" , true )
855
883
})
856
884
857
- It ("creates Ironic 28.0 with HA and upgrades to latest" , Label ("ha-v280-to-latest" ), func () {
858
- if customImage != "" || customImageVersion != "" {
859
- Skip ("skipping because a custom image is provided" )
860
- }
861
-
862
- name := types.NamespacedName {
863
- Name : "test-ironic" ,
864
- Namespace : namespace ,
865
- }
866
-
867
- secret := & corev1.Secret {
868
- ObjectMeta : metav1.ObjectMeta {
869
- Name : fmt .Sprintf ("%s-api" , name .Name ),
870
- Namespace : namespace ,
871
- },
872
- Data : map [string ][]byte {
873
- corev1 .BasicAuthUsernameKey : []byte ("admin" ),
874
- corev1 .BasicAuthPasswordKey : []byte ("test-password" ),
875
- },
876
- Type : corev1 .SecretTypeBasicAuth ,
877
- }
878
- err := k8sClient .Create (ctx , secret )
879
- Expect (err ).NotTo (HaveOccurred ())
880
-
881
- // FIXME(dtantsur): use a real database in this test, e.g. one deployed by mariadb-operator.
882
- ironicDB := buildDatabase (name , secret .Name )
883
- err = k8sClient .Create (ctx , ironicDB )
884
- Expect (err ).NotTo (HaveOccurred ())
885
-
886
- ironic := buildIronic (name , metal3api.IronicSpec {
887
- Database : & metal3api.Database {
888
- CredentialsName : secret .Name ,
889
- Host : fmt .Sprintf ("%s-database.%s.svc" , ironicDB .Name , namespace ),
890
- Name : "ironic" ,
891
- },
892
- HighAvailability : true ,
893
- Version : "28.0" ,
894
- })
895
- err = k8sClient .Create (ctx , ironic )
896
- Expect (err ).NotTo (HaveOccurred ())
897
- DeferCleanup (func () {
898
- CollectLogs (namespace )
899
- DeleteAndWait (ironic )
900
- })
901
-
902
- ironic = WaitForIronic (name )
903
- VerifyIronic (ironic , TestAssumptions {maxAPIVersion : apiVersionIn280 })
904
-
905
- By ("upgrading to Ironic latest" )
906
-
907
- patch := client .MergeFrom (ironic .DeepCopy ())
908
- ironic .Spec .Version = "latest"
909
- err = k8sClient .Patch (ctx , ironic , patch )
910
- Expect (err ).NotTo (HaveOccurred ())
885
+ It ("creates Ironic 28.0 with HA and upgrades to 29.0" , Label ("ha-v280-to-v290" ), func () {
886
+ testUpgradeHA ("28.0" , "29.0" , apiVersionIn280 , apiVersionIn290 , namespace )
887
+ })
911
888
912
- ironic = WaitForUpgrade ( name , "28.0 " , " latest" )
913
- VerifyIronic ( ironic , TestAssumptions {} )
889
+ It ( "creates Ironic 29.0 with HA and upgrades to latest " , Label ( "ha-v290-to- latest" ), func () {
890
+ testUpgradeHA ( "29.0" , "latest" , apiVersionIn290 , "" , namespace )
914
891
})
915
892
916
893
It ("creates Ironic with keepalived and DHCP" , Label ("keepalived-dnsmasq" ), func () {
0 commit comments