Skip to content

Commit

Permalink
[#1018] Fix conversion of ActiveMQArtemisAddress CRs from v1beta1 to …
Browse files Browse the repository at this point in the history
…previous versions
  • Loading branch information
brusdev committed Sep 23, 2024
1 parent 4013e34 commit 1657f19
Show file tree
Hide file tree
Showing 9 changed files with 57 additions and 57 deletions.
6 changes: 3 additions & 3 deletions api/v2alpha1/activemqartemisaddress_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ type ActiveMQArtemisAddressSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

AddressName string `json:"addressName"`
QueueName string `json:"queueName"`
RoutingType string `json:"routingType"`
AddressName string `json:"addressName,omitempty"`
QueueName string `json:"queueName,omitempty"`
RoutingType string `json:"routingType,omitempty"`
}

// ActiveMQArtemisAddressStatus defines the observed state of ActiveMQArtemisAddress
Expand Down
8 changes: 4 additions & 4 deletions api/v2alpha2/activemqartemisaddress_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ type ActiveMQArtemisAddressSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

AddressName string `json:"addressName"`
QueueName string `json:"queueName"`
RoutingType string `json:"routingType"`
RemoveFromBrokerOnDelete bool `json:"removeFromBrokerOnDelete"`
AddressName string `json:"addressName,omitempty"`
QueueName string `json:"queueName,omitempty"`
RoutingType string `json:"routingType,omitempty"`
RemoveFromBrokerOnDelete bool `json:"removeFromBrokerOnDelete,omitempty"`
}

// ActiveMQArtemisAddressStatus defines the observed state of ActiveMQArtemisAddress
Expand Down
4 changes: 2 additions & 2 deletions api/v2alpha3/activemqartemisaddress_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ type QueueConfigurationType struct {
FilterString *string `json:"filterString,omitempty"`
Durable *bool `json:"durable,omitempty"`
User *string `json:"user,omitempty"`
MaxConsumers *int32 `json:"maxConsumers"`
MaxConsumers *int32 `json:"maxConsumers,omitempty"`
Exclusive *bool `json:"exclusive,omitempty"`
GroupRebalance *bool `json:"groupRebalance,omitempty"`
GroupRebalancePauseDispatch *bool `json:"groupRebalancePauseDispatch,omitempty"`
Expand All @@ -53,7 +53,7 @@ type QueueConfigurationType struct {
LastValue *bool `json:"lastValue,omitempty"`
LastValueKey *string `json:"lastValueKey,omitempty"`
NonDestructive *bool `json:"nonDestructive,omitempty"`
PurgeOnNoConsumers *bool `json:"purgeOnNoConsumers"`
PurgeOnNoConsumers *bool `json:"purgeOnNoConsumers,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
ConsumersBeforeDispatch *int32 `json:"consumersBeforeDispatch,omitempty"`
DelayBeforeDispatch *int64 `json:"delayBeforeDispatch,omitempty"`
Expand Down
12 changes: 0 additions & 12 deletions bundle/manifests/broker.amq.io_activemqartemisaddresses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,6 @@ spec:
type: string
routingType:
type: string
required:
- addressName
- queueName
- routingType
type: object
status:
description: ActiveMQArtemisAddressStatus defines the observed state of
Expand Down Expand Up @@ -386,11 +382,6 @@ spec:
type: boolean
routingType:
type: string
required:
- addressName
- queueName
- removeFromBrokerOnDelete
- routingType
type: object
status:
description: ActiveMQArtemisAddressStatus defines the observed state of
Expand Down Expand Up @@ -566,9 +557,6 @@ spec:
type: boolean
user:
type: string
required:
- maxConsumers
- purgeOnNoConsumers
type: object
queueName:
type: string
Expand Down
12 changes: 0 additions & 12 deletions config/crd/bases/broker.amq.io_activemqartemisaddresses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -270,10 +270,6 @@ spec:
type: string
routingType:
type: string
required:
- addressName
- queueName
- routingType
type: object
status:
description: ActiveMQArtemisAddressStatus defines the observed state of
Expand Down Expand Up @@ -387,11 +383,6 @@ spec:
type: boolean
routingType:
type: string
required:
- addressName
- queueName
- removeFromBrokerOnDelete
- routingType
type: object
status:
description: ActiveMQArtemisAddressStatus defines the observed state of
Expand Down Expand Up @@ -567,9 +558,6 @@ spec:
type: boolean
user:
type: string
required:
- maxConsumers
- purgeOnNoConsumers
type: object
queueName:
type: string
Expand Down
44 changes: 44 additions & 0 deletions controllers/activemqartemisaddress_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ import (
"k8s.io/apimachinery/pkg/types"

brokerv1beta1 "github.com/artemiscloud/activemq-artemis-operator/api/v1beta1"
"github.com/artemiscloud/activemq-artemis-operator/api/v2alpha1"
"github.com/artemiscloud/activemq-artemis-operator/api/v2alpha2"
"github.com/artemiscloud/activemq-artemis-operator/api/v2alpha3"
"github.com/artemiscloud/activemq-artemis-operator/pkg/utils/common"
"github.com/artemiscloud/activemq-artemis-operator/pkg/utils/jolokia"
"github.com/artemiscloud/activemq-artemis-operator/pkg/utils/namer"
Expand Down Expand Up @@ -955,6 +958,47 @@ var _ = Describe("Address controller tests", func() {

})
})

Context("Address conversion test", Label("address-conversion-test"), func() {
It("convert empty address CR", func() {
v1beta1AddressCR := brokerv1beta1.ActiveMQArtemisAddress{
TypeMeta: metav1.TypeMeta{
Kind: "ActiveMQArtemisAddress",
APIVersion: brokerv1beta1.GroupVersion.Identifier(),
},
ObjectMeta: metav1.ObjectMeta{
Name: NextSpecResourceName(),
Namespace: defaultNamespace,
},
}
Expect(k8sClient.Create(ctx, &v1beta1AddressCR)).Should(Succeed())

addressCRKey := types.NamespacedName{Name: v1beta1AddressCR.Name, Namespace: v1beta1AddressCR.Namespace}

Eventually(func(g Gomega) {
v1beta1CreatedAddressCR := &brokerv1beta1.ActiveMQArtemisAddress{}
g.Expect(k8sClient.Get(ctx, addressCRKey, v1beta1CreatedAddressCR)).Should(Succeed())
}, timeout, interval).Should(Succeed())

Eventually(func(g Gomega) {
v2alpha3AddressCR := &v2alpha3.ActiveMQArtemisAddress{}
g.Expect(k8sClient.Get(ctx, addressCRKey, v2alpha3AddressCR)).Should(Succeed())
g.Expect(k8sClient.Update(ctx, v2alpha3AddressCR)).Should(Succeed())
}, timeout, interval).Should(Succeed())

Eventually(func(g Gomega) {
v2alpha2AddressCR := &v2alpha2.ActiveMQArtemisAddress{}
g.Expect(k8sClient.Get(ctx, addressCRKey, v2alpha2AddressCR)).Should(Succeed())
g.Expect(k8sClient.Update(ctx, v2alpha2AddressCR)).Should(Succeed())
}, timeout, interval).Should(Succeed())

Eventually(func(g Gomega) {
v2alpha1AddressCR := &v2alpha1.ActiveMQArtemisAddress{}
g.Expect(k8sClient.Get(ctx, addressCRKey, v2alpha1AddressCR)).Should(Succeed())
g.Expect(k8sClient.Update(ctx, v2alpha1AddressCR)).Should(Succeed())
}, timeout, interval).Should(Succeed())
})
})
})

func CheckQueueExistInPod(brokerCrName string, podName string, queueName string, namespace string) {
Expand Down
4 changes: 4 additions & 0 deletions controllers/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import (
brokerv1alpha1 "github.com/artemiscloud/activemq-artemis-operator/api/v1alpha1"
brokerv1beta1 "github.com/artemiscloud/activemq-artemis-operator/api/v1beta1"
brokerv2alpha1 "github.com/artemiscloud/activemq-artemis-operator/api/v2alpha1"
brokerv2alpha2 "github.com/artemiscloud/activemq-artemis-operator/api/v2alpha2"
brokerv2alpha3 "github.com/artemiscloud/activemq-artemis-operator/api/v2alpha3"
brokerv2alpha4 "github.com/artemiscloud/activemq-artemis-operator/api/v2alpha4"
brokerv2alpha5 "github.com/artemiscloud/activemq-artemis-operator/api/v2alpha5"
Expand Down Expand Up @@ -751,6 +752,9 @@ func setUpK8sClient() {
err = brokerv2alpha3.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

err = brokerv2alpha2.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

err = brokerv2alpha1.AddToScheme(scheme.Scheme)
Expect(err).NotTo(HaveOccurred())

Expand Down
12 changes: 0 additions & 12 deletions deploy/activemq-artemis-operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -231,10 +231,6 @@ spec:
type: string
routingType:
type: string
required:
- addressName
- queueName
- routingType
type: object
status:
description: ActiveMQArtemisAddressStatus defines the observed state of ActiveMQArtemisAddress
Expand Down Expand Up @@ -315,11 +311,6 @@ spec:
type: boolean
routingType:
type: string
required:
- addressName
- queueName
- removeFromBrokerOnDelete
- routingType
type: object
status:
description: ActiveMQArtemisAddressStatus defines the observed state of ActiveMQArtemisAddress
Expand Down Expand Up @@ -462,9 +453,6 @@ spec:
type: boolean
user:
type: string
required:
- maxConsumers
- purgeOnNoConsumers
type: object
queueName:
type: string
Expand Down
12 changes: 0 additions & 12 deletions deploy/crds/broker_activemqartemisaddress_crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,6 @@ spec:
type: string
routingType:
type: string
required:
- addressName
- queueName
- routingType
type: object
status:
description: ActiveMQArtemisAddressStatus defines the observed state of ActiveMQArtemisAddress
Expand Down Expand Up @@ -308,11 +304,6 @@ spec:
type: boolean
routingType:
type: string
required:
- addressName
- queueName
- removeFromBrokerOnDelete
- routingType
type: object
status:
description: ActiveMQArtemisAddressStatus defines the observed state of ActiveMQArtemisAddress
Expand Down Expand Up @@ -455,9 +446,6 @@ spec:
type: boolean
user:
type: string
required:
- maxConsumers
- purgeOnNoConsumers
type: object
queueName:
type: string
Expand Down

0 comments on commit 1657f19

Please sign in to comment.