1
/*___INFO__MARK_BEGIN__*/
2
/*************************************************************************
4
* The Contents of this file are made available subject to the terms of
5
* the Sun Industry Standards Source License Version 1.2
7
* Sun Microsystems Inc., March, 2001
10
* Sun Industry Standards Source License Version 1.2
11
* =================================================
12
* The contents of this file are subject to the Sun Industry Standards
13
* Source License Version 1.2 (the "License"); You may not use this file
14
* except in compliance with the License. You may obtain a copy of the
15
* License at http://gridengine.sunsource.net/Gridengine_SISSL_license.html
17
* Software provided under this License is provided on an "AS IS" basis,
18
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
19
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
20
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
21
* See the License for the specific provisions governing your rights and
22
* obligations concerning the Software.
24
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
26
* Copyright: 2001 by Sun Microsystems, Inc.
28
* All Rights Reserved.
30
************************************************************************/
31
/*___INFO__MARK_END__*/
32
package com.sun.grid.jgdi.monitoring;
34
import com.sun.grid.jgdi.monitoring.filter.QueueStateFilter;
35
import com.sun.grid.jgdi.monitoring.filter.ResourceFilter;
36
import java.util.List;
37
import junit.framework.Test;
38
import junit.framework.TestSuite;
39
import com.sun.grid.jgdi.JGDI;
40
import com.sun.grid.jgdi.monitoring.filter.UserFilter;
41
import com.sun.grid.jgdi.configuration.ClusterQueue;
42
import com.sun.grid.jgdi.configuration.ConfigurationFactory;
43
import com.sun.grid.jgdi.configuration.UserSet;
49
public class TestClusterQueueSummary extends com.sun.grid.jgdi.BaseTestCase {
51
/** Creates a new instance of TestQHost */
52
public TestClusterQueueSummary(String testName) {
56
public static Test suite() {
57
TestSuite suite = new TestSuite(TestClusterQueueSummary.class);
61
private void printResult(List<ClusterQueueSummary> result) {
63
logger.fine("CLUSTER QUEUE CQLOAD USED AVAIL TOTAL");
64
StringBuilder buf = new StringBuilder();
65
for (ClusterQueueSummary cqs : result) {
67
buf.append(cqs.getName());
69
buf.append(cqs.isLoadSet() ? Double.toString(cqs.getLoad()) : "-NA-");
71
buf.append(cqs.getUsedSlots());
73
buf.append(cqs.getAvailableSlots());
75
buf.append(cqs.getTotalSlots());
76
logger.fine(buf.toString());
80
public void testSimple() throws Exception {
82
JGDI jgdi = createJGDI();
84
ClusterQueueSummaryOptions options = new ClusterQueueSummaryOptions();
85
List<ClusterQueueSummary> result = jgdi.getClusterQueueSummary(options);
92
public void testResourceFilter() throws Exception {
94
JGDI jgdi = createJGDI();
96
ClusterQueueSummaryOptions options = new ClusterQueueSummaryOptions();
97
ResourceFilter rsf = new ResourceFilter();
98
rsf.addResource("NoAccessUsers", "lx26-x86");
99
options.setResourceFilter(rsf);
100
List<ClusterQueueSummary> result = jgdi.getClusterQueueSummary(options);
107
public void testQueueStateFilter() throws Exception {
109
JGDI jgdi = createJGDI();
111
ClusterQueueSummaryOptions options = new ClusterQueueSummaryOptions();
112
QueueStateFilter qsf = new QueueStateFilter();
114
options.setQueueStateFilter(qsf);
115
logger.fine("queueStateFiter: " + qsf);
116
List<ClusterQueueSummary> result = jgdi.getClusterQueueSummary(options);
123
public void testQueueUserFilter() throws Exception {
125
JGDI jgdi = createJGDI();
127
ClusterQueueSummaryOptions options = new ClusterQueueSummaryOptions();
128
UserSet userSet = ConfigurationFactory.createUserSet();
129
userSet.setName("NoAccessUsers");
130
userSet.addEntries("noaccess");
131
jgdi.addUserSet(userSet);
133
ClusterQueue cq = ConfigurationFactory.createClusterQueueWithDefaults();
134
cq.setName("testQueueUserFilter");
135
UserFilter uf = new UserFilter();
136
uf.addUser("noaccess");
137
jgdi.addClusterQueue(cq);
140
options.setQueueUserFilter(uf);
141
logger.fine("testQueueUserFilter for queue " + cq.getName());
142
List<ClusterQueueSummary> result = jgdi.getClusterQueueSummary(options);
145
jgdi.deleteClusterQueue(cq);
148
jgdi.deleteUserSet(userSet);