View Javadoc

1   package org.apache.helix;
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  
23  import org.apache.helix.healthcheck.DefaultPerfCounters;
24  import org.testng.AssertJUnit;
25  import org.testng.annotations.BeforeTest;
26  import org.testng.annotations.Test;
27  
28  
29  public class TestPerfCounters {
30  
31  	final String INSTANCE_NAME = "instance_123";
32      final long AVAILABLE_CPUS = 1;
33      final long FREE_PHYSICAL_MEMORY = 2;
34      final long FREE_JVM_MEMORY = 3;
35      final long TOTAL_JVM_MEMORY = 4;
36      final double AVERAGE_SYSTEM_LOAD = 5;
37  
38  	DefaultPerfCounters _perfCounters;
39  
40  	@BeforeTest ()
41  	public void setup()
42  	{
43  		_perfCounters = new DefaultPerfCounters(INSTANCE_NAME, AVAILABLE_CPUS,
44  				FREE_PHYSICAL_MEMORY, FREE_JVM_MEMORY, TOTAL_JVM_MEMORY,
45  				AVERAGE_SYSTEM_LOAD);
46  	}
47  
48  	 @Test ()
49  	 public void testGetAvailableCpus()
50  	 {
51  		 AssertJUnit.assertEquals(AVAILABLE_CPUS,_perfCounters.getAvailableCpus());
52  	 }
53  
54  	 @Test ()
55  	 public void testGetAverageSystemLoad()
56  	 {
57  		 AssertJUnit.assertEquals(AVERAGE_SYSTEM_LOAD,_perfCounters.getAverageSystemLoad());
58  	 }
59  
60  	 @Test ()
61  	 public void testGetTotalJvmMemory()
62  	 {
63  		 AssertJUnit.assertEquals(TOTAL_JVM_MEMORY,_perfCounters.getTotalJvmMemory());
64  	 }
65  
66  	 @Test ()
67  	 public void testGetFreeJvmMemory()
68  	 {
69  		 AssertJUnit.assertEquals(FREE_JVM_MEMORY,_perfCounters.getFreeJvmMemory());
70  	 }
71  
72  	 @Test ()
73  	 public void testGetFreePhysicalMemory()
74  	 {
75  		 AssertJUnit.assertEquals(FREE_PHYSICAL_MEMORY,_perfCounters.getFreePhysicalMemory());
76  	 }
77  }