diff options
author | 2022-07-28 09:52:22 +0000 | |
---|---|---|
committer | 2022-08-05 06:53:10 +0000 | |
commit | c56c4a5e36d97cb22c97d9acc29d057760b0ec0f (patch) | |
tree | eb9bd65d207ccf7763c06f9c26d14ee816f79f69 | |
parent | ebaab76841e7c7cfee0143e6c40c6e1ae3204309 (diff) |
Support 7.2.1 VES in TCAGEN2
- Includes modifications for processing Tca Policy as a List
to support both v5 and v7 policies
Issue-ID: DCAEGEN2-2976
Signed-off-by: Malarvizhi Paramasivam <malarvizhi.44@wipro.com>
Change-Id: I29f56048d825710d268e4588f4b5779d5fdb6020
46 files changed, 1257 insertions, 179 deletions
diff --git a/ChangeLog.md b/ChangeLog.md index 22e1077..990c0d9 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -4,6 +4,9 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/) and this project adheres to [Semantic Versioning](http://semver.org/). +## [1.3.4] - 2022/07/28 + - [DCAEGEN2-2976](https://jira.onap.org/browse/DCAEGEN2-2976) - Support 7.2.1 VES in TCAGEN2 + ## [1.3.3] - 2022/05/24 - [DCAEGEN2-3159](https://jira.onap.org/browse/DCAEGEN2-3159) - CodeCoverage improvement for dcaegen2-analytics-tca-gen2 diff --git a/dcae-analytics/dcae-analytics-model/pom.xml b/dcae-analytics/dcae-analytics-model/pom.xml index 4a0b64a..00613b5 100644 --- a/dcae-analytics/dcae-analytics-model/pom.xml +++ b/dcae-analytics/dcae-analytics-model/pom.xml @@ -47,6 +47,7 @@ <main.basedir>${project.parent.basedir}</main.basedir> <sdk.version>1.8.6</sdk.version> <immutable.version>2.7.1</immutable.version> + <onap-gerrit-review>-changelog-missing</onap-gerrit-review> </properties> <dependencies> diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/CommonEventHeaderV7.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/CommonEventHeaderV7.java new file mode 100644 index 0000000..7c69fc4 --- /dev/null +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/CommonEventHeaderV7.java @@ -0,0 +1,139 @@ +/* + ** ============LICENSE_START======================================================= + ** Copyright (c) 2022 Wipro Limited. All rights reserved. + ** ================================================================================ + ** Licensed under the Apache License, Version 2.0 (the "License"); + ** you may not use this file except in compliance with the License. + ** You may obtain a copy of the License at + ** + ** http://www.apache.org/licenses/LICENSE-2.0 + ** + ** Unless required by applicable law or agreed to in writing, software + ** distributed under the License is distributed on an "AS IS" BASIS, + ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ** See the License for the specific language governing permissions and + ** limitations under the License. + ** ============LICENSE_END========================================================= + ** + **/ + +package org.onap.dcae.analytics.model.cef; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * Fields common to all Events + * + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class CommonEventHeaderV7 extends BaseCEFModel { + + private static final long serialVersionUID = 1L; + + /** + * The eventing domain associated with this event + */ + + private Domain domain; + + /** + * Event key that is unique to the event source + */ + + private String eventId; + + /** + * Unique event name + */ + + private String eventName; + + /** + * Event type e.g. applicationVnf, guestOS, hostOS, platform + */ + + private String eventType; + + /** + * Enrichment fields for internal VES Event Listener service use only, not supplied by event sources + */ + + private InternalHeaderFields internalHeaderFields; + + /** + * The latest unix time aka epoch time associated with the event from any component--as microseconds elapsed since + * 1 Jan 1970 not including leap seconds + */ + + private Long lastEpochMicrosec; + + /** + * Three character network function component type as aligned with vfc naming standards + */ + + private String nfcNamingCode; + + /** + * Four character network function type as aligned with vnf naming standards + */ + + private String nfNamingCode; + + /** + * Processing Priority + */ + + private Priority priority; + + /** + * UUID identifying the entity reporting the event, for example an OAM VM; must be populated by the + * enrichment process + */ + + private String reportingEntityId; + + /** + * Name of the entity reporting the event, for example, an EMS name; may be the same as sourceName + */ + + private String reportingEntityName; + + /** + * Ordering of events communicated by an event source instance or 0 if not needed + */ + + private Integer sequence; + + /** + * UUID identifying the entity experiencing the event issue; must be populated by the enrichment process + */ + + private String sourceId; + + /** + * Name of the entity experiencing the event issue + */ + + private String sourceName; + + /** + * The earliest unix time aka epoch time associated with the event from any component--as microseconds elapsed + * since 1 Jan 1970 not including leap seconds + */ + + private Long startEpochMicrosec; + + /** + * Version of the event header + */ + + private String version; + + /** + * Version of the VES event listener version + */ + + private String vesEventListenerVersion; +} diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Domain.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Domain.java index 2be00dc..bcb9c64 100644 --- a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Domain.java +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/Domain.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ============LICENSE_START======================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -31,6 +32,7 @@ public enum Domain implements CEFModel { measurementsForVfScaling, mobileFlow, other, + measurement, sipSignaling, stateChange, syslog, diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventListener.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventListener.java index 50bf3d1..3f32b7b 100644 --- a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventListener.java +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventListener.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ============LICENSE_START======================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -38,4 +39,5 @@ public class EventListener extends BaseCEFModel { * Common Event Format - Event */ private Event event; + private EventV7 eventV7; } diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventV7.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventV7.java new file mode 100644 index 0000000..a4324a0 --- /dev/null +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/EventV7.java @@ -0,0 +1,50 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.model.cef; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * Generic Event Format + * + */ +@Data +@EqualsAndHashCode(callSuper = true) +public class EventV7 extends BaseCEFModel { + + + private static final long serialVersionUID = 1L; + + /** + * Fields common to all Events + */ + private CommonEventHeaderV7 commonEventHeader; + + /** + * Measurements for Vf scaling fields + */ + private MeasurementFields measurementFields; + + /** + * Threshold crossing alert Fields. + */ + private ThresholdCrossingAlertFields thresholdCrossingAlertFields; +} diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/MeasurementFields.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/MeasurementFields.java new file mode 100644 index 0000000..37f98e0 --- /dev/null +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/MeasurementFields.java @@ -0,0 +1,69 @@ +/* + ** ============LICENSE_START======================================================= + ** Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. + ** ================================================================================ + ** Licensed under the Apache License, Version 2.0 (the "License"); + ** you may not use this file except in compliance with the License. + ** You may obtain a copy of the License at + ** + ** http://www.apache.org/licenses/LICENSE-2.0 + ** + ** Unless required by applicable law or agreed to in writing, software + ** distributed under the License is distributed on an "AS IS" BASIS, + ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + ** See the License for the specific language governing permissions and + ** limitations under the License. + ** ============LICENSE_END========================================================= + ** + **/ + +package org.onap.dcae.analytics.model.cef; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.util.List; + +/** + * Common Event Format - Measurement fields + * + */ + +@Data +@EqualsAndHashCode(callSuper = true) +public class MeasurementFields extends BaseCEFModel { + + private static final long serialVersionUID = 1L; + + /** + * Additional name-value-pair fields + */ + + private List<Field> additionalFields; + + /** + * Array of named name-value-pair arrays for additional Measurements + */ + + private List<NamedArrayOfFields> additionalMeasurements; + + /** + * Interval over which measurements are being reported in seconds + */ + + private Long measurementInterval; + + /** + * Version of the measurementsForVfScaling block + */ + + private String measurementFieldsVersion; + + /** + * Usage of an array of virtual network interface cards + */ + + private List<NicPerformance> nicPerformanceArray; + +} + diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/NicPerformance.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/NicPerformance.java new file mode 100644 index 0000000..7472e65 --- /dev/null +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/cef/NicPerformance.java @@ -0,0 +1,216 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.model.cef; + +import lombok.Data; +import lombok.EqualsAndHashCode; + +/** + * Describes the performance and errors of an identified virtual network interface card + * + * */ +@Data +@EqualsAndHashCode(callSuper = true) +public class NicPerformance extends BaseCEFModel { + + private static final long serialVersionUID = 1L; + + /** + * Cumulative count of broadcast packets received as read at the end of the measurement interval + */ + + private Long receivedBroadcastPacketsAccumulated; + + /** + * Count of broadcast packets received within the measurement interval + */ + + private Long receivedBroadcastPacketsDelta; + + /** + * Cumulative count of discarded packets received as read at the end of the measurement interval + */ + + private Long receivedDiscardedPacketsAccumulated; + + /** + * Count of discarded packets received within the measurement interval + */ + + private Long receivedDiscardedPacketsDelta; + + /** + * Cumulative count of error packets received as read at the end of the measurement interval + */ + + private Long receivedErrorPacketsAccumulated; + + /** + * Count of error packets received within the measurement interval + */ + + private Long receivedErrorPacketsDelta; + + /** + * Cumulative count of multicast packets received as read at the end of the measurement interval + */ + + private Long receivedMulticastPacketsAccumulated; + + /** + * Count of multicast packets received within the measurement interval + */ + + private Long receivedMulticastPacketsDelta; + + /** + * Cumulative count of octets received as read at the end of the measurement interval + */ + + private Long receivedOctetsAccumulated; + + /** + * Count of octets received within the measurement interval + */ + + private Long receivedOctetsDelta; + + /** + * Cumulative count of all packets received as read at the end of the measurement interval + */ + + private Long receivedTotalPacketsAccumulated; + + /** + * Count of all packets received within the measurement interval + */ + + private Long receivedTotalPacketsDelta; + + /** + * Cumulative count of unicast packets received as read at the end of the measurement interval + */ + + private Long receivedUnicastPacketsAccumulated; + + /** + * Count of unicast packets received within the measurement interval + */ + + private Long receivedUnicastPacketsDelta; + + /** + * Cumulative count of broadcast packets transmitted as read at the end of the measurement interval + */ + + private Long transmittedBroadcastPacketsAccumulated; + + /** + * Count of broadcast packets transmitted within the measurement interval + */ + + private Long transmittedBroadcastPacketsDelta; + + /** + * Cumulative count of discarded packets transmitted as read at the end of the measurement interval + */ + + private Long transmittedDiscardedPacketsAccumulated; + + /** + * Count of discarded packets transmitted within the measurement interval + */ + + private Long transmittedDiscardedPacketsDelta; + + /** + * Cumulative count of error packets transmitted as read at the end of the measurement interval + */ + + private Long transmittedErrorPacketsAccumulated; + + /** + * Count of error packets transmitted within the measurement interval + */ + + private Long transmittedErrorPacketsDelta; + + /** + * Cumulative count of multicast packets transmitted as read at the end of the measurement interval + */ + + private Long transmittedMulticastPacketsAccumulated; + + /** + * Count of multicast packets transmitted within the measurement interval + */ + + private Long transmittedMulticastPacketsDelta; + + /** + * Cumulative count of octets transmitted as read at the end of the measurement interval + */ + + private Long transmittedOctetsAccumulated; + + /** + * Count of octets transmitted within the measurement interval + */ + + private Long transmittedOctetsDelta; + + /** + * Cumulative count of all packets transmitted as read at the end of the measurement interval + */ + + private Long transmittedTotalPacketsAccumulated; + + /** + * Count of all packets transmitted within the measurement interval + */ + + private Long transmittedTotalPacketsDelta; + + /** + * Cumulative count of unicast packets transmitted as read at the end of the measurement interval + */ + + private Long transmittedUnicastPacketsAccumulated; + + /** + * Count of unicast packets transmitted within the measurement interval + */ + + private Long transmittedUnicastPacketsDelta; + + /** + * Indicates whether vNicPerformance values are likely inaccurate due to counter overflow or other conditions + */ + + private Boolean valuesAreSuspect; + + /** + * Virtual Network Card Identifier + */ + + private String nicIdentifier; + +} + diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/BaseObjectMapperSupplier.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/BaseObjectMapperSupplier.java index 18e8262..0e705a9 100644 --- a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/BaseObjectMapperSupplier.java +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/BaseObjectMapperSupplier.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * =============LICENSE_START=================================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -34,6 +35,7 @@ import java.util.Set; import java.util.function.Supplier; import org.onap.dcae.analytics.model.util.json.module.CommonEventFormatModule; +import org.onap.dcae.analytics.model.util.json.module.CommonEventFormatModuleV7; import org.onap.dcae.analytics.model.util.json.module.ConfigBindingServiceModule; import org.onap.dcae.analytics.model.util.json.module.DynamicPropertiesModule; @@ -96,6 +98,8 @@ public abstract class BaseObjectMapperSupplier implements Supplier<ObjectMapper> objectMapper.registerModule(new ConfigBindingServiceModule()); // register common event format module objectMapper.registerModule(new CommonEventFormatModule()); + // register common event format module for v7 + objectMapper.registerModule(new CommonEventFormatModuleV7()); // register custom modules registerCustomModules(objectMapper); diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/CommonEventHeaderV7Mixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/CommonEventHeaderV7Mixin.java new file mode 100644 index 0000000..da50caa --- /dev/null +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/CommonEventHeaderV7Mixin.java @@ -0,0 +1,24 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.model.util.json.mixin.cef; + + +public abstract class CommonEventHeaderV7Mixin extends BaseCEFModelMixin { +} diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventV7Mixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventV7Mixin.java new file mode 100644 index 0000000..16e4ad5 --- /dev/null +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/EventV7Mixin.java @@ -0,0 +1,27 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.model.util.json.mixin.cef; + +/** + * Event v7 Json Mixin class + * + */ +public abstract class EventV7Mixin extends BaseCEFModelMixin { +} diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/MeasurementFieldsMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/MeasurementFieldsMixin.java new file mode 100644 index 0000000..c1e3a25 --- /dev/null +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/MeasurementFieldsMixin.java @@ -0,0 +1,39 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.model.util.json.mixin.cef; + +import com.fasterxml.jackson.annotation.JsonGetter; +import com.fasterxml.jackson.annotation.JsonSetter; + +import java.util.List; + +import org.onap.dcae.analytics.model.cef.NicPerformance; + +/** + * Measurement Fields Mixin class + */ +public abstract class MeasurementFieldsMixin extends BaseCEFModelMixin { + + @JsonGetter("nicPerformanceArray") + public abstract List<NicPerformance> getVNicPerformanceArray(); + + @JsonSetter("nicPerformanceArray") + public abstract void setVNicPerformanceArray(List<NicPerformance> vNicPerformances); +} diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/nicUsageArrayMixin.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/nicUsageArrayMixin.java new file mode 100644 index 0000000..b78ccf2 --- /dev/null +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/mixin/cef/nicUsageArrayMixin.java @@ -0,0 +1,35 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.model.util.json.mixin.cef; + +import com.fasterxml.jackson.annotation.JsonSetter; + +/** + * nicUsageArray mixin class + */ +public abstract class nicUsageArrayMixin extends BaseCEFModelMixin { + + @JsonSetter("nicIdentifier") + public abstract void setVNicIdentifier(String name); + + @JsonSetter("nicIdentifier") + public abstract String setVNicIdentifier(); + +} diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModule.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModule.java index 1daf2ef..8df9b06 100644 --- a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModule.java +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModule.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ============LICENSE_START======================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModuleV7.java b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModuleV7.java new file mode 100644 index 0000000..7c09a30 --- /dev/null +++ b/dcae-analytics/dcae-analytics-model/src/main/java/org/onap/dcae/analytics/model/util/json/module/CommonEventFormatModuleV7.java @@ -0,0 +1,102 @@ +/* + * ============LICENSE_START======================================================= + * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + * + */ + +package org.onap.dcae.analytics.model.util.json.module; + +import static org.onap.dcae.analytics.model.AnalyticsModelConstants.JSON_MODULE_ARTIFACT_ID; +import static org.onap.dcae.analytics.model.AnalyticsModelConstants.JSON_MODULE_GROUP_ID; + +import com.fasterxml.jackson.core.Version; +import com.fasterxml.jackson.databind.module.SimpleModule; + +import org.onap.dcae.analytics.model.cef.AlertAction; +import org.onap.dcae.analytics.model.cef.AlertType; +import org.onap.dcae.analytics.model.cef.BaseCEFModel; +import org.onap.dcae.analytics.model.cef.CommonEventHeaderV7; +import org.onap.dcae.analytics.model.cef.Criticality; +import org.onap.dcae.analytics.model.cef.Domain; +import org.onap.dcae.analytics.model.cef.EventV7; +import org.onap.dcae.analytics.model.cef.EventListener; +import org.onap.dcae.analytics.model.cef.EventSeverity; +import org.onap.dcae.analytics.model.cef.Field; +import org.onap.dcae.analytics.model.cef.InternalHeaderFields; +import org.onap.dcae.analytics.model.cef.MeasurementFields; +import org.onap.dcae.analytics.model.cef.NamedArrayOfFields; +import org.onap.dcae.analytics.model.cef.NicPerformance; +import org.onap.dcae.analytics.model.cef.PerformanceCounter; +import org.onap.dcae.analytics.model.cef.Priority; +import org.onap.dcae.analytics.model.cef.ThresholdCrossingAlertFields; +import org.onap.dcae.analytics.model.util.json.mixin.cef.AlertActionMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.AlertTypeMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.BaseCEFModelMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.CommonEventHeaderV7Mixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.CriticalityMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.DomainMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.EventListenerMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.EventV7Mixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.EventSeverityMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.FieldMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.InternalHeaderFieldsMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.MeasurementFieldsMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.NamedArrayOfFieldsMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.nicUsageArrayMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.PerformanceCounterMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.PriorityMixin; +import org.onap.dcae.analytics.model.util.json.mixin.cef.ThresholdCrossingAlertFieldsMixin; + + + +/** + * @author Rajiv Singla + */ +public class CommonEventFormatModuleV7 extends SimpleModule { + + private static final long serialVersionUID = 1L; + + public CommonEventFormatModuleV7() { + super("Common Event Format", + new Version(30, 2, 1, null, JSON_MODULE_GROUP_ID, JSON_MODULE_ARTIFACT_ID)); + } + + @Override + public void setupModule(final SetupContext setupContext) { + + setupContext.setMixInAnnotations(AlertAction.class, AlertActionMixin.class); + setupContext.setMixInAnnotations(AlertType.class, AlertTypeMixin.class); + setupContext.setMixInAnnotations(BaseCEFModel.class, BaseCEFModelMixin.class); + setupContext.setMixInAnnotations(CommonEventHeaderV7.class, CommonEventHeaderV7Mixin.class); + setupContext.setMixInAnnotations(Domain.class, DomainMixin.class); + setupContext.setMixInAnnotations(InternalHeaderFields.class, InternalHeaderFieldsMixin.class); + setupContext.setMixInAnnotations(Field.class, FieldMixin.class); + setupContext.setMixInAnnotations(NamedArrayOfFields.class, NamedArrayOfFieldsMixin.class); + setupContext.setMixInAnnotations(Criticality.class, CriticalityMixin.class); + setupContext.setMixInAnnotations(EventListener.class, EventListenerMixin.class); + setupContext.setMixInAnnotations(EventV7.class, EventV7Mixin.class); + setupContext.setMixInAnnotations(EventSeverity.class, EventSeverityMixin.class); + setupContext.setMixInAnnotations(MeasurementFields.class, + MeasurementFieldsMixin.class); + setupContext.setMixInAnnotations(PerformanceCounter.class, PerformanceCounterMixin.class); + setupContext.setMixInAnnotations(Priority.class, PriorityMixin.class); + setupContext.setMixInAnnotations(ThresholdCrossingAlertFields.class, ThresholdCrossingAlertFieldsMixin.class); + setupContext.setMixInAnnotations(NicPerformance.class, nicUsageArrayMixin.class); + + } + +} diff --git a/dcae-analytics/dcae-analytics-tca-core/pom.xml b/dcae-analytics/dcae-analytics-tca-core/pom.xml index d21a86c..4921f84 100644 --- a/dcae-analytics/dcae-analytics-tca-core/pom.xml +++ b/dcae-analytics/dcae-analytics-tca-core/pom.xml @@ -42,7 +42,8 @@ <description>Contins Core functionality for TCA</description> <properties> - <main.basedir>${project.parent.basedir}</main.basedir> + <main.basedir>${project.parent.basedir}</main.basedir> + <onap-gerrit-review>-changelog-missing</onap-gerrit-review> </properties> <dependencies> diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java index 6a208d2..715ed53 100644 --- a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/GenericTcaExecutionContext.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ============LICENSE_START======================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +24,7 @@ import lombok.Builder; import lombok.EqualsAndHashCode; import lombok.Getter; import lombok.ToString; +import java.util.List; import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; @@ -39,7 +41,7 @@ public class GenericTcaExecutionContext implements TcaExecutionContext { private final String transactionId; private final int messageIndex; private final String cefMessage; - private final TcaPolicy tcaPolicy; + private final List<TcaPolicy> tcaPolicy; private final TcaProcessingContext tcaProcessingContext; private final TcaResultContext tcaResultContext; private final TcaAbatementContext tcaAbatementContext; diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java index 9a55151..7a0ac51 100644 --- a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/service/TcaExecutionContext.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ============LICENSE_START======================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +20,7 @@ package org.onap.dcae.analytics.tca.core.service; +import java.util.List; import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; /** @@ -65,7 +67,7 @@ public interface TcaExecutionContext { * * @return TCA Policy associated with processing context */ - TcaPolicy getTcaPolicy(); + List<TcaPolicy> getTcaPolicy(); /** diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/TcaUtils.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/TcaUtils.java index bbadcac..5f581f6 100644 --- a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/TcaUtils.java +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/TcaUtils.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ==========LICENSE_START========================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +24,7 @@ import static org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion import com.fasterxml.jackson.core.JsonProcessingException; +import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Optional; @@ -52,14 +54,19 @@ public abstract class TcaUtils { * * @return deep copy of provided tca policy */ - public static TcaPolicy getTcaPolicyDeepCopy(final TcaPolicy tcaPolicy) { + public static List<TcaPolicy> getTcaPolicyDeepCopy(final List<TcaPolicy> tcaPolicy) { if (tcaPolicy != null) { - try { - return TCA_OBJECT_MAPPER.treeToValue(TCA_OBJECT_MAPPER.valueToTree(tcaPolicy), TcaPolicy.class); + List<TcaPolicy> tcaList = new ArrayList<TcaPolicy>(); + for( TcaPolicy tcaPol : tcaPolicy) { + try { + tcaList.add(TCA_OBJECT_MAPPER.treeToValue(TCA_OBJECT_MAPPER.valueToTree(tcaPol), TcaPolicy.class)); } catch (JsonProcessingException e) { - throw new AnalyticsParsingException("Unable to create deep copy of TCA Policy: " + tcaPolicy, e); + throw new AnalyticsParsingException("Unable to create deep copy of TCA Policy: " + tcaPol, e); } - } else { + } + return tcaList; + } + else { final String errorMessage = "Invalid application state. TCA Policy must not be null"; throw new AnalyticsParsingException(errorMessage, new IllegalStateException(errorMessage)); } diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaDomainFilter.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaDomainFilter.java index a54b615..2e3a1f5 100644 --- a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaDomainFilter.java +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaDomainFilter.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ===========LICENSE_START======================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,12 +20,14 @@ package org.onap.dcae.analytics.tca.core.util.function.calculation; +import java.util.List; import java.util.Optional; import org.onap.dcae.analytics.model.cef.CommonEventHeader; import org.onap.dcae.analytics.model.cef.Domain; import org.onap.dcae.analytics.model.cef.Event; import org.onap.dcae.analytics.model.cef.EventListener; +import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; import org.onap.dcae.analytics.tca.core.service.TcaExecutionContext; import org.onap.dcae.analytics.tca.core.service.TcaProcessingContext; @@ -54,19 +57,25 @@ public class TcaDomainFilter implements TcaCalculationFunction { } // Get Policy and CEF Message Domain - final String policyDomain = tcaExecutionContext.getTcaPolicy().getDomain(); + final List<TcaPolicy> tcaPolList = tcaExecutionContext.getTcaPolicy(); final String cefMessageDomain = domainOptional.get().name(); - - // Check Policy domain matches CEF message domain - if (!policyDomain.equalsIgnoreCase(cefMessageDomain)) { - final String earlyTerminationMessage = String.format( - "Policy Domain does not match CEF Message Domain. Policy Domain: %s, CEF Message Domain: %s", - policyDomain, cefMessageDomain); - setTerminatingMessage(earlyTerminationMessage, tcaExecutionContext, false); - return tcaExecutionContext; + + for( TcaPolicy tcaPol : tcaPolList){ + String policyDomain = tcaPol.getDomain(); + int size = tcaPolList.size(); + int count = 0; + // Check Policy domain matches CEF message domain + if (!policyDomain.equalsIgnoreCase(cefMessageDomain)) { + count++; + if (count >= size){ + final String earlyTerminationMessage = String.format( + "Policy Domain does not match CEF Message Domain. Policy Domain: %s, CEF Message Domain: %s", + policyDomain, cefMessageDomain); + setTerminatingMessage(earlyTerminationMessage, tcaExecutionContext, false); + return tcaExecutionContext; + } + } } - - // Policy Domain and CEF Message Domain match successful // do nothing diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventNameFilter.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventNameFilter.java index 574e9ba..e5f501e 100644 --- a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventNameFilter.java +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaEventNameFilter.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ==========LICENSE_START========================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,6 +22,7 @@ package org.onap.dcae.analytics.tca.core.util.function.calculation; import java.util.Optional; import java.util.Set; +import java.util.List; import java.util.stream.Collectors; import org.onap.dcae.analytics.model.cef.CommonEventHeader; @@ -56,17 +58,23 @@ public class TcaEventNameFilter implements TcaCalculationFunction { // Get CEF Message Event name and Event names in tca policy final String cefMessageEventName = eventNameOptional.get(); - final TcaPolicy tcaPolicy = tcaExecutionContext.getTcaPolicy(); - final Set<String> policyEventNames = tcaPolicy.getMetricsPerEventName().stream() + final List<TcaPolicy> tcaPolList = tcaExecutionContext.getTcaPolicy(); + int count = 0; + int size = tcaPolList.size(); + for( TcaPolicy tcaPol : tcaPolList){ + final Set<String> policyEventNames = tcaPol.getMetricsPerEventName().stream() .map(MetricsPerEventName::getEventName).collect(Collectors.toSet()); - - // Check CEF Message Event name matches any Policy Event names - if (!policyEventNames.contains(cefMessageEventName)) { - final String earlyTerminationMessage = String.format( - "CEF Message Event name does not match any Policy Event Names. " + + // Check CEF Message Event name matches any Policy Event names + if (!policyEventNames.contains(cefMessageEventName)) { + count++; + if(count >= size) { + final String earlyTerminationMessage = String.format( + "CEF Message Event name does not match any Policy Event Names. " + "Message EventName: %s, Policy Event Names: %s", cefMessageEventName, policyEventNames); - setTerminatingMessage(earlyTerminationMessage, tcaExecutionContext, false); - return tcaExecutionContext; + setTerminatingMessage(earlyTerminationMessage, tcaExecutionContext, false); + return tcaExecutionContext; + } + } } // CEF Messages one of the the Policy Event names diff --git a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaThresholdViolationCalculator.java b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaThresholdViolationCalculator.java index 053fcab..afa35ee 100644 --- a/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaThresholdViolationCalculator.java +++ b/dcae-analytics/dcae-analytics-tca-core/src/main/java/org/onap/dcae/analytics/tca/core/util/function/calculation/TcaThresholdViolationCalculator.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ============LICENSE_START======================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -39,6 +40,7 @@ import java.util.stream.Collectors; import javax.annotation.Nonnull; import org.onap.dcae.analytics.model.cef.CommonEventHeader; +import org.onap.dcae.analytics.model.cef.Domain; import org.onap.dcae.analytics.model.cef.Event; import org.onap.dcae.analytics.model.cef.EventListener; import org.onap.dcae.analytics.tca.core.exception.TcaProcessingException; @@ -52,13 +54,14 @@ import org.onap.dcae.analytics.tca.model.policy.Threshold; * @author Rajiv Singla */ public class TcaThresholdViolationCalculator implements TcaCalculationFunction { - + @Override public TcaExecutionContext calculate(final TcaExecutionContext tcaExecutionContext) { final String cefMessage = tcaExecutionContext.getCefMessage(); final EventListener eventListener = tcaExecutionContext.getTcaProcessingContext().getEventListener(); - final TcaPolicy tcaPolicy = tcaExecutionContext.getTcaPolicy(); + final List<TcaPolicy> tcaPolicy = tcaExecutionContext.getTcaPolicy(); + TcaPolicy tcaPolicyFinal = null; // Get CEF Event Name final String cefEventName = Optional.ofNullable(eventListener) @@ -66,18 +69,33 @@ public class TcaThresholdViolationCalculator implements TcaCalculationFunction { .map(Event::getCommonEventHeader) .map(CommonEventHeader::getEventName) .orElseThrow(() -> new TcaProcessingException("Required Field: EventName not present")); + + final Optional<Domain> domainName = Optional.ofNullable(eventListener) + .map(EventListener::getEvent) + .map(Event::getCommonEventHeader) + .map(CommonEventHeader::getDomain); - // Get Policy's metrics per event name matching CEF message event name - final MetricsPerEventName policyMetricsPerEventName = - tcaPolicy.getMetricsPerEventName().stream() - .filter(m -> m.getEventName().equalsIgnoreCase(cefEventName)) - .findFirst().orElseThrow(() -> - new TcaProcessingException("Required Field: MetricsPerEventName not present")); - + final String cefMessageDomain = domainName.get().name(); + for(TcaPolicy tca : tcaPolicy){ + if (tca.getDomain().equalsIgnoreCase(cefMessageDomain)){ + tcaPolicyFinal = tca; + break; + } + else + continue; + } + + // Get Policy's metrics per event name matching CEF message event name + final MetricsPerEventName policyMetricsPerEventName = + tcaPolicyFinal.getMetricsPerEventName().stream() + .filter(m -> m.getEventName().equalsIgnoreCase(cefEventName)) + .findFirst().orElseThrow(() -> + new TcaProcessingException("Required Field: MetricsPerEventName not present")); + // get violated policy threshold for cef event name sorted by severity final Optional<Threshold> thresholdOptional = - getViolatedThreshold(policyMetricsPerEventName.getThresholds(), cefMessage); + getViolatedThreshold(policyMetricsPerEventName.getThresholds(), cefMessage); // Check if threshold violation is present @@ -85,17 +103,17 @@ public class TcaThresholdViolationCalculator implements TcaCalculationFunction { final String earlyTerminationMessage = "No Policy Threshold violation detected in CEF Message"; setTerminatingMessage(earlyTerminationMessage, tcaExecutionContext, false); return tcaExecutionContext; - } - + } + // Threshold violations are present - update tca processing result context final MetricsPerEventName violatedMetricsPerEventName = copyMetricsPerEventName(policyMetricsPerEventName); final Threshold violatedThreshold = thresholdOptional.get(); violatedMetricsPerEventName.setThresholds(Collections.singletonList(violatedThreshold)); final TcaResultContext tcaResultContext = - tcaExecutionContext.getTcaResultContext(); + tcaExecutionContext.getTcaResultContext(); tcaResultContext.setViolatedMetricsPerEventName(violatedMetricsPerEventName); - + return tcaExecutionContext; } @@ -226,7 +244,6 @@ public class TcaThresholdViolationCalculator implements TcaCalculationFunction { } } } - return jsonFieldPathMap; } diff --git a/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/BaseTcaCoreTest.java b/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/BaseTcaCoreTest.java index 0d32190..23ff4e3 100644 --- a/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/BaseTcaCoreTest.java +++ b/dcae-analytics/dcae-analytics-tca-core/src/test/java/org/onap/dcae/analytics/tca/core/BaseTcaCoreTest.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ==========LICENSE_START========================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +20,8 @@ package org.onap.dcae.analytics.tca.core; +import java.util.List; + import org.onap.dcae.analytics.model.cef.EventListener; import org.onap.dcae.analytics.model.util.json.AnalyticsModelJsonConversion; import org.onap.dcae.analytics.tca.core.domain.TestTcaAaiEnrichmentContext; @@ -47,7 +50,7 @@ public abstract class BaseTcaCoreTest extends BaseAnalyticsUnitTest { protected static final String TEST_CEF_JSON_MESSAGE_WITH_ABATEMENT_STRING; protected static final String TEST_CEF_JSON_MESSAGE_WITH_INAPPLICABLE_EVENT_NAME; protected static final String TEST_REQUEST_ID = "testRequestId"; - protected static final TcaPolicy TEST_TCA_POLICY; + protected static final List<TcaPolicy> TEST_TCA_POLICY; static { @@ -102,7 +105,7 @@ public abstract class BaseTcaCoreTest extends BaseAnalyticsUnitTest { } protected GenericTcaExecutionContextBuilder getTestExecutionContextBuilder( - final String cefMessage, final TcaPolicy tcaPolicy, final TcaAbatementContext tcaAbatementContext) { + final String cefMessage, final List<TcaPolicy> tcaPolicy, final TcaAbatementContext tcaAbatementContext) { final TcaProcessingContext tcaProcessingContext = new GenericTcaProcessingContext(); final TcaResultContext tcaResultContext = new GenericTcaResultContext(); diff --git a/dcae-analytics/dcae-analytics-tca-model/pom.xml b/dcae-analytics/dcae-analytics-tca-model/pom.xml index 488d1c8..9b5223b 100644 --- a/dcae-analytics/dcae-analytics-tca-model/pom.xml +++ b/dcae-analytics/dcae-analytics-tca-model/pom.xml @@ -42,7 +42,8 @@ <description>Contains models for TCA (Threshold Crossing Alert) micro service</description> <properties> - <main.basedir>${project.parent.basedir}</main.basedir> + <main.basedir>${project.parent.basedir}</main.basedir> + <onap-gerrit-review>-changelog-missing</onap-gerrit-review> </properties> diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java index 024202a..8db9723 100644 --- a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/policy/MetricsPerEventName.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ===========LICENSE_START======================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -65,6 +66,7 @@ public class MetricsPerEventName extends BaseTcaPolicyModel { * Policy Thresholds */ private List<Threshold> thresholds; - + + public MetricsPerEventName() { } } diff --git a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java index aaec970..df14b32 100644 --- a/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java +++ b/dcae-analytics/dcae-analytics-tca-model/src/main/java/org/onap/dcae/analytics/tca/model/util/json/TcaModelJsonConversion.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ===========LICENSE_START======================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +25,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import java.util.Optional; import java.util.function.Function; +import java.util.List; import org.onap.dcae.analytics.model.util.function.JsonToJavaObjectBiFunction; import org.onap.dcae.analytics.tca.model.facade.TcaAlert; @@ -38,7 +40,7 @@ public abstract class TcaModelJsonConversion { public static final ObjectMapper TCA_OBJECT_MAPPER = new TcaObjectMapperSupplier().get(); // Type reference to convert tca policy string to tca policy object - private static final TypeReference<TcaPolicy> TCA_POLICY_TYPE_REF = new TypeReference<TcaPolicy>() { + private static final TypeReference<List<TcaPolicy>> TCA_POLICY_TYPE_REF = new TypeReference<List<TcaPolicy>>() { }; // Type reference to convert tca alert string to tca alert @@ -46,8 +48,8 @@ public abstract class TcaModelJsonConversion { }; // Tca Policy JSON conversion function - public static final Function<String, Optional<TcaPolicy>> TCA_POLICY_JSON_FUNCTION = new - JsonToJavaObjectBiFunction<TcaPolicy>(TCA_OBJECT_MAPPER).curry(TCA_POLICY_TYPE_REF); + public static final Function<String, Optional<List<TcaPolicy>>> TCA_POLICY_JSON_FUNCTION = new + JsonToJavaObjectBiFunction<List<TcaPolicy>>(TCA_OBJECT_MAPPER).curry(TCA_POLICY_TYPE_REF); // Tca Alert JSON conversion function public static final Function<String, Optional<TcaAlert>> TCA_ALERT_JSON_FUNCTION = new diff --git a/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java index 5592f3b..1cfc1b3 100644 --- a/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java +++ b/dcae-analytics/dcae-analytics-tca-model/src/test/java/org/onap/dcae/analytics/tca/model/util/json/mixin/policy/TcaPolicyMixinTest.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ============LICENSE_START======================================================= * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,6 +27,7 @@ import org.junit.jupiter.api.Test; import org.onap.dcae.analytics.tca.model.BaseTcaModelTest; import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; import org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion; +import java.util.List; /** * @author Rajiv Singla @@ -36,15 +38,16 @@ class TcaPolicyMixinTest extends BaseTcaModelTest { @DisplayName("Test TCA Policy JSON Conversions") void testTCAPolicyJsonConversions() throws Exception { - final TcaPolicy tcaPolicy = + final List<TcaPolicy> tcaPolicy = assertJsonConversions(TestFileLocation.TCA_POLICY_JSON, TcaModelJsonConversion .TCA_POLICY_JSON_FUNCTION, TcaModelJsonConversion.TCA_OBJECT_MAPPER); assertThat(tcaPolicy).isNotNull(); - assertThat(tcaPolicy.getMetricsPerEventName().size()) + TcaPolicy tcaPol = tcaPolicy.get(0); + assertThat(tcaPol.getMetricsPerEventName().size()) .as("TCA Policy Metrics Per Event Name must be 3").isEqualTo(3); - assertThat(tcaPolicy.getMetricsPerEventName().get(0).getThresholds().size()) + assertThat(tcaPol.getMetricsPerEventName().get(0).getThresholds().size()) .as("TCA Policy Thresholds for first event name must be 3").isEqualTo(3); // test tca policy serialization diff --git a/dcae-analytics/dcae-analytics-tca-web/dpo/blueprint/k8s-tca-gen2-web.yaml b/dcae-analytics/dcae-analytics-tca-web/dpo/blueprint/k8s-tca-gen2-web.yaml index 1ebeaeb..9db414a 100644 --- a/dcae-analytics/dcae-analytics-tca-web/dpo/blueprint/k8s-tca-gen2-web.yaml +++ b/dcae-analytics/dcae-analytics-tca-web/dpo/blueprint/k8s-tca-gen2-web.yaml @@ -1,6 +1,7 @@ # ============LICENSE_START==================================================== # ============================================================================= # Copyright (C) 2019 IBM +# Copyright (C) 2022 Wipro Limited Intellectual Property. All rights reserved. # ============================================================================= # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -96,7 +97,7 @@ node_templates: get_input: tca.aai.url tca.aai.username: get_input: tca.aai.username - tca.policy: {"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"Mfvs_eNodeB_RANKPI","controlLoopSchemaType":"VNF","policyScope":"resource=vFirewall;type=configuration","policyName":"configuration.dcae.microservice.tca.xml","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":4000,"direction":"LESS_OR_EQUAL","severity":"MAJOR"},{"closedLoopControlName":"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":20000,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL"},{"closedLoopControlName":"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09","closedLoopEventStatus":"ABATED","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":0,"direction":"EQUAL","severity":"CRITICAL"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VNF","policyScope":"resource=vLoadBalancer;type=configuration","policyName":"configuration.dcae.microservice.tca.xml","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":500,"direction":"LESS_OR_EQUAL","severity":"MAJOR"},{"closedLoopControlName":"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":5000,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL"}]},{"eventName":"virtualVMEventName","controlLoopSchemaType":"VM","policyScope":"resource=virtualVM;type=configuration","policyName":"configuration.dcae.microservice.tca.xml","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":500,"direction":"LESS_OR_EQUAL","severity":"MAJOR"}]}]} + tca.policy: [{"domain":"measurementsForVfScaling","metricsPerEventName":[{"eventName":"Mfvs_eNodeB_RANKPI","controlLoopSchemaType":"VNF","policyScope":"resource=vFirewall;type=configuration","policyName":"configuration.dcae.microservice.tca.xml","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":4000,"direction":"LESS_OR_EQUAL","severity":"MAJOR"},{"closedLoopControlName":"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":20000,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL"},{"closedLoopControlName":"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09","closedLoopEventStatus":"ABATED","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":0,"direction":"EQUAL","severity":"CRITICAL"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VNF","policyScope":"resource=vLoadBalancer;type=configuration","policyName":"configuration.dcae.microservice.tca.xml","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":500,"direction":"LESS_OR_EQUAL","severity":"MAJOR"},{"closedLoopControlName":"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":5000,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL"}]},{"eventName":"virtualVMEventName","controlLoopSchemaType":"VM","policyScope":"resource=virtualVM;type=configuration","policyName":"configuration.dcae.microservice.tca.xml","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A","closedLoopEventStatus":"ONSET","version":"1.0.2","fieldPath":"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated","thresholdValue":500,"direction":"LESS_OR_EQUAL","severity":"MAJOR"}]}]},{"domain":"measurement","metricsPerEventName":[{"eventName":"vFirewallBroadcastPackets","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"LESS_OR_EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a","version":"1.0.2","fieldPath":"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":700,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"vLoadBalancer","controlLoopSchemaType":"VM","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3","version":"1.0.2","fieldPath":"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta","thresholdValue":300,"direction":"GREATER_OR_EQUAL","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]},{"eventName":"Measurement_vGMUX","controlLoopSchemaType":"VNF","policyScope":"DCAE","policyName":"DCAE.Config_tca-hi-lo","policyVersion":"v0.0.1","thresholds":[{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"EQUAL","severity":"MAJOR","closedLoopEventStatus":"ABATED"},{"closedLoopControlName":"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e","version":"1.0.2","fieldPath":"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value","thresholdValue":0,"direction":"GREATER","severity":"CRITICAL","closedLoopEventStatus":"ONSET"}]}]}] tca.processing_batch_size: 10000 docker_config: interval: 30s diff --git a/dcae-analytics/dcae-analytics-tca-web/pom.xml b/dcae-analytics/dcae-analytics-tca-web/pom.xml index fc7ccaa..4ee9e50 100644 --- a/dcae-analytics/dcae-analytics-tca-web/pom.xml +++ b/dcae-analytics/dcae-analytics-tca-web/pom.xml @@ -47,6 +47,7 @@ <main.basedir>${project.parent.basedir}</main.basedir> <undertow-core.version>2.2.14.Final</undertow-core.version> <docker.image.name>onap/${project.groupId}.${project.artifactId}</docker.image.name> + <onap-gerrit-review>-changelog-missing</onap-gerrit-review> <maven.build.timestamp.format>yyyyMMdd'T'HHmmss</maven.build.timestamp.format> </properties> @@ -179,8 +180,8 @@ <id>tag-version</id> <phase>install</phase> <goals> - <goal>tag</goal> - <goal>push</goal> + <goal>tag</goal> + <goal>push</goal> </goals> <configuration> <tag>${project.version}</tag> diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/controller/TcaRestController.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/controller/TcaRestController.java index 402d475..91181ed 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/controller/TcaRestController.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/controller/TcaRestController.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * =============LICENSE_START====================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -64,14 +65,14 @@ public class TcaRestController { @GetMapping(value = TcaModelConstants.TCA_POLICY_ENDPOINT, produces = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Provides current TCA Policy") - public ResponseEntity<TcaPolicy> getTcaPolicy() { + public ResponseEntity<List<TcaPolicy>> getTcaPolicy() { return getTcaPolicyResponse(tcaPolicyWrapper); } @PostMapping(value = TcaModelConstants.TCA_POLICY_ENDPOINT, produces = MediaType.APPLICATION_JSON_VALUE, consumes = MediaType.APPLICATION_JSON_VALUE) @ApiOperation(value = "Sets new value for TCA Policy and returns current Policy") - public ResponseEntity<TcaPolicy> setTcaPolicy(@RequestBody final TcaPolicy tcaPolicy) { + public ResponseEntity<List<TcaPolicy>> setTcaPolicy(@RequestBody final List<TcaPolicy> tcaPolicy) { tcaPolicyWrapper.setTcaPolicy(tcaPolicy, ConfigSource.REST_API); return getTcaPolicyResponse(tcaPolicyWrapper); } @@ -103,7 +104,7 @@ public class TcaRestController { } - private static ResponseEntity<TcaPolicy> getTcaPolicyResponse(final TcaPolicyWrapper tcaPolicyWrapper) { + private static ResponseEntity<List<TcaPolicy>> getTcaPolicyResponse(final TcaPolicyWrapper tcaPolicyWrapper) { return ResponseEntity.ok() .header(TcaModelConstants.TCA_POLICY_SOURCE_HEADER_KEY, tcaPolicyWrapper.getConfigSource().name()) .header(TcaModelConstants.TCA_POLICY_CREATION_HEADER_KEY, diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java index fcfc3fe..1873c3c 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/domain/TcaPolicyWrapper.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ===========LICENSE_START===================================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,9 +24,11 @@ import static org.onap.dcae.analytics.tca.model.util.json.TcaModelJsonConversion import java.time.ZonedDateTime; import java.util.concurrent.atomic.AtomicInteger; +import java.util.List; import org.onap.dcae.analytics.model.common.ConfigSource; import org.onap.dcae.analytics.tca.core.exception.AnalyticsParsingException; +import org.onap.dcae.analytics.tca.core.exception.TcaProcessingException; import org.onap.dcae.analytics.tca.model.policy.TcaPolicy; import org.onap.dcae.analytics.tca.model.policy.TcaPolicyModel; import org.onap.dcae.analytics.tca.web.TcaAppProperties; @@ -57,7 +60,7 @@ public class TcaPolicyWrapper implements TcaPolicyModel { this.policyVersion = getPolicyVersion(new AtomicInteger(0)); } - public TcaPolicy getTcaPolicy() { + public List<TcaPolicy> getTcaPolicy() { String tcaPolicyString = tcaAppProperties.getTca().getPolicy(); boolean isConfigBindingServiceProfileActive = tcaAppProperties.isConfigBindingServiceProfileActive(); if (isConfigBindingServiceProfileActive) { @@ -75,15 +78,22 @@ public class TcaPolicyWrapper implements TcaPolicyModel { tcaPolicy, configSource.name(), policyVersion); } - return convertTcaPolicy(tcaPolicyString); + List<TcaPolicy> tcaPolicyList = convertTcaPolicy(tcaPolicyString); + if( tcaPolicyList.size() > 2) + { + throw new TcaProcessingException(" TCA Policy size exceeding limit of 2"); + } + else + return tcaPolicyList; + } - public void setTcaPolicy(TcaPolicy tcaPolicy, ConfigSource configSource) { + public void setTcaPolicy(List<TcaPolicy> tcaPolicy, ConfigSource configSource) { this.tcaPolicy = tcaPolicy.toString(); this.configSource = configSource; } - public TcaPolicy convertTcaPolicy(String tcaPolicyString) { + public List<TcaPolicy> convertTcaPolicy(String tcaPolicyString) { return TCA_POLICY_JSON_FUNCTION.apply(tcaPolicyString).orElseThrow( () -> new AnalyticsParsingException("Unable to parse Tca Policy String: " + tcaPolicyString, new IllegalArgumentException())); diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImpl.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImpl.java index 7f6891d..12cbcf8 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImpl.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImpl.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ==============LICENSE_START===================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,7 +60,7 @@ public class TcaProcessingServiceImpl implements TcaProcessingService { final TcaPolicyWrapper tcaPolicyWrapper, final List<String> cefMessages) { // create tca policy deep copy as it should be same for current execution - final TcaPolicy tcaPolicyDeepCopy = TcaUtils.getTcaPolicyDeepCopy(tcaPolicyWrapper.getTcaPolicy()); + final List<TcaPolicy> tcaPolicyDeepCopy = TcaUtils.getTcaPolicyDeepCopy(tcaPolicyWrapper.getTcaPolicy()); // create new request id if not present final String executionRequestId = isPresent(requestId) ? requestId : REQUEST_ID_SUPPLIER.get(); // create transaction id if not present diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidator.java b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidator.java index f380699..3f9dfc0 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidator.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidator.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ==========LICENSE_START====================================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -42,71 +43,75 @@ import org.springframework.validation.Errors; * * @author Rajiv Singla */ -public class TcaPolicyValidator implements AnalyticsValidator<TcaPolicy, GenericValidationResponse> { +public class TcaPolicyValidator implements AnalyticsValidator<List<TcaPolicy>, GenericValidationResponse> { private static final long serialVersionUID = 1L; @Override - public GenericValidationResponse apply(final TcaPolicy tcaPolicy) { + public GenericValidationResponse apply(final List<TcaPolicy> tcaPol) { final GenericValidationResponse validationResponse = new GenericValidationResponse(); - - // validate TCA Policy must domain present - final String domain = tcaPolicy.getDomain(); - if (isEmpty(domain)) { - validationResponse.addErrorMessage("domain", "TCA Policy must have only one domain present"); - } - - // validate TCA Policy must have at lease one metrics per event name - final List<MetricsPerEventName> metricsPerEventNames = tcaPolicy.getMetricsPerEventName(); - if (metricsPerEventNames == null || metricsPerEventNames.isEmpty()) { - validationResponse + + for( TcaPolicy tcaPolicy : tcaPol) { + + // validate TCA Policy must domain present + final String domain = tcaPolicy.getDomain(); + if (isEmpty(domain)) { + validationResponse.addErrorMessage("domain", "TCA Policy must have only one domain present"); + } + + // validate TCA Policy must have at lease one metrics per event name + final List<MetricsPerEventName> metricsPerEventNames = tcaPolicy.getMetricsPerEventName(); + if (metricsPerEventNames == null || metricsPerEventNames.isEmpty()) { + validationResponse .addErrorMessage("metricsPerEventName", "TCA Policy metricsPerEventName is empty"); - return validationResponse; - } + return validationResponse; + } - // validate Metrics Per Event Name - for (MetricsPerEventName metricsPerEventName : metricsPerEventNames) { + // validate Metrics Per Event Name + for (MetricsPerEventName metricsPerEventName : metricsPerEventNames) { - // event name must be present - final String eventName = metricsPerEventName.getEventName(); - if (isEmpty(eventName)) { - validationResponse.addErrorMessage("eventName", + // event name must be present + final String eventName = metricsPerEventName.getEventName(); + if (isEmpty(eventName)) { + validationResponse.addErrorMessage("eventName", "TCA Policy eventName is not present for metricsPerEventNames:" + metricsPerEventName); - } + } - // control Loop Schema type must be present - final ControlLoopSchemaType controlLoopSchemaType = metricsPerEventName.getControlLoopSchemaType(); - if (controlLoopSchemaType == null) { - validationResponse.addErrorMessage("controlLoopEventType", - "TCA Policy controlLoopSchemaType is not present for metricsPerEventNames:" + // control Loop Schema type must be present + final ControlLoopSchemaType controlLoopSchemaType = metricsPerEventName.getControlLoopSchemaType(); + if (controlLoopSchemaType == null) { + validationResponse.addErrorMessage("controlLoopEventType", + "TCA Policy controlLoopSchemaType is not present for metricsPerEventNames:" + metricsPerEventName); - } + } - // must have at least 1 threshold defined - final List<Threshold> thresholds = metricsPerEventName.getThresholds(); - if (thresholds == null || thresholds.isEmpty()) { - validationResponse.addErrorMessage("thresholds", + // must have at least 1 threshold defined + final List<Threshold> thresholds = metricsPerEventName.getThresholds(); + if (thresholds == null || thresholds.isEmpty()) { + validationResponse.addErrorMessage("thresholds", "TCA Policy event Name must have at least one threshold. " + "Event Name causing this validation error:" + metricsPerEventName); - } else { - // validate each threshold must have non null - fieldPath, thresholdValue, direction and severity - for (Threshold eventNameThreshold : thresholds) { - final String fieldPath = eventNameThreshold.getFieldPath(); - final Long thresholdValue = eventNameThreshold.getThresholdValue(); - final Direction direction = eventNameThreshold.getDirection(); - final EventSeverity severity = eventNameThreshold.getSeverity(); - final ClosedLoopEventStatus closedLoopEventStatus = eventNameThreshold.getClosedLoopEventStatus(); - if (isEmpty(fieldPath) || thresholdValue == null || direction == null || severity == null || + } else { + // validate each threshold must have non null - fieldPath, thresholdValue, direction and severity + for (Threshold eventNameThreshold : thresholds) { + final String fieldPath = eventNameThreshold.getFieldPath(); + final Long thresholdValue = eventNameThreshold.getThresholdValue(); + final Direction direction = eventNameThreshold.getDirection(); + final EventSeverity severity = eventNameThreshold.getSeverity(); + final ClosedLoopEventStatus closedLoopEventStatus = eventNameThreshold.getClosedLoopEventStatus(); + if (isEmpty(fieldPath) || thresholdValue == null || direction == null || severity == null || closedLoopEventStatus == null) { - validationResponse.addErrorMessage("threshold", + validationResponse.addErrorMessage("threshold", "TCA Policy threshold must have fieldPath,thresholdValue,direction, " + "closedLoopEventStatus and severity defined." + "Threshold causing this validation error:" + eventNameThreshold); - } - } - } - } + } + } + } + + } + } return validationResponse; } @@ -124,7 +129,7 @@ public class TcaPolicyValidator implements AnalyticsValidator<TcaPolicy, Generic return; } - final TcaPolicy tcaPolicy = (TcaPolicy) target; + final List<TcaPolicy> tcaPolicy = (List<TcaPolicy>) target; final GenericValidationResponse validationResponse = apply(tcaPolicy); if (validationResponse.hasErrors()) { errors.rejectValue("tca policy", validationResponse.getAllErrorMessage()); diff --git a/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml b/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml index 93f953c..ca8350d 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml +++ b/dcae-analytics/dcae-analytics-tca-web/src/main/resources/config/application-dev.yaml @@ -2,7 +2,7 @@ config-binding-service: config: tca: - policy: "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]}" + policy: "[{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]},{\"domain\":\"measurement\",\"metricsPerEventName\":[{\"eventName\":\"vFirewallBroadcastPackets\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":700,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"Measurement_vGMUX\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"GREATER\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]}]}]" processing_batch_size: 10000 enable_abatement: true enable_ecomp_logging: true diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/controller/TcaRestControllerTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/controller/TcaRestControllerTest.java index 001af0f..910579d 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/controller/TcaRestControllerTest.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/controller/TcaRestControllerTest.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ============LICENSE_START==================================================================== * Copyright (c) 2019 IBM Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,8 +22,10 @@ package org.onap.dcae.analytics.tca.web.controller; import java.time.ZonedDateTime; import java.util.Arrays; +import java.util.ArrayList; import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.onap.dcae.analytics.model.common.ConfigSource; @@ -39,12 +42,18 @@ public class TcaRestControllerTest { TcaPolicyWrapper tcaPolicyWrapper = Mockito.mock(TcaPolicyWrapper.class); TcaProcessingService tcaProcessingService = Mockito.mock(TcaProcessingService.class); TcaPolicy tcaPolicy = Mockito.mock(TcaPolicy.class); + List<TcaPolicy> TcaList = new ArrayList<TcaPolicy>(); + TcaList.add(tcaPolicy); Mockito.when(tcaPolicyWrapper.getConfigSource()).thenReturn(ConfigSource.valueOf("MONGO")); - Mockito.when(tcaPolicyWrapper.getTcaPolicy()).thenReturn(tcaPolicy); + Mockito.when(tcaPolicyWrapper.getTcaPolicy()).thenReturn(TcaList); Mockito.when(tcaPolicyWrapper.getCreationTime()).thenReturn(ZonedDateTime.now()); TcaRestController restcontroller = new TcaRestController(tcaProcessingService, tcaPolicyWrapper); restcontroller.getTcaPolicy(); - restcontroller.setTcaPolicy(tcaPolicy); + restcontroller.setTcaPolicy(TcaList); + assertThat(TcaList).isNotNull(); + assertThat(restcontroller.getTcaPolicy()).isNotNull(); + assertThat(restcontroller.setTcaPolicy(TcaList).getStatusCodeValue()).isEqualTo(200); + } @Test @@ -59,6 +68,7 @@ public class TcaRestControllerTest { .thenReturn(executionContexts); TcaRestController restcontroller = new TcaRestController(tcaProcessingService, tcaPolicyWrapper); restcontroller.execute(tcaExecutionRequest); + assertThat(restcontroller.execute(tcaExecutionRequest).getStatusCodeValue()).isEqualTo(200); } } diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformerTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformerTest.java index 8d1b45c..24ce60e 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformerTest.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/integration/TcaAlertTransformerTest.java @@ -1,8 +1,9 @@ /* - * ================================================================================ + * =============LICENSE_START====================================================== * Copyright (c) 2020 ChinaMobile. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ - * Copyright Copyright (c) 2019 IBM + * Copyright (c) 2019 IBM * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +24,8 @@ package org.onap.dcae.analytics.tca.web.integration; import java.util.ArrayList; import java.util.List; +import static org.assertj.core.api.Assertions.assertThat; + import org.junit.jupiter.api.Test; import org.mockito.Mockito; import org.onap.dcae.analytics.model.AnalyticsHttpConstants; @@ -54,7 +57,7 @@ public class TcaAlertTransformerTest extends BaseAnalyticsSpringBootIT { protected static final String TEST_POLICY_JSON_STRING; protected static final String TEST_REQUEST_ID = "testRequestId"; - protected static final TcaPolicy TEST_TCA_POLICY; + protected static final List<TcaPolicy> TEST_TCA_POLICY; static { @@ -85,7 +88,9 @@ public class TcaAlertTransformerTest extends BaseAnalyticsSpringBootIT { TcaAlertTransformer tcaAlertTransformer = new TcaAlertTransformer(properties); tcaAlertTransformer.doTransform(message); - + assertThat(message).isNotNull(); + assertThat(tcaAlertTransformer.doTransform(message)).getClass().getName().startsWith("TcaAlert"); + } protected TcaExecutionContext getTestExecutionContext(final String cefMessage) { @@ -94,7 +99,7 @@ public class TcaAlertTransformerTest extends BaseAnalyticsSpringBootIT { } protected GenericTcaExecutionContextBuilder getTestExecutionContextBuilder( - final String cefMessage, final TcaPolicy tcaPolicy, final TcaAbatementContext tcaAbatementContext) { + final String cefMessage, final List<TcaPolicy> tcaPolicy, final TcaAbatementContext tcaAbatementContext) { final TcaProcessingContext tcaProcessingContext = new GenericTcaProcessingContext(); final TcaResultContext tcaResultContext = new GenericTcaResultContext(); diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java index 5e9957e..ac01169 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/service/TcaProcessingServiceImplTest.java @@ -1,6 +1,7 @@ /* - * ================================================================================ + * ===========LICENSE_START======================================================== * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -41,29 +42,18 @@ import com.fasterxml.jackson.databind.ObjectMapper; */ class TcaProcessingServiceImplTest { -// @Autowired -// Environment environment; +// @Autowired +// Environment environment; - public TcaPolicy convertTcaPolicy(String tcaPolicyString) { - return TCA_POLICY_JSON_FUNCTION.apply(tcaPolicyString).orElseThrow( + public List<TcaPolicy> convertTcaPolicy(String tcaPolicyString) { + return TCA_POLICY_JSON_FUNCTION.apply(tcaPolicyString).orElseThrow( () -> new AnalyticsParsingException("Unable to parse Tca Policy String: " + tcaPolicyString, new IllegalArgumentException())); } + + String policy = "[{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]},{\"domain\":\"measurement\",\"metricsPerEventName\":[{\"eventName\":\"vFirewallBroadcastPackets\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":700,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"Measurement_vGMUX\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"GREATER\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]}]}]"; - @Test - void getTcaExecutionResults() throws Exception { - TcaAbatementContext tcaAbatementContext = new TestTcaAbatementContext(); - TcaAaiEnrichmentContext tcaAaiEnrichmentContext = new TestTcaAaiEnrichmentContext(); - - TcaPolicyWrapper tcaPolicyWrapper = Mockito.mock(TcaPolicyWrapper.class); -// TcaAppProperties tcaAppProperties = new TcaAppProperties(environment); - String policy = "{\"domain\":\"measurementsForVfScaling\",\"metricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ABATED\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"virtualVMEventName\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"resource=virtualVM;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"}]}]}"; -// TcaPolicyWrapper tcaPolicyWrapper = new TcaPolicyWrapper(tcaAppProperties); - TcaPolicy tcaPolicy = convertTcaPolicy(policy); - Mockito.when(tcaPolicyWrapper.getTcaPolicy()).thenReturn(tcaPolicy); - TcaProcessingService tcaProcessingService = new TcaProcessingServiceImpl(tcaAbatementContext, tcaAaiEnrichmentContext); - - String cefMessage = "{\r\n" + + String cefMessage = "{\r\n" + " \"event\": {\r\n" + " \"commonEventHeader\": {\r\n" + " \"domain\": \"measurementsForVfScaling\",\r\n" + @@ -141,7 +131,174 @@ class TcaProcessingServiceImplTest { "}\r\n" + ""; - String cefViolationMessage = "{\r\n" + + String cefV7Message = "{\r\n" + + " \"event\": {\r\n" + + " \"commonEventHeader\": {\r\n" + + " \"domain\": \"measurement\",\r\n" + + " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" + + " \"eventName\": \"vFirewallBroadcastPackets\",\r\n" + + " \"lastEpochMicrosec\": 1492639920787,\r\n" + + " \"nfNamingCode\": \"ENBE\",\r\n" + + " \"priority\": \"Normal\",\r\n" + + " \"reportingEntityId\": \"\",\r\n" + + " \"reportingEntityName\": \"vtc2e7admn2\",\r\n" + + " \"sequence\": 0,\r\n" + + " \"sourceId\": \"SCL01081_9B_1\",\r\n" + + " \"sourceName\": \"SCL01081\",\r\n" + + " \"startEpochMicrosec\": 1492639920787,\r\n" + + " \"version\": 3.0,\r\n" + + " \"vesEventListenerVersion\":\"7.2.1\"\r\n" + + " },\r\n" + + " \"measurementFields\": {\r\n" + + " \"additionalFields\": [\r\n" + + " {\r\n" + + " \"name\": \"software_version \",\r\n" + + " \"value\": \"version1\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"name\": \"vendor \",\r\n" + + " \"value\": \"Ericsson \"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"additionalMeasurements\": [\r\n" + + " {\r\n" + + " \"name\": \"OaaS_UC1_EricssonSleepingCell\",\r\n" + + " \"arrayOfFields\": [\r\n" + + " {\r\n" + + " \"name\": \"PMRAATTCBRA\",\r\n" + + " \"value\": \"1353\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"name\": \"PMRASUCCCBRA\",\r\n" + + " \"value\": \"1351\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"name\": \"PMCELLDOWNTIMEAUTO\",\r\n" + + " \"value\": \"0\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"name\": \"PMCELLDOWNTIMEMAN\",\r\n" + + " \"value\": \"0\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"name\": \"PMRRCCONNESTABATT\",\r\n" + + " \"value\": \"297\"\r\n" + + " },\r\n" + + " {\r\n" + + " \"name\": \"PMRRCCONNESTABSUCC\",\r\n" + + " \"value\": \"297\"\r\n" + + " }\r\n" + + " ]\r\n" + + " }\r\n" + + " ],\r\n" + + " \"nicPerformanceArray\": [\r\n" + + " {\r\n" + + " \"receivedBroadcastPacketsAccumulated\": 1002,\r\n" + + " \"receivedBroadcastPacketsDelta\": 5,\r\n" + + " \"receivedDiscardedPacketsAccumulated\": 12,\r\n" + + " \"receivedDiscardedPacketsDelta\": 2,\r\n" + + " \"receivedErrorPacketsAccumulated\": 2,\r\n" + + " \"receivedErrorPacketsDelta\": 1,\r\n" + + " \"valuesAreSuspect\": false,\r\n" + + " \"nicIdentifier\": \"someVNicIdentifier\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"measurementInterval\": 900,\r\n" + + " \"measurementFieldsVersion\": 2.0\r\n" + + " }\r\n" + + " }\r\n" + + "}\r\n" + + ""; + + String cefV7OnsetMessage = "{\r\n" + + " \"event\": {\r\n" + + " \"commonEventHeader\": {\r\n" + + " \"domain\": \"measurement\",\r\n" + + " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" + + " \"eventName\": \"vFirewallBroadcastPackets\",\r\n" + + " \"lastEpochMicrosec\": 1492639920787,\r\n" + + " \"nfNamingCode\": \"ENBE\",\r\n" + + " \"priority\": \"Normal\",\r\n" + + " \"reportingEntityId\": \"\",\r\n" + + " \"reportingEntityName\": \"vtc2e7admn2\",\r\n" + + " \"sequence\": 0,\r\n" + + " \"sourceId\": \"SCL01081_9B_1\",\r\n" + + " \"sourceName\": \"SCL01081\",\r\n" + + " \"startEpochMicrosec\": 1492639920787,\r\n" + + " \"version\": 3.0,\r\n" + + " \"vesEventListenerVersion\":\"7.2.1\"\r\n" + + " },\r\n" + + " \"measurementFields\": {\r\n" + + " \"cpuUsageArray\": [\r\n" + + " {\r\n" + + " \"percentUsage\": 0,\r\n" + + " \"cpuIdentifier\": \"cpu1\",\r\n" + + " \"cpuIdle\": 100,\r\n" + + " \"cpuUsageSystem\": 0\r\n" + + " }\r\n" + + " ],\r\n" + + " \"nicPerformanceArray\": [\r\n" + + " {\r\n" + + " \"receivedTotalPacketsDelta\": 1002,\r\n" + + " \"transmittedOctetsDelta\": 0,\r\n" + + " \"transmittedTotalPacketsDelta\": 0,\r\n" + + " \"receivedOctetsDelta\": 61200,\r\n" + + " \"valuesAreSuspect\": true,\r\n" + + " \"nicIdentifier\": \"someNicIdentifier\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"measurementInterval\": 900,\r\n" + + " \"measurementFieldsVersion\": 4.0\r\n" + + " }\r\n" + + " }\r\n" + + "}\r\n" + + ""; + + String cefV7AbatementMessage = "{\r\n" + + " \"event\": {\r\n" + + " \"commonEventHeader\": {\r\n" + + " \"domain\": \"measurement\",\r\n" + + " \"eventId\": \"UC1-SCL01081-1492639920787\",\r\n" + + " \"eventName\": \"vFirewallBroadcastPackets\",\r\n" + + " \"lastEpochMicrosec\": 1492639920787,\r\n" + + " \"nfNamingCode\": \"ENBE\",\r\n" + + " \"priority\": \"Normal\",\r\n" + + " \"reportingEntityId\": \"\",\r\n" + + " \"reportingEntityName\": \"vtc2e7admn2\",\r\n" + + " \"sequence\": 0,\r\n" + + " \"sourceId\": \"SCL01081_9B_1\",\r\n" + + " \"sourceName\": \"SCL01081\",\r\n" + + " \"startEpochMicrosec\": 1492639920787,\r\n" + + " \"version\": 3.0,\r\n" + + " \"vesEventListenerVersion\":\"7.2.1\"\r\n" + + " },\r\n" + + " \"measurementFields\": {\r\n" + + " \"cpuUsageArray\": [\r\n" + + " {\r\n" + + " \"percentUsage\": 0,\r\n" + + " \"cpuIdentifier\": \"cpu1\",\r\n" + + " \"cpuIdle\": 100,\r\n" + + " \"cpuUsageSystem\": 0\r\n" + + " }\r\n" + + " ],\r\n" + + " \"nicPerformanceArray\": [\r\n" + + " {\r\n" + + " \"receivedTotalPacketsDelta\": 100,\r\n" + + " \"transmittedOctetsDelta\": 0,\r\n" + + " \"transmittedTotalPacketsDelta\": 0,\r\n" + + " \"receivedOctetsDelta\": 61200,\r\n" + + " \"valuesAreSuspect\": true,\r\n" + + " \"nicIdentifier\": \"someNicIdentifier\"\r\n" + + " }\r\n" + + " ],\r\n" + + " \"measurementInterval\": 900,\r\n" + + " \"measurementFieldsVersion\": 4.0\r\n" + + " }\r\n" + + " }\r\n" + + "}\r\n" + + ""; + + String cefViolationMessage = "{\r\n" + " \"event\": {\r\n" + " \"commonEventHeader\": {\r\n" + " \"domain\": \"measurementsForVfScaling\",\r\n" + @@ -219,7 +376,7 @@ class TcaProcessingServiceImplTest { "}\r\n" + ""; - String cefAbatementMessage = "{\r\n" + + String cefAbatementMessage = "{\r\n" + " \"event\": {\r\n" + " \"commonEventHeader\": {\r\n" + " \"domain\": \"measurementsForVfScaling\",\r\n" + @@ -297,7 +454,7 @@ class TcaProcessingServiceImplTest { "}\r\n" + ""; - String cefInapplicableMessage = "{\r\n" + + String cefInapplicableMessage = "{\r\n" + " \"event\": {\r\n" + " \"commonEventHeader\": {\r\n" + " \"domain\": \"measurementsForVfScaling\",\r\n" + @@ -375,13 +532,22 @@ class TcaProcessingServiceImplTest { "}\r\n" + ""; - ObjectMapper objectMapper = new ObjectMapper(); - final List<TcaExecutionContext> tcaExecutionResults = tcaProcessingService.getTcaExecutionResults( + @Test + void getTcaExecutionResults() throws Exception { + TcaAbatementContext tcaAbatementContext = new TestTcaAbatementContext(); + TcaAaiEnrichmentContext tcaAaiEnrichmentContext = new TestTcaAaiEnrichmentContext(); + TcaPolicyWrapper tcaPolicyWrapper = Mockito.mock(TcaPolicyWrapper.class); + + List<TcaPolicy> tcaPolicy = convertTcaPolicy(policy); + Mockito.when(tcaPolicyWrapper.getTcaPolicy()).thenReturn(tcaPolicy); + TcaProcessingService tcaProcessingService = new TcaProcessingServiceImpl(tcaAbatementContext, tcaAaiEnrichmentContext); + + ObjectMapper objectMapper = new ObjectMapper(); + final List<TcaExecutionContext> tcaExecutionResults = tcaProcessingService.getTcaExecutionResults( "testRequestId", "testTransactionId", tcaPolicyWrapper, Arrays.asList(cefMessage, cefViolationMessage, - cefAbatementMessage, - cefInapplicableMessage)); - + cefAbatementMessage)); + for (TcaExecutionContext tcaExecutionResult : tcaExecutionResults) { final TcaAlert tcaAlert = tcaExecutionResult.getTcaResultContext().getTcaAlert(); String tcaAlertString = ""; @@ -390,6 +556,31 @@ class TcaProcessingServiceImplTest { } } } + + @Test + void getTcaExecutionResultsV7() throws Exception{ + TcaAbatementContext tcaAbatementContext = new TestTcaAbatementContext(); + TcaAaiEnrichmentContext tcaAaiEnrichmentContext = new TestTcaAaiEnrichmentContext(); + TcaPolicyWrapper tcaPolicyWrapper = Mockito.mock(TcaPolicyWrapper.class); + + List<TcaPolicy> tcaPolicy = convertTcaPolicy(policy); + Mockito.when(tcaPolicyWrapper.getTcaPolicy()).thenReturn(tcaPolicy); + TcaProcessingService tcaProcessingService = new TcaProcessingServiceImpl(tcaAbatementContext, tcaAaiEnrichmentContext); + + ObjectMapper objectMapper = new ObjectMapper(); + final List<TcaExecutionContext> tcaExecutionResults = tcaProcessingService.getTcaExecutionResults( + "testRequestId", "testTransactionId", tcaPolicyWrapper, + Arrays.asList(cefV7Message, cefV7OnsetMessage, + cefV7AbatementMessage)); + + for (TcaExecutionContext tcaExecutionResult : tcaExecutionResults) { + final TcaAlert tcaAlert = tcaExecutionResult.getTcaResultContext().getTcaAlert(); + String tcaAlertString = ""; + if (tcaAlert != null) { + tcaAlertString = objectMapper.writeValueAsString(tcaAlert); + } + } + } } diff --git a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidateTest.java b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidateTest.java index 36ed37e..949d696 100644 --- a/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidateTest.java +++ b/dcae-analytics/dcae-analytics-tca-web/src/test/java/org/onap/dcae/analytics/tca/web/validation/TcaPolicyValidateTest.java @@ -1,8 +1,9 @@ /* - * ================================================================================ + * ===========LICENSE_START===================================================================== * Copyright (c) 2020 ChinaMobile. All rights reserved. + * Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. * ================================================================================ - * Copyright Copyright (c) 2019 IBM + * Copyright (c) 2019 IBM * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,6 +21,8 @@ */ package org.onap.dcae.analytics.tca.web.validation; +import java.util.List; + import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; import org.mockito.Mockito; @@ -46,7 +49,7 @@ public class TcaPolicyValidateTest extends BaseAnalyticsSpringBootIT { Errors errors = Mockito.mock(Errors.class); TcaPolicyWrapper tcaPolicyWrapper = new TcaPolicyWrapper(properties); tcaPolicyWrapper.getConfigSource(); - TcaPolicy tcaPolicy = tcaPolicyWrapper.getTcaPolicy(); + List<TcaPolicy> tcaPolicy = tcaPolicyWrapper.getTcaPolicy(); validate.validate(tcaPolicy, errors); validate.apply(tcaPolicy); Assertions.assertEquals("version-0", tcaPolicyWrapper.getPolicyVersion()); diff --git a/dcae-analytics/dcae-analytics-test/pom.xml b/dcae-analytics/dcae-analytics-test/pom.xml index ea2ca88..14f8ce4 100644 --- a/dcae-analytics/dcae-analytics-test/pom.xml +++ b/dcae-analytics/dcae-analytics-test/pom.xml @@ -42,7 +42,8 @@ <description>Contains common testing code for all DCAE Analytics Modules</description> <properties> - <main.basedir>${project.parent.basedir}</main.basedir> + <main.basedir>${project.parent.basedir}</main.basedir> + <onap-gerrit-review>-changelog-missing</onap-gerrit-review> </properties> <dependencies> diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/policy/tca_policy.json b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/policy/tca_policy.json index e2560bd..dbf52c6 100644 --- a/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/policy/tca_policy.json +++ b/dcae-analytics/dcae-analytics-test/src/main/resources/data/json/policy/tca_policy.json @@ -1,4 +1,4 @@ -{ +[{ "domain": "measurementsForVfScaling", "metricsPerEventName": [ { @@ -82,5 +82,82 @@ } ] } - ] -} + ]}, + { + "domain": "measurement", + "metricsPerEventName": [ + { + "eventName": "vFirewallBroadcastPackets", + "controlLoopSchemaType": "VM", + "policyScope": "DCAE", + "policyName": "DCAE.Config_tca-hi-lo", + "policyVersion": "v0.0.1", + "thresholds": [ + { + "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", + "version": "1.0.2", + "fieldPath": "$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta", + "thresholdValue": 300, + "direction": "LESS_OR_EQUAL", + "severity": "MAJOR", + "closedLoopEventStatus": "ABATED" + }, + { + "closedLoopControlName": "ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a", + "version": "1.0.2", + "fieldPath": "$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta", + "thresholdValue": 700, + "direction": "GREATER_OR_EQUAL", + "severity": "CRITICAL", + "closedLoopEventStatus": "ONSET" + } + ] + }, + { + "eventName": "vLoadBalancer", + "controlLoopSchemaType": "VM", + "policyScope": "DCAE", + "policyName": "DCAE.Config_tca-hi-lo", + "policyVersion": "v0.0.1", + "thresholds": [ + { + "closedLoopControlName": "ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3", + "version": "1.0.2", + "fieldPath": "$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta", + "thresholdValue": 300, + "direction": "GREATER_OR_EQUAL", + "severity": "CRITICAL", + "closedLoopEventStatus": "ONSET" + } + ] + }, + { + "eventName": "Measurement_vGMUX", + "controlLoopSchemaType": "VNF", + "policyScope": "DCAE", + "policyName": "DCAE.Config_tca-hi-lo", + "policyVersion": "v0.0.1", + "thresholds": [ + { + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "version": "1.0.2", + "fieldPath": "$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value", + "thresholdValue": 0, + "direction": "EQUAL", + "severity": "MAJOR", + "closedLoopEventStatus": "ABATED" + }, + { + "closedLoopControlName": "ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e", + "version": "1.0.2", + "fieldPath": "$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value", + "thresholdValue": 0, + "direction": "GREATER", + "severity": "CRITICAL", + "closedLoopEventStatus": "ONSET" + } + ] + } + ] + } +] diff --git a/dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy_from_json.properties b/dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy_from_json.properties index 22216a6..d0f5707 100644 --- a/dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy_from_json.properties +++ b/dcae-analytics/dcae-analytics-test/src/main/resources/data/properties/tca_controller_policy_from_json.properties @@ -1,6 +1,7 @@ # -# ================================================================================ +# ==========LICENSE_START========================================================= # Copyright (c) 2018 AT&T Intellectual Property. All rights reserved. +# Copyright (c) 2022 Wipro Limited Intellectual Property. All rights reserved. # ================================================================================ # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -37,5 +38,5 @@ aaiEnrichmentIgnoreSSLCertificateErrors=true aaiVNFEnrichmentAPIPath=/aai/v11/network/generic-vnfs/generic-vnf aaiVMEnrichmentAPIPath=/aai/v11/search/nodes-query aaiEnrichmentProxyURL=http://username:password@proxyhost.com:8080 -tca_policy={\"domain\":\"measurementsForVfScaling\",\"violatedMetricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]}]} +tca_policy= [{\"domain\":\"measurementsForVfScaling\",\"violatedMetricsPerEventName\":[{\"eventName\":\"Mfvs_eNodeB_RANKPI\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vFirewall;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-FRWL-LOW-TRAFFIC-SIG-d925ed73-8231-4d02-9545-db4e101f88f8\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":4000,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-FRWL-HIGH-TRAFFIC-SIG-EA36FE84-9342-5E13-A656-EC5F21309A09\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":20000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"resource=vLoadBalancer;type=configuration\",\"policyName\":\"configuration.dcae.microservice.tca.xml\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-FB480F95-A453-6F24-B767-FD703241AB1A\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":500,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\"},{\"closedLoopControlName\":\"CL-LBAL-LOW-TRAFFIC-SIG-0C5920A6-B564-8035-C878-0E814352BC2B\",\"closedLoopEventStatus\":\"ONSET\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated\",\"thresholdValue\":5000,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\"}]}]},{\"domain\":\"measurement\",\"metricsPerEventName\":[{\"eventName\":\"vFirewallBroadcastPackets\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"LESS_OR_EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vFirewall-d0a1dfc6-94f5-4fd4-a5b5-4630b438850a\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":700,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"vLoadBalancer\",\"controlLoopSchemaType\":\"VM\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vDNS-6f37f56d-a87d-4b85-b6a9-cc953cf779b3\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.nicPerformanceArray[*].receivedTotalPacketsDelta\",\"thresholdValue\":300,\"direction\":\"GREATER_OR_EQUAL\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]},{\"eventName\":\"Measurement_vGMUX\",\"controlLoopSchemaType\":\"VNF\",\"policyScope\":\"DCAE\",\"policyName\":\"DCAE.Config_tca-hi-lo\",\"policyVersion\":\"v0.0.1\",\"thresholds\":[{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"EQUAL\",\"severity\":\"MAJOR\",\"closedLoopEventStatus\":\"ABATED\"},{\"closedLoopControlName\":\"ControlLoop-vCPE-48f0c2c3-a172-4192-9ae3-052274181b6e\",\"version\":\"1.0.2\",\"fieldPath\":\"$.event.measurementFields.additionalMeasurements[*].arrayOfFields[0].value\",\"thresholdValue\":0,\"direction\":\"GREATER\",\"severity\":\"CRITICAL\",\"closedLoopEventStatus\":\"ONSET\"}]}]}] diff --git a/dcae-analytics/dcae-analytics-web/pom.xml b/dcae-analytics/dcae-analytics-web/pom.xml index 6244dea..3c09734 100644 --- a/dcae-analytics/dcae-analytics-web/pom.xml +++ b/dcae-analytics/dcae-analytics-web/pom.xml @@ -46,6 +46,7 @@ <main.basedir>${project.parent.basedir}</main.basedir> <undertow-core.version>2.2.14.Final</undertow-core.version> <httpclient.version>4.5.13</httpclient.version> + <onap-gerrit-review>-changelog-missing</onap-gerrit-review> </properties> <dependencies> diff --git a/dcae-analytics/pom.xml b/dcae-analytics/pom.xml index ce7521e..276d496 100644 --- a/dcae-analytics/pom.xml +++ b/dcae-analytics/pom.xml @@ -113,6 +113,7 @@ <releases.path>content/repositories/releases/</releases.path> <docker.repository>nexus3.onap.org:10003</docker.repository> <spring-swagger-ui.version>2.10.5</spring-swagger-ui.version> + <onap-gerrit-review>-changelog-missing</onap-gerrit-review> <!-- SONAR EXCLUSIONS --> <!-- EXCLUDE TEST COVERAGE ON @@ -128,8 +129,6 @@ </properties> - - <dependencyManagement> <dependencies> diff --git a/dcae-analytics/version.properties b/dcae-analytics/version.properties index 5672fef..a486fcb 100644 --- a/dcae-analytics/version.properties +++ b/dcae-analytics/version.properties @@ -22,7 +22,7 @@ # major=1 minor=3 -patch=3 +patch=4 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT @@ -36,7 +36,7 @@ <version>${revision}</version> <properties> - <revision>1.3.3-SNAPSHOT</revision> + <revision>1.3.4-SNAPSHOT</revision> </properties> <name>dcaegen2-analytics-tca-gen2</name> diff --git a/version.properties b/version.properties index 4aaa531..ef87c2e 100644 --- a/version.properties +++ b/version.properties @@ -20,7 +20,7 @@ ################################################################################## major=1 minor=3 -patch=3 +patch=4 base_version=${major}.${minor}.${patch} release_version=${base_version} snapshot_version=${base_version}-SNAPSHOT |