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=========================================================
21 package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
23 import static org.junit.Assert.fail;
26 import org.junit.Test;
27 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka.AkkaConfig;
28 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka.ClusterConfig;
29 import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka.ClusterNodeInfo;
31 public class TestAkkaConfig {
33 private static String getAkkaConfigSingleNodeText() {
34 return "\n" + "odl-cluster-data {\n" + " akka {\n" + " remote {\n" + " artery {\n"
35 + " enabled = off\n" + " canonical.hostname = \"127.0.0.1\"\n"
36 + " canonical.port = 2550\n" + " }\n" + " netty.tcp {\n"
37 + " hostname = \"127.0.0.1\"\n" + " port = 2550\n" + " }\n"
38 + " # when under load we might trip a false positive on the failure detector\n"
39 + " # transport-failure-detector {\n" + " # heartbeat-interval = 4 s\n"
40 + " # acceptable-heartbeat-pause = 16s\n" + " # }\n" + " }\n" + "\n" + " cluster {\n"
41 + " # Remove \".tcp\" when using artery.\n"
42 + " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@127.0.0.1:2550\"]\n" + "\n"
43 + " roles = [\n" + " \"member-1\"\n" + " ]\n" + "\n" + " }\n" + "\n"
45 + " # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by\n"
46 + " # modifying the following two properties. The directory location specified may be a relative or absolute path. \n"
47 + " # The relative path is always relative to KARAF_HOME.\n" + "\n"
48 + " # snapshot-store.local.dir = \"target/snapshots\"\n"
49 + " # journal.leveldb.dir = \"target/journal\"\n" + "\n" + " journal {\n"
50 + " leveldb {\n" + " # Set native = off to use a Java-only implementation of leveldb.\n"
51 + " # Note that the Java-only version is not currently considered by Akka to be production quality.\n"
52 + "\n" + " # native = off\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}";
55 private static String getAkkaConfigClusterNodeText() {
56 return "\n" + "odl-cluster-data {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n"
57 + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n"
58 + " port = 2550\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n"
59 + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n"
60 + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n"
61 + " 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"
62 + " seed-node-timeout = 15s\n" + " roles = [\"member-1\"]\n" + "\n" + " }\n"
63 + " persistence {\n" + " journal-plugin-fallback {\n" + " circuit-breaker {\n"
64 + " max-failures = 10\n" + " call-timeout = 60s\n"
65 + " reset-timeout = 30s\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}\n" + "\n"
66 + "odl-cluster-rpc {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n"
67 + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n"
68 + " port = 2551\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n"
69 + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n"
70 + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n"
71 + " 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"
72 + " seed-node-timeout = 15s\n" + " }\n" + " persistence {\n"
73 + " journal-plugin-fallback {\n" + " circuit-breaker {\n" + " max-failures = 10\n"
74 + " call-timeout = 60s\n" + " reset-timeout = 30s\n" + " }\n" + " }\n"
75 + " }\n" + " }\n" + "}\n" + "\n" + "";
82 System.out.println("testing clusternode config1");
83 System.out.println("===========================");
84 cfg = AkkaConfig.parse(getAkkaConfigClusterNodeText());
85 System.out.println("succeeded: ");
86 System.out.println(cfg.toString());
87 System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size()));
88 for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) {
89 System.out.println(n.toString());
91 } catch (Exception e) {
92 String failMessage = "failed: " + e.getMessage();
93 System.out.println(failMessage);
102 System.out.println("testing singlenode config1");
103 System.out.println("===========================");
104 cfg = AkkaConfig.parse(getAkkaConfigSingleNodeText());
105 System.out.println("succeeded: ");
106 System.out.println(cfg.toString());
107 } catch (Exception e) {
108 String failMessage = "failed: " + e.getMessage();
109 System.out.println(failMessage);
115 public void test3() {
118 ClassLoader classLoader = getClass().getClassLoader();
119 File file = new File(classLoader.getResource("captured-akka.conf").getFile());
120 System.out.println(file.getAbsolutePath());
123 System.out.println("testing clusternode config1");
124 System.out.println("===========================");
125 cfg = AkkaConfig.load(file.getAbsolutePath());
126 System.out.println("succeeded: " + cfg.hashCode());
127 System.out.println(cfg.toString());
128 System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size()));
129 for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) {
130 System.out.println(n.toString());
132 } catch (Exception e) {
133 String failMessage = "failed: " + e.getMessage();
134 System.out.println(failMessage);
140 public void test4() {
141 ClusterConfig cc = ClusterConfig.defaultSingleNodeConfig();
142 cc.getClusterSeedNodeName();
143 cc.getRoleMemberIndex();