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;
34
import com.sun.grid.jgdi.configuration.ClusterQueue;
36
import java.util.logging.Level;
37
import java.util.logging.Logger;
38
import junit.framework.Test;
39
import junit.framework.TestSuite;
44
public class ClusterQueueJobSlotTestCase extends BaseTestCase {
46
private ClusterQueue testClusterQueue;
49
* Creates a new instance of ClusterQueueJobSlotTestCase
51
public ClusterQueueJobSlotTestCase(String name) {
55
public static Test suite() {
56
TestSuite suite = new TestSuite( ClusterQueueJobSlotTestCase.class);
60
public void testUpdateJobSlots() throws Exception {
62
JGDI jgdi = super.createJGDI();
65
ClusterQueue testObj = jgdi.getClusterQueue("all.q");
67
testObj.setName("new.q");
69
jgdi.addClusterQueue(testObj);
71
ClusterQueue retObj = jgdi.getClusterQueue(testObj.getName());
73
String host = TestValueFactory.getNextHostname();
74
retObj.putJobSlots(host, 10);
76
jgdi.updateClusterQueue(retObj);
78
ClusterQueue updatedObj = jgdi.getClusterQueue(testObj.getName());
80
// TODO: problem with short/long hostnames as keys -> failure of test even for correct result
81
// workaround is correct hostname in Testvalues*.properties
82
// System.out.println("retObj.getJobSlots(host) " + retObj.getJobSlots(host) + "(" + host + ")");
83
// System.out.println("updateObj.getJobSlots(host) " + updatedObj.getJobSlots(host) + "(" + host + ")");
84
// System.out.println("updateObj.getJobSlotsKeys() " + updatedObj.getJobSlotsKeys());
85
assertEquals(retObj.getJobSlots(host), updatedObj.getJobSlots(host));
87
retObj.removeJobSlots(host);
88
Logger logger = Logger.getLogger("com.sun.grid.jgdi");
89
Level orgLevel = logger.getLevel();
90
logger.setLevel(Level.FINE);
91
jgdi.updateClusterQueue(retObj);
93
updatedObj = jgdi.getClusterQueue(testObj.getName());
94
logger.setLevel(orgLevel);
96
Set hostnames = updatedObj.getJobSlotsKeys();
97
assertFalse(hostnames.contains(host));
100
jgdi.deleteClusterQueue(testObj);
110
// public void testWriteXML() throws Exception {
111
// String[] clusterNames = getClusterNames();
113
// for (int i=0; i<clusterNames.length;i++) {
114
// JGDI gdi = createJGDI();
116
// for (ClusterQueue cq : gdi.getClusterQueueList()) {
117
// logger.fine("ClusterQueue " + cq.getName() + "----------");
118
// File file = File.createTempFile("cq_" + cq.getName(), ".xml" );
119
// XMLUtil.write(cq, file);
120
// logger.fine("cq " + cq.getName() + " -> " + file.getAbsolutePath());
121
// ClusterQueue cq1 = (ClusterQueue)XMLUtil.read(file);
122
// assertTrue("cq1 is not equals to cq2", cq.equalsCompletely(cq1));
131
// public void testAdd() throws Exception {
133
// JGDI gdi = createJGDI();
135
// ClassDescriptor cd = Util.getDescriptor(testClusterQueue.getClass());
137
// cd.validate(testClusterQueue);
139
// gdi.addClusterQueue(testClusterQueue);
142
// gdi.deleteClusterQueue(testClusterQueue);
148
// public void testAddProject() throws Exception {
150
// JGDI gdi = createJGDI();
153
// Project p = new Project();
154
// p.setName("testName");
155
// gdi.addProject(p);
158
// ClusterQueue cq = gdi.getClusterQueue("all.q");
161
// cq.addProjects("@allhosts", p );
163
// List projectList = cq.getProjectsList("@allhosts");
165
// boolean found = false;
167
// for(int ii = 0; ii < projectList.size(); ii++) {
169
// Project tmpPrj = (Project)projectList.get(ii);
170
// logger.fine("project " + tmpPrj.getName());
171
// if(tmpPrj.getName().equals(p.getName())) {
177
// assertTrue("project " + p.getName() + " not found in cluster queue" + cq.getName(), found);
180
// gdi.deleteProject(p);