Remove references to MariaDB from resource files 30/126630/4
authorwaynedunican <wayne.dunican@est.tech>
Wed, 5 Jan 2022 14:56:44 +0000 (14:56 +0000)
committerWayne Dunican <wayne.dunican@est.tech>
Thu, 27 Jan 2022 07:41:05 +0000 (07:41 +0000)
Issue-ID: POLICY-2086
Change-Id: I891feb05d2e964ae8d4454d30672ffc77c1da555
Signed-off-by: Wayne Dunican <wayne.dunican@est.tech>
main/src/main/resources/META-INF/persistence.xml
main/src/main/resources/application.yaml
main/src/test/java/org/onap/policy/pap/main/parameters/CommonTestData.java
main/src/test/java/org/onap/policy/pap/main/parameters/TestPapParameterGroup.java
main/src/test/resources/META-INF/persistence.xml
main/src/test/resources/parameters/PapConfigParameters_Postgres.json [new file with mode: 0644]
packages/policy-pap-tarball/src/main/resources/etc/papParameters.yaml
testsuites/stability/src/main/resources/papsetup/config/pap/etc/defaultConfig.json

index 3e1d428..a9d6129 100644 (file)
@@ -3,7 +3,7 @@
   ============LICENSE_START=======================================================
    Copyright (C) 2019-2021 Nordix Foundation.
    Modifications Copyright (C) 2021 AT&T Intellectual Property.
-   Modification Copyright 2021. Nordix Foundation.
+   Modification Copyright 2022. Nordix Foundation.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@
 -->
 
 <persistence xmlns="http://java.sun.com/xml/ns/persistence" version="2.0">
-    <persistence-unit name="PolicyMariaDb" transaction-type="RESOURCE_LOCAL">
+    <persistence-unit name="PolicyDb" transaction-type="RESOURCE_LOCAL">
         <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 
         <class>org.onap.policy.models.base.PfConceptKey</class>
index f37cc76..0fb6730 100644 (file)
@@ -27,7 +27,7 @@ pap:
     databaseUrl: jdbc:mariadb://mariadb:3306/policyadmin
     databaseUser: policy_user
     databasePassword: policy_user
-    persistenceUnit: PolicyMariaDb
+    persistenceUnit: PolicyDb
   savePdpStatisticsInDb: true
   topicParameterGroup:
     topicSources:
index 34d7220..130f1ef 100644 (file)
@@ -3,6 +3,7 @@
  *  Copyright (C) 2019 Nordix Foundation.
  *  Modifications Copyright (C) 2019 AT&T Intellectual Property.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ *  Modification Copyright 2022. Nordix Foundation.
  * ================================================================================
  * 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 java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Files;
+import java.nio.file.Paths;
 import org.onap.policy.common.utils.coder.Coder;
 import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
@@ -85,6 +87,28 @@ public class CommonTestData {
         }
     }
 
+    /**
+     * Gets the postgres PAP parameters, as a String.
+     *
+     * @param port port to be inserted into the parameters
+     * @return the postgres PAP parameters
+     */
+    public String getPapPostgresParameterGroupAsString(int port) {
+
+        try {
+            String json = new String(Files.readAllBytes(Paths.get(
+                    "src/test/resources/parameters/PapConfigParameters_Postgres.json")));
+
+            json = json.replace("${port}", String.valueOf(port));
+            json = json.replace("${dbName}", "jdbc:h2:mem:testdb" + dbNum);
+
+            return json;
+
+        } catch (IOException e) {
+            throw new PolicyPapRuntimeException("cannot read PAP parameters", e);
+        }
+    }
+
     /**
      * Gets the full path to the parameter file, which may vary depending on whether or
      * not this is an end-to-end test.
index 926a1f4..d52e21f 100644 (file)
@@ -3,6 +3,7 @@
  *  Copyright (C) 2019 Nordix Foundation.
  *  Modifications Copyright (C) 2019, 2021 AT&T Intellectual Property.
  *  Modifications Copyright (C) 2021 Bell Canada. All rights reserved.
+ *  Modification Copyright 2022. Nordix Foundation.
  * ================================================================================
  * 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 @@ import org.junit.Test;
 import org.onap.policy.common.endpoints.parameters.TopicParameterGroup;
 import org.onap.policy.common.parameters.ValidationResult;
 import org.onap.policy.common.utils.coder.Coder;
+import org.onap.policy.common.utils.coder.CoderException;
 import org.onap.policy.common.utils.coder.StandardCoder;
 
 /**
@@ -52,12 +54,14 @@ public class TestPapParameterGroup {
     @Test
     public void testPapParameterGroup() {
         final PapParameterGroup papParameters = commonTestData.getPapParameterGroup(1);
-        final TopicParameterGroup topicParameterGroup = papParameters.getTopicParameterGroup();
-        final ValidationResult validationResult = papParameters.validate();
-        assertTrue(validationResult.isValid());
-        assertEquals(CommonTestData.PAP_GROUP_NAME, papParameters.getName());
-        assertEquals(topicParameterGroup.getTopicSinks(), papParameters.getTopicParameterGroup().getTopicSinks());
-        assertEquals(topicParameterGroup.getTopicSources(), papParameters.getTopicParameterGroup().getTopicSources());
+        validateParameters(papParameters);
+    }
+
+    @Test
+    public void testPapParameterGroup_Postgres() throws CoderException {
+        String json = commonTestData.getPapPostgresParameterGroupAsString(1);
+        final PapParameterGroup papPostgresParameters = coder.decode(json, PapParameterGroup.class);
+        validateParameters(papPostgresParameters);
     }
 
     @Test
@@ -89,4 +93,17 @@ public class TestPapParameterGroup {
         assertEquals("PapNewGroup", papParameters.getName());
     }
 
+    /**
+     * Validates the pap parameters.
+     *
+     * @param parameterGroup parameter group being tested
+     */
+    public void validateParameters(PapParameterGroup parameterGroup) {
+        final TopicParameterGroup topicParameterGroup = parameterGroup.getTopicParameterGroup();
+        final ValidationResult validationResult = parameterGroup.validate();
+        assertTrue(validationResult.isValid());
+        assertEquals(CommonTestData.PAP_GROUP_NAME, parameterGroup.getName());
+        assertEquals(topicParameterGroup.getTopicSinks(), parameterGroup.getTopicParameterGroup().getTopicSinks());
+        assertEquals(topicParameterGroup.getTopicSources(), parameterGroup.getTopicParameterGroup().getTopicSources());
+    }
 }
index 21a3a8b..845118d 100644 (file)
@@ -3,6 +3,7 @@
   ============LICENSE_START=======================================================
    Copyright (C) 2019-2021 Nordix Foundation.
    Modifications Copyright (C) 2021 AT&T Intellectual Property.
+   Modification Copyright 2022. Nordix Foundation.
   ================================================================================
   Licensed under the Apache License, Version 2.0 (the "License");
   you may not use this file except in compliance with the License.
@@ -65,7 +66,7 @@
         </properties>
     </persistence-unit>
 
-    <persistence-unit name="PolicyMariaDb" transaction-type="RESOURCE_LOCAL">
+    <persistence-unit name="PolicyDb" transaction-type="RESOURCE_LOCAL">
         <provider>org.eclipse.persistence.jpa.PersistenceProvider</provider>
 
         <class>org.onap.policy.models.dao.converters.CDataConditioner</class>
diff --git a/main/src/test/resources/parameters/PapConfigParameters_Postgres.json b/main/src/test/resources/parameters/PapConfigParameters_Postgres.json
new file mode 100644 (file)
index 0000000..46d25b1
--- /dev/null
@@ -0,0 +1,64 @@
+{
+    "name": "PapGroup",
+    "restServerParameters": {
+        "host": "0.0.0.0",
+        "port": 6969,
+        "userName": "healthcheck",
+        "password": "zb!XztG34",
+        "https": false
+    },
+    "pdpParameters": {
+        "heartBeatMs": 60000,
+        "updateParameters": {
+            "maxRetryCount": 1,
+            "maxWaitMs": 30000
+        },
+        "stateChangeParameters": {
+            "maxRetryCount": 1,
+            "maxWaitMs": 30000
+        }
+    },
+    "databaseProviderParameters": {
+        "name": "PolicyProviderParameterGroup",
+        "implementation": "org.onap.policy.models.provider.impl.DatabasePolicyModelsProviderImpl",
+        "databaseDriver": "org.postgresql.Driver",
+        "databaseUrl": "jdbc:postgresql://localhost:5432/policyadmin",
+        "databaseUser": "policy_user",
+        "databasePassword": "policy_user",
+        "persistenceUnit": "PolicyDb"
+    },
+    "topicParameterGroup": {
+        "topicSources" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "localhost:3904" ],
+            "topicCommInfrastructure" : "dmaap"
+        }],
+        "topicSinks" : [{
+            "topic" : "POLICY-PDP-PAP",
+            "servers" : [ "localhost:3904" ],
+            "topicCommInfrastructure" : "dmaap"
+        },{
+            "topic" : "POLICY-NOTIFICATION",
+            "servers" : [ "localhost:3904" ],
+            "topicCommInfrastructure" : "dmaap"
+        }]
+    },
+    "healthCheckRestClientParameters":[{
+        "clientName": "api",
+        "hostname": "policy-api",
+        "port": 6968,
+        "userName": "healthcheck",
+        "password": "zb!XztG34",
+        "useHttps": false,
+        "basePath": "policy/api/v1/healthcheck"
+    },
+    {
+        "clientName": "distribution",
+        "hostname": "policy-distribution",
+        "port": 6970,
+        "userName": "healthcheck",
+        "password": "zb!XztG34",
+        "useHttps": false,
+        "basePath": "healthcheck"
+    }]
+}
index 8a4cba0..f38e67b 100644 (file)
@@ -29,7 +29,7 @@ pap:
     databaseUrl: jdbc:mariadb://mariadb:3306/policyadmin
     databaseUser: policy_user
     databasePassword: policy_user
-    persistenceUnit: PolicyMariaDb
+    persistenceUnit: PolicyDb
   savePdpStatisticsInDb: false
   topicParameterGroup:
     topicSources:
index 2338f93..f7149b4 100644 (file)
@@ -26,7 +26,7 @@
         "databaseUrl": "jdbc:mariadb://mariadb:3306/policyadmin",
         "databaseUser": "policy_user",
         "databasePassword": "policy_user",
-        "persistenceUnit": "PolicyMariaDb"
+        "persistenceUnit": "PolicyDb"
     },
     "topicParameterGroup": {
         "topicSources" : [{