Improve segmented journal actor metrics
[controller.git] / opendaylight / md-sal / sal-distributed-datastore / src / test / java / org / opendaylight / controller / cluster / datastore / config / ConfigurationImplHybridTest.java
1 /*
2  * Copyright (c) 2019 PANTHEON.tech, s.r.o. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.controller.cluster.datastore.config;
9
10 import com.typesafe.config.Config;
11 import com.typesafe.config.ConfigFactory;
12 import java.util.List;
13 import org.junit.Test;
14
15 public class ConfigurationImplHybridTest extends ConfigurationImplBaseTest {
16
17     @Override
18     public ConfigurationImpl createConfiguration() {
19         Config moduleShardsConf = generateModuleShards(List.of(
20                 generateShard("default", "default", List.of("member-1", "member-2", "member-3")),
21                 generateShard("people", "people-1", List.of("member-1")),
22                 generateShard("cars", "cars-1", List.of("member-1")),
23                 generateShard("test", "test-1", List.of("member-1"))
24         ));
25         return new ConfigurationImpl(new HybridModuleShardConfigProvider(moduleShardsConf, "modules.conf"));
26     }
27
28     @Test(expected = NullPointerException.class)
29     public void testNullModuleShardsConf() {
30         new HybridModuleShardConfigProvider(null, "modules.conf");
31     }
32
33     private static Config generateModuleShards(final List<String> shards) {
34         String moduleShardsContent = String.format("module-shards = [%n%s]", String.join(",\n", shards));
35         return ConfigFactory.parseString(moduleShardsContent);
36     }
37
38     private static String generateShard(final String name, final String shardsName, final List<String> replicas) {
39         return "    {"
40                 + "        name = \"" + name + "\"\n"
41                 + "        shards = [\n"
42                 + "            {\n"
43                 + "                name=\"" + shardsName + "\"\n"
44                 + "                replicas = " + replicas
45                 + "                \n"
46                 + "            }\n"
47                 + "        ]\n"
48                 + "    }";
49     }
50 }