1 /*******************************************************************************
2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk feature sdnr wt
4 * ================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
19 * ============LICENSE_END=========================================================
20 ******************************************************************************/
21 package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
23 import static org.junit.Assert.fail;
25 import org.junit.Test;
26 import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AaiConfig;
27 import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.impl.AkkaConfig;
28 import org.onap.ccsdk.features.sdnr.wt.devicemanager.config.util.ClusterNodeInfo;
30 public class TestAkkaConfig {
32 private static String getAkkaConfigSingleNodeText() {
33 return "\n" + "odl-cluster-data {\n" + " akka {\n" + " remote {\n" + " artery {\n"
34 + " enabled = off\n" + " canonical.hostname = \"127.0.0.1\"\n"
35 + " canonical.port = 2550\n" + " }\n" + " netty.tcp {\n"
36 + " hostname = \"127.0.0.1\"\n" + " port = 2550\n" + " }\n"
37 + " # when under load we might trip a false positive on the failure detector\n"
38 + " # transport-failure-detector {\n" + " # heartbeat-interval = 4 s\n"
39 + " # acceptable-heartbeat-pause = 16s\n" + " # }\n" + " }\n" + "\n" + " cluster {\n"
40 + " # Remove \".tcp\" when using artery.\n"
41 + " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@127.0.0.1:2550\"]\n" + "\n"
42 + " roles = [\n" + " \"member-1\"\n" + " ]\n" + "\n" + " }\n" + "\n"
44 + " # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by\n"
45 + " # modifying the following two properties. The directory location specified may be a relative or absolute path. \n"
46 + " # The relative path is always relative to KARAF_HOME.\n" + "\n"
47 + " # snapshot-store.local.dir = \"target/snapshots\"\n"
48 + " # journal.leveldb.dir = \"target/journal\"\n" + "\n" + " journal {\n"
49 + " leveldb {\n" + " # Set native = off to use a Java-only implementation of leveldb.\n"
50 + " # Note that the Java-only version is not currently considered by Akka to be production quality.\n"
51 + "\n" + " # native = off\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}";
54 private static String getAkkaConfigClusterNodeText() {
55 return "\n" + "odl-cluster-data {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n"
56 + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n"
57 + " port = 2550\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n"
58 + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n"
59 + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n"
60 + " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2550\"]\n"
61 + " seed-node-timeout = 15s\n" + " roles = [\"member-1\"]\n" + "\n" + " }\n"
62 + " persistence {\n" + " journal-plugin-fallback {\n" + " circuit-breaker {\n"
63 + " max-failures = 10\n" + " call-timeout = 60s\n"
64 + " reset-timeout = 30s\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}\n" + "\n"
65 + "odl-cluster-rpc {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n"
66 + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n"
67 + " port = 2551\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n"
68 + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n"
69 + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n"
70 + " seed-nodes = [\"akka.tcp://odl-cluster-rpc@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2551\"]\n"
71 + " seed-node-timeout = 15s\n" + " }\n" + " persistence {\n"
72 + " journal-plugin-fallback {\n" + " circuit-breaker {\n" + " max-failures = 10\n"
73 + " call-timeout = 60s\n" + " reset-timeout = 30s\n" + " }\n" + " }\n"
74 + " }\n" + " }\n" + "}\n" + "\n" + "";
81 System.out.println("testing clusternode config1");
82 System.out.println("===========================");
83 cfg = AkkaConfig.parse(getAkkaConfigClusterNodeText());
84 System.out.println("succeeded: ");
85 System.out.println(cfg.toString());
86 System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size()));
87 for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) {
88 System.out.println(n.toString());
90 } catch (Exception e) {
91 String failMessage = "failed: " + e.getMessage();
92 System.out.println(failMessage);
101 System.out.println("testing singlenode config1");
102 System.out.println("===========================");
103 cfg = AkkaConfig.parse(getAkkaConfigSingleNodeText());
104 System.out.println("succeeded: ");
105 System.out.println(cfg.toString());
106 } catch (Exception e) {
107 String failMessage = "failed: " + e.getMessage();
108 System.out.println(failMessage);
114 public void test3() {
117 ClassLoader classLoader = getClass().getClassLoader();
118 File file = new File(classLoader.getResource("captured-akka.conf").getFile());
119 System.out.println(file.getAbsolutePath());
122 System.out.println("testing clusternode config1");
123 System.out.println("===========================");
124 cfg = AkkaConfig.load(file.getAbsolutePath());
125 System.out.println("succeeded: "+cfg.hashCode());
126 System.out.println(cfg.toString());
127 System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size()));
128 for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) {
129 System.out.println(n.toString());
131 } catch (Exception e) {
132 String failMessage = "failed: " + e.getMessage();
133 System.out.println(failMessage);
139 public void test4() {
140 AaiConfig cfg = AaiConfig.getDefaultConfiguration();