summaryrefslogtreecommitdiffstats
path: root/main/src/test
diff options
context:
space:
mode:
authorChenfei Gao <cgao@research.att.com>2019-04-10 16:54:47 -0400
committerChenfei Gao <cgao@research.att.com>2019-04-10 21:11:48 -0400
commita229e2bccfdcf40c56c4d87d9e3cc5cd9dabb2a8 (patch)
treeb082f9f4f8f0ebb5aed960bb3491893b5e35a75a /main/src/test
parentf3dfe9dc5029c7f2628d9bd2810b61543902d70c (diff)
Modify delete safety net and DB lab setup
Includes: a) Close db connection using try-with-resource b) Modify delete safety net for policy, policy type and legacy policies c) Modify db persistence d) Modify db setup in bootstrap config e) Add unit tests for providers and endpoints Issue-ID: POLICY-1441 Change-Id: Id89bc361c73380df61df35f01f296e47e936e9cf Signed-off-by: Chenfei Gao <cgao@research.att.com>
Diffstat (limited to 'main/src/test')
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java107
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java98
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java133
-rw-r--r--main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java112
-rw-r--r--main/src/test/resources/policies/vCPE.policy.bad.policytypeid.json50
-rw-r--r--main/src/test/resources/policies/vCPE.policy.bad.policytypeversion.json51
-rw-r--r--main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json432
7 files changed, 694 insertions, 289 deletions
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
index 08f7fecd..085255f3 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyGuardPolicyProvider.java
@@ -22,20 +22,26 @@
package org.onap.policy.api.main.rest.provider;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
import java.util.Base64;
-import org.junit.Before;
+import java.util.Map;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyInput;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyGuardPolicyOutput;
/**
* This class performs unit test of {@link LegacyGuardPolicyProvider}
@@ -44,38 +50,105 @@ import org.slf4j.LoggerFactory;
*/
public class TestLegacyGuardPolicyProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(TestPolicyProvider.class);
+ private static LegacyGuardPolicyProvider guardPolicyProvider;
+ private static PolicyModelsProviderParameters providerParams;
+ private static ApiParameterGroup apiParamGroup;
+ private static StandardCoder standardCoder;
- private LegacyGuardPolicyProvider guardPolicyProvider;
+ private static final String POLICY_RESOURCE = "policies/vDNS.policy.guard.frequency.input.json";
/**
- * Initialize parameters.
+ * Initializes parameters.
+ *
+ * @throws PfModelException the PfModel parsing exception
*/
- @Before
- public void setupParameters() throws PfModelException {
-
- PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
- parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
- parameters.setDatabaseUser("policy");
- parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
- parameters.setPersistenceUnit("ToscaConceptTest");
- ApiParameterGroup paramGroup = new ApiParameterGroup("ApiGroup", null, parameters);
- ParameterService.register(paramGroup, true);
+ @BeforeClass
+ public static void setupParameters() throws PfModelException {
+
+ standardCoder = new StandardCoder();
+ providerParams = new PolicyModelsProviderParameters();
+ providerParams.setDatabaseUrl("jdbc:h2:mem:testdb");
+ providerParams.setDatabaseUser("policy");
+ providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ providerParams.setPersistenceUnit("ToscaConceptTest");
+ apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
+ ParameterService.register(apiParamGroup, true);
guardPolicyProvider = new LegacyGuardPolicyProvider();
}
+ /**
+ * Closes up DB connections and deregisters API parameter group.
+ *
+ * @throws PfModelException the PfModel parsing exception
+ */
+ @AfterClass
+ public static void tearDown() throws PfModelException {
+
+ guardPolicyProvider.close();
+ ParameterService.deregister(apiParamGroup);
+ }
+
+
@Test
public void testFetchGuardPolicy() {
+ assertThatThrownBy(() -> {
+ guardPolicyProvider.fetchGuardPolicy("dummy", null);
+ }).hasMessage("no policy found for policy ID: dummy");
+
+ assertThatThrownBy(() -> {
+ guardPolicyProvider.fetchGuardPolicy("dummy", "dummy");
+ }).hasMessage("no policy found for policy ID: dummy");
}
@Test
public void testCreateGuardPolicy() {
+ assertThatCode(() -> {
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ LegacyGuardPolicyInput policyToCreate = standardCoder.decode(policyString, LegacyGuardPolicyInput.class);
+ Map<String, LegacyGuardPolicyOutput> createdPolicy = guardPolicyProvider.createGuardPolicy(policyToCreate);
+ assertNotNull(createdPolicy);
+ assertFalse(createdPolicy.isEmpty());
+ assertTrue(createdPolicy.containsKey("guard.frequency.scaleout"));
+ assertEquals("onap.policies.controlloop.guard.FrequencyLimiter",
+ createdPolicy.get("guard.frequency.scaleout").getType());
+ assertEquals("1.0.0", createdPolicy.get("guard.frequency.scaleout").getVersion());
+ }).doesNotThrowAnyException();
}
@Test
public void testDeleteGuardPolicy() {
+ assertThatThrownBy(() -> {
+ guardPolicyProvider.deleteGuardPolicy("dummy", null);
+ }).hasMessage("version is marked @NonNull but is null");
+
+ assertThatThrownBy(() -> {
+ guardPolicyProvider.deleteGuardPolicy("dummy", "dummy");
+ }).hasMessage("no policy found for policy ID: dummy");
+
+ assertThatCode(() -> {
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ LegacyGuardPolicyInput policyToCreate = standardCoder.decode(policyString, LegacyGuardPolicyInput.class);
+ Map<String, LegacyGuardPolicyOutput> createdPolicy = guardPolicyProvider.createGuardPolicy(policyToCreate);
+ assertNotNull(createdPolicy);
+ assertFalse(createdPolicy.isEmpty());
+ }).doesNotThrowAnyException();
+
+ assertThatCode(() -> {
+ Map<String, LegacyGuardPolicyOutput> deletedPolicy = guardPolicyProvider
+ .deleteGuardPolicy("guard.frequency.scaleout", "1.0.0");
+ assertNotNull(deletedPolicy);
+ assertFalse(deletedPolicy.isEmpty());
+ assertTrue(deletedPolicy.containsKey("guard.frequency.scaleout"));
+ assertEquals("onap.policies.controlloop.guard.FrequencyLimiter",
+ deletedPolicy.get("guard.frequency.scaleout").getType());
+ assertEquals("1.0.0", deletedPolicy.get("guard.frequency.scaleout").getVersion());
+ }).doesNotThrowAnyException();
+
+ assertThatThrownBy(() -> {
+ guardPolicyProvider.deleteGuardPolicy("guard.frequency.scaleout", "1.0.0");
+ }).hasMessage("no policy found for policy ID: guard.frequency.scaleout");
}
}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
index 86124c74..e9adae7c 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestLegacyOperationalPolicyProvider.java
@@ -22,20 +22,23 @@
package org.onap.policy.api.main.rest.provider;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertTrue;
import java.util.Base64;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.policy.models.tosca.legacy.concepts.LegacyOperationalPolicy;
/**
* This class performs unit test of {@link LegacyOperationalPolicyProvider}
@@ -44,38 +47,99 @@ import org.slf4j.LoggerFactory;
*/
public class TestLegacyOperationalPolicyProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(TestPolicyProvider.class);
+ private static LegacyOperationalPolicyProvider operationalPolicyProvider;
+ private static PolicyModelsProviderParameters providerParams;
+ private static ApiParameterGroup apiParamGroup;
+ private static StandardCoder standardCoder;
- private LegacyOperationalPolicyProvider operationalPolicyProvider;
+ private static final String POLICY_RESOURCE = "policies/vCPE.policy.operational.input.json";
/**
- * Initialize parameters.
+ * Initializes parameters.
+ *
+ * @throws PfModelException the PfModel parsing exception
*/
- @Before
- public void setupParameters() throws PfModelException {
-
- PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
- parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
- parameters.setDatabaseUser("policy");
- parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
- parameters.setPersistenceUnit("ToscaConceptTest");
- ApiParameterGroup paramGroup = new ApiParameterGroup("ApiGroup", null, parameters);
- ParameterService.register(paramGroup, true);
+ @BeforeClass
+ public static void setupParameters() throws PfModelException {
+
+ standardCoder = new StandardCoder();
+ providerParams = new PolicyModelsProviderParameters();
+ providerParams.setDatabaseUrl("jdbc:h2:mem:testdb");
+ providerParams.setDatabaseUser("policy");
+ providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ providerParams.setPersistenceUnit("ToscaConceptTest");
+ apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
+ ParameterService.register(apiParamGroup, true);
operationalPolicyProvider = new LegacyOperationalPolicyProvider();
}
+ /**
+ * Closes up DB connections and deregisters API parameter group.
+ *
+ * @throws PfModelException the PfModel parsing exception
+ */
+ @AfterClass
+ public static void tearDown() throws PfModelException {
+
+ operationalPolicyProvider.close();
+ ParameterService.deregister(apiParamGroup);
+ }
+
@Test
public void testFetchOperationalPolicy() {
+ assertThatThrownBy(() -> {
+ operationalPolicyProvider.fetchOperationalPolicy("dummy", null);
+ }).hasMessage("no policy found for policy ID: dummy");
+
+ assertThatThrownBy(() -> {
+ operationalPolicyProvider.fetchOperationalPolicy("dummy", "dummy");
+ }).hasMessage("no policy found for policy ID: dummy");
}
@Test
public void testCreateOperationalPolicy() {
+ assertThatCode(() -> {
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ LegacyOperationalPolicy policyToCreate = standardCoder.decode(policyString, LegacyOperationalPolicy.class);
+ LegacyOperationalPolicy createdPolicy = operationalPolicyProvider.createOperationalPolicy(policyToCreate);
+ assertNotNull(createdPolicy);
+ assertEquals("operational.restart", createdPolicy.getPolicyId());
+ assertTrue(createdPolicy.getContent()
+ .startsWith("controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20"));
+ }).doesNotThrowAnyException();
}
@Test
public void testDeleteOperationalPolicy() {
+ assertThatThrownBy(() -> {
+ operationalPolicyProvider.deleteOperationalPolicy("dummy", null);
+ }).hasMessage("version is marked @NonNull but is null");
+
+ assertThatThrownBy(() -> {
+ operationalPolicyProvider.deleteOperationalPolicy("dummy", "dummy");
+ }).hasMessage("no policy found for policy ID: dummy");
+
+ assertThatCode(() -> {
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ LegacyOperationalPolicy policyToCreate = standardCoder.decode(policyString, LegacyOperationalPolicy.class);
+ LegacyOperationalPolicy createdPolicy = operationalPolicyProvider.createOperationalPolicy(policyToCreate);
+ assertNotNull(createdPolicy);
+ }).doesNotThrowAnyException();
+
+ assertThatCode(() -> {
+ LegacyOperationalPolicy deletedPolicy = operationalPolicyProvider
+ .deleteOperationalPolicy("operational.restart", "1.0.0");
+ assertNotNull(deletedPolicy);
+ assertEquals("operational.restart", deletedPolicy.getPolicyId());
+ assertTrue(deletedPolicy.getContent()
+ .startsWith("controlLoop%3A%0A%20%20version%3A%202.0.0%0A%20%20"));
+ }).doesNotThrowAnyException();
+
+ assertThatThrownBy(() -> {
+ operationalPolicyProvider.deleteOperationalPolicy("operational.restart", "1.0.0");
+ }).hasMessage("no policy found for policy ID: operational.restart");
}
}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
index eeb4dbae..7720575a 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyProvider.java
@@ -22,20 +22,21 @@
package org.onap.policy.api.main.rest.provider;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertFalse;
import java.util.Base64;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
* This class performs unit test of {@link PolicyProvider}
@@ -44,49 +45,141 @@ import org.slf4j.LoggerFactory;
*/
public class TestPolicyProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(TestPolicyProvider.class);
+ private static PolicyProvider policyProvider;
+ private static PolicyTypeProvider policyTypeProvider;
+ private static PolicyModelsProviderParameters providerParams;
+ private static ApiParameterGroup apiParamGroup;
+ private static StandardCoder standardCoder;
- private PolicyProvider policyProvider;
+ private static final String POLICY_RESOURCE = "policies/vCPE.policy.monitoring.input.tosca.json";
+ private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json";
+ private static final String POLICY_RESOURCE_WITH_BAD_POLICYTYPE_ID = "policies/vCPE.policy.bad.policytypeid.json";
+ private static final String POLICY_RESOURCE_WITH_BAD_POLICYTYPE_VERSION =
+ "policies/vCPE.policy.bad.policytypeversion.json";
/**
- * Initialize parameters.
+ * Initializes parameters.
+ *
+ * @throws PfModelException the PfModel parsing exception
*/
- @Before
- public void setupParameters() throws PfModelException {
-
- PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
- parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
- parameters.setDatabaseUser("policy");
- parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
- parameters.setPersistenceUnit("ToscaConceptTest");
- ApiParameterGroup paramGroup = new ApiParameterGroup("ApiGroup", null, parameters);
- ParameterService.register(paramGroup, true);
+ @BeforeClass
+ public static void setupParameters() throws PfModelException {
+
+ standardCoder = new StandardCoder();
+ providerParams = new PolicyModelsProviderParameters();
+ providerParams.setDatabaseUrl("jdbc:h2:mem:testdb");
+ providerParams.setDatabaseUser("policy");
+ providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ providerParams.setPersistenceUnit("ToscaConceptTest");
+ apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
+ ParameterService.register(apiParamGroup, true);
+ policyTypeProvider = new PolicyTypeProvider();
policyProvider = new PolicyProvider();
- System.out.println("xxxx");
+ }
+
+ /**
+ * Closes up DB connections and deregisters API parameter group.
+ *
+ * @throws PfModelException the PfModel parsing exception
+ */
+ @AfterClass
+ public static void tearDown() throws PfModelException {
+
+ policyTypeProvider.close();
+ policyProvider.close();
+ ParameterService.deregister(apiParamGroup);
}
@Test
public void testFetchPolicies() {
+ assertThatThrownBy(() -> {
+ policyProvider.fetchPolicies("dummy", "dummy", null, null);
+ }).hasMessage("policy with ID null:null and type dummy:dummy does not exist");
+
+ assertThatThrownBy(() -> {
+ policyProvider.fetchPolicies("dummy", "dummy", "dummy", null);
+ }).hasMessage("policy with ID dummy:null and type dummy:dummy does not exist");
+
+ assertThatThrownBy(() -> {
+ policyProvider.fetchPolicies("dummy", "dummy", "dummy", "dummy");
+ }).hasMessage("policy with ID dummy:dummy and type dummy:dummy does not exist");
}
@Test
public void testFetchLatestPolicies() {
+ assertThatThrownBy(() -> {
+ policyProvider.fetchLatestPolicies("dummy", "dummy", "dummy");
+ }).hasMessage("policy with ID dummy:null and type dummy:dummy does not exist");
}
@Test
public void testFetchDeployedPolicies() {
+ assertThatThrownBy(() -> {
+ policyProvider.fetchDeployedPolicies("dummy", "dummy", "dummy");
+ }).hasMessage("could not find policy with ID dummy and type dummy:dummy deployed in any pdp group");
}
@Test
public void testCreatePolicy() {
+ assertThatThrownBy(() -> {
+ policyProvider.createPolicy("dummy", "dummy", new ToscaServiceTemplate());
+ }).hasMessage("policy type with ID dummy:dummy does not exist");
+
+ assertThatCode(() -> {
+ String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+ ToscaServiceTemplate policyTypeServiceTemplate =
+ standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+ policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+ }).doesNotThrowAnyException();
+
+ assertThatThrownBy(() -> {
+ String badPolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_BAD_POLICYTYPE_ID);
+ ToscaServiceTemplate badPolicyServiceTemplate =
+ standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
+ policyProvider.createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
+ badPolicyServiceTemplate);
+ }).hasMessage("policy type id does not match");
+
+ assertThatThrownBy(() -> {
+ String badPolicyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE_WITH_BAD_POLICYTYPE_VERSION);
+ ToscaServiceTemplate badPolicyServiceTemplate =
+ standardCoder.decode(badPolicyString, ToscaServiceTemplate.class);
+ policyProvider.createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
+ badPolicyServiceTemplate);
+ }).hasMessage("policy type version does not match");
+
+ assertThatCode(() -> {
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ ToscaServiceTemplate policyServiceTemplate =
+ standardCoder.decode(policyString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = policyProvider
+ .createPolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+ assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
+ }).doesNotThrowAnyException();
}
@Test
public void testDeletePolicy() {
+ assertThatThrownBy(() -> {
+ policyProvider.deletePolicy("dummy", "dummy", "dummy", "dummy");
+ }).hasMessage("policy with ID dummy:dummy and type dummy:dummy does not exist");
+
+ assertThatCode(() -> {
+ ToscaServiceTemplate serviceTemplate = policyProvider.deletePolicy(
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", "1.0.0");
+ assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
+ }).doesNotThrowAnyException();
+
+ String exceptionMessage = "policy with ID onap.restart.tca:1.0.0 and type "
+ + "onap.policies.monitoring.cdap.tca.hi.lo.app:1.0.0 does not exist";
+ assertThatThrownBy(() -> {
+ policyProvider.deletePolicy("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0",
+ "onap.restart.tca", "1.0.0");
+ }).hasMessage(exceptionMessage);
}
}
diff --git a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
index 4c3f23b3..76825b20 100644
--- a/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
+++ b/main/src/test/java/org/onap/policy/api/main/rest/provider/TestPolicyTypeProvider.java
@@ -22,20 +22,21 @@
package org.onap.policy.api.main.rest.provider;
+import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.Assert.assertFalse;
import java.util.Base64;
-import org.junit.Before;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.api.main.parameters.ApiParameterGroup;
import org.onap.policy.common.parameters.ParameterService;
+import org.onap.policy.common.utils.coder.StandardCoder;
+import org.onap.policy.common.utils.resources.ResourceUtils;
import org.onap.policy.models.base.PfModelException;
import org.onap.policy.models.provider.PolicyModelsProviderParameters;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.policy.models.tosca.authorative.concepts.ToscaServiceTemplate;
/**
* This class performs unit test of {@link PolicyTypeProvider}
@@ -44,43 +45,116 @@ import org.slf4j.LoggerFactory;
*/
public class TestPolicyTypeProvider {
- private static final Logger LOGGER = LoggerFactory.getLogger(TestPolicyTypeProvider.class);
+ private static PolicyTypeProvider policyTypeProvider;
+ private static PolicyProvider policyProvider;
+ private static PolicyModelsProviderParameters providerParams;
+ private static ApiParameterGroup apiParamGroup;
+ private static StandardCoder standardCoder;
- private PolicyTypeProvider policyTypeProvider;
+ private static final String POLICY_RESOURCE = "policies/vCPE.policy.monitoring.input.tosca.json";
+ private static final String POLICY_TYPE_RESOURCE = "policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json";
/**
- * Initialize parameters.
+ * Initializes parameters.
+ *
+ * @throws PfModelException the PfModel parsing exception
*/
- @Before
- public void setupParameters() throws PfModelException {
-
- PolicyModelsProviderParameters parameters = new PolicyModelsProviderParameters();
- parameters.setDatabaseUrl("jdbc:h2:mem:testdb");
- parameters.setDatabaseUser("policy");
- parameters.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
- parameters.setPersistenceUnit("ToscaConceptTest");
- ApiParameterGroup paramGroup = new ApiParameterGroup("ApiGroup", null, parameters);
- ParameterService.register(paramGroup, true);
+ @BeforeClass
+ public static void setupParameters() throws PfModelException {
+
+ standardCoder = new StandardCoder();
+ providerParams = new PolicyModelsProviderParameters();
+ providerParams.setDatabaseUrl("jdbc:h2:mem:testdb");
+ providerParams.setDatabaseUser("policy");
+ providerParams.setDatabasePassword(Base64.getEncoder().encodeToString("P01icY".getBytes()));
+ providerParams.setPersistenceUnit("ToscaConceptTest");
+ apiParamGroup = new ApiParameterGroup("ApiGroup", null, providerParams);
+ ParameterService.register(apiParamGroup, true);
policyTypeProvider = new PolicyTypeProvider();
+ policyProvider = new PolicyProvider();
+ }
+
+ /**
+ * Closes up DB connections and deregisters API parameter group.
+ *
+ * @throws PfModelException the PfModel parsing exception
+ */
+ @AfterClass
+ public static void tearDown() throws PfModelException {
+
+ policyTypeProvider.close();
+ policyProvider.close();
+ ParameterService.deregister(apiParamGroup);
}
@Test
public void testFetchPolicyTypes() {
+ assertThatCode(() -> {
+ ToscaServiceTemplate serviceTemplate = policyTypeProvider.fetchPolicyTypes(null, null);
+ assertFalse(serviceTemplate.getPolicyTypes().isEmpty());
+ }).doesNotThrowAnyException();
+
+ assertThatThrownBy(() -> {
+ policyTypeProvider.fetchPolicyTypes("dummy", null);
+ }).hasMessage("policy type with ID dummy:null does not exist");
+
+ assertThatThrownBy(() -> {
+ policyTypeProvider.fetchPolicyTypes("dummy", "dummy");
+ }).hasMessage("policy type with ID dummy:dummy does not exist");
}
@Test
public void testFetchLatestPolicyTypes() {
+ assertThatThrownBy(() -> {
+ policyTypeProvider.fetchLatestPolicyTypes("dummy");
+ }).hasMessage("policy type with ID dummy:null does not exist");
}
@Test
public void testCreatePolicyType() {
+ assertThatCode(() -> {
+ String policyTypeString = ResourceUtils.getResourceAsString(POLICY_TYPE_RESOURCE);
+ ToscaServiceTemplate policyTypeServiceTemplate =
+ standardCoder.decode(policyTypeString, ToscaServiceTemplate.class);
+ ToscaServiceTemplate serviceTemplate = policyTypeProvider.createPolicyType(policyTypeServiceTemplate);
+ assertFalse(serviceTemplate.getPolicyTypes().get(0).isEmpty());
+ }).doesNotThrowAnyException();
}
@Test
public void testDeletePolicyType() {
+ assertThatCode(() -> {
+ String policyString = ResourceUtils.getResourceAsString(POLICY_RESOURCE);
+ ToscaServiceTemplate policyServiceTemplate =
+ standardCoder.decode(policyString, ToscaServiceTemplate.class);
+ policyProvider.createPolicy(
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", policyServiceTemplate);
+ }).doesNotThrowAnyException();
+
+ String exceptionMessage = "policy type with ID onap.policies.monitoring.cdap.tca.hi.lo.app:1.0.0 "
+ + "cannot be deleted as it is parameterized by policies onap.restart.tca:1.0.0";
+ assertThatThrownBy(() -> {
+ policyTypeProvider.deletePolicyType("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0");
+ }).hasMessage(exceptionMessage);
+
+ assertThatCode(() -> {
+ ToscaServiceTemplate serviceTemplate = policyProvider.deletePolicy(
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0", "onap.restart.tca", "1.0.0");
+ assertFalse(serviceTemplate.getToscaTopologyTemplate().getPolicies().get(0).isEmpty());
+ }).doesNotThrowAnyException();
+
+ assertThatCode(() -> {
+ ToscaServiceTemplate serviceTemplate = policyTypeProvider.deletePolicyType(
+ "onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0");
+ assertFalse(serviceTemplate.getPolicyTypes().get(0).isEmpty());
+ }).doesNotThrowAnyException();
+
+ assertThatThrownBy(() -> {
+ policyTypeProvider.deletePolicyType("onap.policies.monitoring.cdap.tca.hi.lo.app", "1.0.0");
+ }).hasMessage("policy type with ID onap.policies.monitoring.cdap.tca.hi.lo.app:1.0.0 does not exist");
}
}
diff --git a/main/src/test/resources/policies/vCPE.policy.bad.policytypeid.json b/main/src/test/resources/policies/vCPE.policy.bad.policytypeid.json
new file mode 100644
index 00000000..4eb84aa5
--- /dev/null
+++ b/main/src/test/resources/policies/vCPE.policy.bad.policytypeid.json
@@ -0,0 +1,50 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "topology_template": {
+ "policies": [
+ {
+ "onap.restart.tca": {
+ "type": "onap.policies.monitoring.cdap.tca.hi.lo.appxxx",
+ "version": "1.0.0",
+ "metadata": {
+ "policy-id": "onap.restart.tca"
+ },
+ "properties": {
+ "tca_policy" : {
+ "domain": "measurementsForVfScaling",
+ "metricsPerEventName": [
+ {
+ "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.measurementsForVfScalingFields.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.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "GREATER",
+ "severity": "CRITICAL",
+ "closedLoopEventStatus": "ONSET"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/main/src/test/resources/policies/vCPE.policy.bad.policytypeversion.json b/main/src/test/resources/policies/vCPE.policy.bad.policytypeversion.json
new file mode 100644
index 00000000..638a4e1d
--- /dev/null
+++ b/main/src/test/resources/policies/vCPE.policy.bad.policytypeversion.json
@@ -0,0 +1,51 @@
+{
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "topology_template": {
+ "policies": [
+ {
+ "onap.restart.tca": {
+ "type": "onap.policies.monitoring.cdap.tca.hi.lo.app",
+ "version": "1.0.0",
+ "typeVersion": "2.0.0",
+ "metadata": {
+ "policy-id": "onap.restart.tca"
+ },
+ "properties": {
+ "tca_policy" : {
+ "domain": "measurementsForVfScaling",
+ "metricsPerEventName": [
+ {
+ "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.measurementsForVfScalingFields.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.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value",
+ "thresholdValue": 0,
+ "direction": "GREATER",
+ "severity": "CRITICAL",
+ "closedLoopEventStatus": "ONSET"
+ }
+ ]
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ }
+} \ No newline at end of file
diff --git a/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json
index 292c632c..1d1a4d64 100644
--- a/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json
+++ b/main/src/test/resources/policytypes/onap.policy.monitoring.cdap.tca.hi.lo.app.json
@@ -1,223 +1,223 @@
{
- "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
- "policy_types": [
- {
- "onap.policies.Monitoring": {
- "derived_from": "tosca.policies.Root",
- "description": "a base policy type for all policies that governs monitoring provisioning"
- }
- },
- {
- "onap.policies.monitoring.cdap.tca.hi.lo.app": {
- "derived_from": "onap.policies.Monitoring",
- "version": "1.0.0",
- "properties": {
- "tca_policy": {
- "type": "map",
- "description": "TCA Policy JSON",
- "entry_schema": {
- "type": "onap.datatypes.monitoring.tca_policy"
+ "tosca_definitions_version": "tosca_simple_yaml_1_0_0",
+ "policy_types": [
+ {
+ "onap.policies.Monitoring": {
+ "derived_from": "tosca.policies.Root",
+ "description": "a base policy type for all policies that governs monitoring provisioning"
}
- }
- }
- }
- }
- ],
- "data_types": [
- {
- "onap.datatypes.monitoring.metricsPerEventName": {
- "derived_from": "tosca.datatypes.Root",
- "properties": {
- "controlLoopSchemaType": {
- "type": "string",
- "required": true,
- "description": "Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
- "constraints": [
- {
- "valid_values": [
- "VM",
- "VNF"
- ]
- }
- ]
- },
- "eventName": {
- "type": "string",
- "required": true,
- "description": "Event name to which thresholds need to be applied"
- },
- "policyName": {
- "type": "string",
- "required": true,
- "description": "TCA Policy Scope Name"
- },
- "policyScope": {
- "type": "string",
- "required": true,
- "description": "TCA Policy Scope"
- },
- "policyVersion": {
- "type": "string",
- "required": true,
- "description": "TCA Policy Scope Version"
- },
- "thresholds": {
- "type": "list",
- "required": true,
- "description": "Thresholds associated with eventName",
- "entry_schema": {
- "type": "onap.datatypes.monitoring.thresholds"
+ },
+ {
+ "onap.policies.monitoring.cdap.tca.hi.lo.app": {
+ "derived_from": "onap.policies.Monitoring",
+ "version": "1.0.0",
+ "properties": {
+ "tca_policy": {
+ "type": "map",
+ "description": "TCA Policy JSON",
+ "entry_schema": {
+ "type": "onap.datatypes.monitoring.tca_policy"
+ }
+ }
+ }
}
- }
}
- }
- },
- {
- "onap.datatypes.monitoring.tca_policy": {
- "derived_from": "tosca.datatypes.Root",
- "properties": {
- "domain": {
- "type": "string",
- "required": true,
- "description": "Domain name to which TCA needs to be applied",
- "default": "measurementsForVfScaling",
- "constraints": [
- {
- "equal": "measurementsForVfScaling"
- }
- ]
- },
- "metricsPerEventName": {
- "type": "list",
- "required": true,
- "description": "Contains eventName and threshold details that need to be applied to given eventName",
- "entry_schema": {
- "type": "onap.datatypes.monitoring.metricsPerEventName"
+ ],
+ "data_types": [
+ {
+ "onap.datatypes.monitoring.metricsPerEventName": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "controlLoopSchemaType": {
+ "type": "string",
+ "required": true,
+ "description": "Specifies Control Loop Schema Type for the event Name e.g. VNF, VM",
+ "constraints": [
+ {
+ "valid_values": [
+ "VM",
+ "VNF"
+ ]
+ }
+ ]
+ },
+ "eventName": {
+ "type": "string",
+ "required": true,
+ "description": "Event name to which thresholds need to be applied"
+ },
+ "policyName": {
+ "type": "string",
+ "required": true,
+ "description": "TCA Policy Scope Name"
+ },
+ "policyScope": {
+ "type": "string",
+ "required": true,
+ "description": "TCA Policy Scope"
+ },
+ "policyVersion": {
+ "type": "string",
+ "required": true,
+ "description": "TCA Policy Scope Version"
+ },
+ "thresholds": {
+ "type": "list",
+ "required": true,
+ "description": "Thresholds associated with eventName",
+ "entry_schema": {
+ "type": "onap.datatypes.monitoring.thresholds"
+ }
+ }
+ }
+ }
+ },
+ {
+ "onap.datatypes.monitoring.tca_policy": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "domain": {
+ "type": "string",
+ "required": true,
+ "description": "Domain name to which TCA needs to be applied",
+ "default": "measurementsForVfScaling",
+ "constraints": [
+ {
+ "equal": "measurementsForVfScaling"
+ }
+ ]
+ },
+ "metricsPerEventName": {
+ "type": "list",
+ "required": true,
+ "description": "Contains eventName and threshold details that need to be applied to given eventName",
+ "entry_schema": {
+ "type": "onap.datatypes.monitoring.metricsPerEventName"
+ }
+ }
+ }
+ }
+ },
+ {
+ "onap.datatypes.monitoring.thresholds": {
+ "derived_from": "tosca.datatypes.Root",
+ "properties": {
+ "closedLoopControlName": {
+ "type": "string",
+ "required": true,
+ "description": "Closed Loop Control Name associated with the threshold"
+ },
+ "closedLoopEventStatus": {
+ "type": "string",
+ "required": true,
+ "description": "Closed Loop Event Status of the threshold",
+ "constraints": [
+ {
+ "valid_values": [
+ "ONSET",
+ "ABATED"
+ ]
+ }
+ ]
+ },
+ "direction": {
+ "type": "string",
+ "required": true,
+ "description": "Direction of the threshold",
+ "constraints": [
+ {
+ "valid_values": [
+ "LESS",
+ "LESS_OR_EQUAL",
+ "GREATER",
+ "GREATER_OR_EQUAL",
+ "EQUAL"
+ ]
+ }
+ ]
+ },
+ "fieldPath": {
+ "type": "string",
+ "required": true,
+ "description": "Json field Path as per CEF message which needs to be analyzed for TCA",
+ "constraints": [
+ {
+ "valid_values": [
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsDelta",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsAccumulated",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuIdle",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageInterrupt",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageNice",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSoftIrq",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSteal",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSystem",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuWait",
+ "$.event.measurementsForVfScalingFields.cpuUsageArray[*].percentUsage",
+ "$.event.measurementsForVfScalingFields.meanRequestLatency",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryBuffered",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryCached",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryConfigured",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryFree",
+ "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryUsed",
+ "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value"
+ ]
+ }
+ ]
+ },
+ "severity": {
+ "type": "string",
+ "required": true,
+ "description": "Threshold Event Severity",
+ "constraints": [
+ {
+ "valid_values": [
+ "CRITICAL",
+ "MAJOR",
+ "MINOR",
+ "WARNING",
+ "NORMAL"
+ ]
+ }
+ ]
+ },
+ "thresholdValue": {
+ "type": "integer",
+ "required": true,
+ "description": "Threshold value for the field Path inside CEF message"
+ },
+ "version": {
+ "type": "string",
+ "required": true,
+ "description": "Version number associated with the threshold"
+ }
+ }
}
- }
- }
- }
- },
- {
- "onap.datatypes.monitoring.thresholds": {
- "derived_from": "tosca.datatypes.Root",
- "properties": {
- "closedLoopControlName": {
- "type": "string",
- "required": true,
- "description": "Closed Loop Control Name associated with the threshold"
- },
- "closedLoopEventStatus": {
- "type": "string",
- "required": true,
- "description": "Closed Loop Event Status of the threshold",
- "constraints": [
- {
- "valid_values": [
- "ONSET",
- "ABATED"
- ]
- }
- ]
- },
- "direction": {
- "type": "string",
- "required": true,
- "description": "Direction of the threshold",
- "constraints": [
- {
- "valid_values": [
- "LESS",
- "LESS_OR_EQUAL",
- "GREATER",
- "GREATER_OR_EQUAL",
- "EQUAL"
- ]
- }
- ]
- },
- "fieldPath": {
- "type": "string",
- "required": true,
- "description": "Json field Path as per CEF message which needs to be analyzed for TCA",
- "constraints": [
- {
- "valid_values": [
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedTotalPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedOctetsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedUnicastPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedMulticastPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedBroadcastPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedDiscardedPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].receivedErrorPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsDelta",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedTotalPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedOctetsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedUnicastPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedMulticastPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedBroadcastPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedDiscardedPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.vNicPerformanceArray[*].transmittedErrorPacketsAccumulated",
- "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuIdle",
- "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageInterrupt",
- "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageNice",
- "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSoftIrq",
- "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSteal",
- "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuUsageSystem",
- "$.event.measurementsForVfScalingFields.cpuUsageArray[*].cpuWait",
- "$.event.measurementsForVfScalingFields.cpuUsageArray[*].percentUsage",
- "$.event.measurementsForVfScalingFields.meanRequestLatency",
- "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryBuffered",
- "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryCached",
- "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryConfigured",
- "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryFree",
- "$.event.measurementsForVfScalingFields.memoryUsageArray[*].memoryUsed",
- "$.event.measurementsForVfScalingFields.additionalMeasurements[*].arrayOfFields[0].value"
- ]
- }
- ]
- },
- "severity": {
- "type": "string",
- "required": true,
- "description": "Threshold Event Severity",
- "constraints": [
- {
- "valid_values": [
- "CRITICAL",
- "MAJOR",
- "MINOR",
- "WARNING",
- "NORMAL"
- ]
- }
- ]
- },
- "thresholdValue": {
- "type": "integer",
- "required": true,
- "description": "Threshold value for the field Path inside CEF message"
- },
- "version": {
- "type": "string",
- "required": true,
- "description": "Version number associated with the threshold"
- }
}
- }
- }
- ]
+ ]
} \ No newline at end of file