1 package org.apache.helix.integration;
2
3 /*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
11 *
12 * http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21
22 import java.util.Date;
23
24 import org.apache.helix.TestHelper;
25 import org.apache.helix.controller.HelixControllerMain;
26 import org.apache.helix.mock.participant.MockParticipant;
27 import org.apache.helix.tools.ClusterStateVerifier;
28 import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier;
29 import org.testng.Assert;
30 import org.testng.annotations.Test;
31
32
33 public class TestSchemataSM extends ZkIntegrationTestBase
34 {
35 @Test
36 public void testSchemataSM() throws Exception
37 {
38 String testName = "TestSchemataSM";
39 String clusterName = testName;
40
41 MockParticipant[] participants = new MockParticipant[5];
42 // Logger.getRootLogger().setLevel(Level.INFO);
43
44 System.out.println("START " + testName + " at " + new Date(System.currentTimeMillis()));
45
46 TestHelper.setupCluster(clusterName, ZK_ADDR, 12918, // participant start
47 // port
48 "localhost", // participant name prefix
49 "TestSchemata", // resource name prefix
50 1, // resources
51 10, // partitions per resource
52 5, // number of nodes
53 5, // replicas
54 "STORAGE_DEFAULT_SM_SCHEMATA",
55 true); // do rebalance
56
57 TestHelper.startController(clusterName,
58 "controller_0",
59 ZK_ADDR,
60 HelixControllerMain.STANDALONE);
61 // start participants
62 for (int i = 0; i < 5; i++)
63 {
64 String instanceName = "localhost_" + (12918 + i);
65
66 participants[i] =
67 new MockParticipant(clusterName,
68 instanceName,
69 ZK_ADDR,
70 null);
71 participants[i].syncStart();
72 }
73
74 boolean result =
75 ClusterStateVerifier.verifyByZkCallback(new BestPossAndExtViewZkVerifier(ZK_ADDR,
76 clusterName));
77 Assert.assertTrue(result);
78 for (int i = 0; i < 5; i++)
79 {
80 participants[i].syncStop();
81 }
82
83 System.out.println("END " + testName + " at " + new Date(System.currentTimeMillis()));
84 }
85 }