cloudstack-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kelv...@apache.org
Subject git commit: updated refs/heads/vmsync to 2320b1c
Date Sat, 11 May 2013 01:11:31 GMT
Updated Branches:
  refs/heads/vmsync a681a7efe -> 2320b1c2c


Unit tests for job wakeup process


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/2320b1c2
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/2320b1c2
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/2320b1c2

Branch: refs/heads/vmsync
Commit: 2320b1c2c5b57b58f83474f7a79524be816d97ee
Parents: a681a7e
Author: Kelven Yang <kelveny@gmail.com>
Authored: Fri May 10 18:07:14 2013 -0700
Committer: Kelven Yang <kelveny@gmail.com>
Committed: Fri May 10 18:07:14 2013 -0700

----------------------------------------------------------------------
 .../vm/VmWorkMockVirtualMachineManagerImpl.java    |    5 +-
 server/test/com/cloud/vm/VmWorkTest.java           |   19 +++
 .../test/com/cloud/vm/VmWorkTestJobDispatcher.java |   61 +++++++++
 server/test/resources/VmWorkTestContext.xml        |    3 +
 settings.xml.old                                   |   98 +++++++++++++++
 5 files changed, 185 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2320b1c2/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java b/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java
index d77ebd1..3ccc526 100644
--- a/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java
+++ b/server/test/com/cloud/vm/VmWorkMockVirtualMachineManagerImpl.java
@@ -397,10 +397,13 @@ public class VmWorkMockVirtualMachineManagerImpl implements VirtualMachineManage
     	return vm;
     }
 	
+	public void processVmStartWakeup() {
+		System.out.println("processVmStartWakeup. job-" + AsyncJobExecutionContext.getCurrentExecutionContext().getJob().getId());
+	}
+	
 	@Override
     public <T extends VMInstanceVO> boolean processVmStopWork(T vm, boolean forced,
User user, Account account) 
         throws AgentUnavailableException, OperationTimedoutException, ConcurrentOperationException
{
     	return true;
     }
-        	
 }

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2320b1c2/server/test/com/cloud/vm/VmWorkTest.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/VmWorkTest.java b/server/test/com/cloud/vm/VmWorkTest.java
index 75ba612..cbc22ab 100644
--- a/server/test/com/cloud/vm/VmWorkTest.java
+++ b/server/test/com/cloud/vm/VmWorkTest.java
@@ -36,6 +36,7 @@ import junit.framework.TestCase;
 
 import com.cloud.api.ApiSerializerHelper;
 import com.cloud.async.AsyncJobManager;
+import com.cloud.async.AsyncJobVO;
 import com.cloud.cluster.ClusterManager;
 import com.cloud.deploy.DataCenterDeployment;
 import com.cloud.deploy.DeploymentPlan;
@@ -142,6 +143,24 @@ public class VmWorkTest extends TestCase {
 	}
 	
 	@Test
+	public void testVmWorkWakeup() {
+		AsyncJobVO mainJob = new AsyncJobVO();
+		
+		mainJob.setDispatcher("TestJobDispatcher");
+		mainJob.setAccountId(1L);
+		mainJob.setUserId(1L);
+		mainJob.setCmd("Dummy");
+		mainJob.setCmdInfo("Dummy");
+		
+		_jobMgr.submitAsyncJob(mainJob);
+		
+		try {
+			Thread.sleep(120000);
+		} catch (InterruptedException e) {
+		}
+	}
+	
+	@Test
 	public void testExceptionSerialization() {
 		InsufficientCapacityException exception = new InsufficientStorageCapacityException("foo",
VmWorkJobVO.class, 1L);
 		

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2320b1c2/server/test/com/cloud/vm/VmWorkTestJobDispatcher.java
----------------------------------------------------------------------
diff --git a/server/test/com/cloud/vm/VmWorkTestJobDispatcher.java b/server/test/com/cloud/vm/VmWorkTestJobDispatcher.java
new file mode 100644
index 0000000..552bed5
--- /dev/null
+++ b/server/test/com/cloud/vm/VmWorkTestJobDispatcher.java
@@ -0,0 +1,61 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+package com.cloud.vm;
+
+import javax.inject.Inject;
+
+import com.cloud.api.ApiSerializerHelper;
+import com.cloud.async.AsyncJob;
+import com.cloud.async.AsyncJobDispatcher;
+import com.cloud.async.AsyncJobManager;
+import com.cloud.utils.component.AdapterBase;
+
+public class VmWorkTestJobDispatcher extends AdapterBase implements AsyncJobDispatcher {
+
+	@Inject AsyncJobManager _jobMgr;
+	
+	@Override
+	public void runJob(AsyncJob job) {
+		VmWorkJobVO workJob = new VmWorkJobVO();
+    	
+		workJob.setDispatcher(VmWorkConstants.VM_WORK_JOB_DISPATCHER);
+		workJob.setCmd(VmWorkConstants.VM_WORK_START);
+		
+		workJob.setAccountId(1L);
+		workJob.setUserId(1L);
+		workJob.setStep(VmWorkJobVO.Step.Starting);
+		workJob.setVmType(VirtualMachine.Type.ConsoleProxy);
+		workJob.setVmInstanceId(1L);
+
+		// save work context info (there are some duplications)
+		VmWorkStart workInfo = new VmWorkStart();
+		workInfo.setAccountId(1L);
+		workInfo.setUserId(1L);
+		workInfo.setVmId(1L);
+		workInfo.setPlan(null);
+		workInfo.setParams(null);
+		workJob.setCmdInfo(ApiSerializerHelper.toSerializedString(workInfo));
+		
+		_jobMgr.submitAsyncJob(workJob, VmWorkConstants.VM_WORK_QUEUE, 1L);
+		
+		_jobMgr.joinJob(job.getId(), workJob.getId(), "processVmStartWakeup", 
+				VmWorkConstants.VM_WORK_JOB_WAKEUP_DISPATCHER, 
+				new String[] {}, 
+				3000, 120000);
+	}
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2320b1c2/server/test/resources/VmWorkTestContext.xml
----------------------------------------------------------------------
diff --git a/server/test/resources/VmWorkTestContext.xml b/server/test/resources/VmWorkTestContext.xml
index 43457fc..11f50f8 100644
--- a/server/test/resources/VmWorkTestContext.xml
+++ b/server/test/resources/VmWorkTestContext.xml
@@ -46,6 +46,9 @@
   <bean id="VmWorkJobDispatcher" class="com.cloud.vm.VmWorkJobDispatcher">
     <property name="name" value="VmWorkJobDispatcher" />
   </bean>
+  <bean id="TestJobDispatcher" class="com.cloud.vm.VmWorkTestJobDispatcher">
+    <property name="name" value="TestJobDispatcher" />
+  </bean>
   
   <bean id="messageBus" class = "org.apache.cloudstack.framework.messagebus.MessageBusBase"
/>
 

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/2320b1c2/settings.xml.old
----------------------------------------------------------------------
diff --git a/settings.xml.old b/settings.xml.old
new file mode 100644
index 0000000..050af0c
--- /dev/null
+++ b/settings.xml.old
@@ -0,0 +1,98 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<settings xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <!--<localRepository>repo</localRepository>-->
+  <servers>
+    <server>
+      <username>admin</username>
+      <id>central</id>
+    </server>
+    <server>
+      <username>admin</username>
+      <id>snapshots</id>
+    </server>
+  </servers>
+  
+  <!--
+  <mirrors>
+    <mirror>
+      <id>central</id>
+      <name>Central</name>
+      <url>http://10.223.75.59:8081/nexus/content/repositories/central/
+      </url>
+      <mirrorOf>central</mirrorOf>
+    </mirror>
+  </mirrors>
+ --> 
+  <profiles>
+    <profile>
+      <id>thirdparty</id>
+      <activation>
+        <property>
+          <name>nonoss</name>
+        </property>
+      </activation>
+      <repositories>
+<!--
+        <repository>
+          <id>thirdparty</id>
+          <name>3rd party</name>
+          <url>http://10.223.75.59:8081/nexus/content/repositories/thirdparty
+          </url>
+          <layout>default</layout>
+          <releases>
+            <enabled>true</enabled>
+            <updatePolicy>never</updatePolicy>
+          </releases>
+          <snapshots>
+            <enabled>false</enabled>
+            <updatePolicy>never</updatePolicy>
+          </snapshots>
+        </repository>
+-->
+      </repositories>
+    </profile> 
+    <profile>
+      <repositories>
+        <repository>
+          <snapshots>
+            <enabled>false</enabled>
+          </snapshots>
+          <id>repo1</id>
+          <name>repo1</name>
+          <url>http://repo1.maven.org/maven2</url>
+        </repository>
+        <repository>
+          <snapshots>
+            <enabled>false</enabled>
+          </snapshots>
+          <id>central</id>
+          <name>libs-release</name>
+          <url>http://cs.ibuildthecloud.com/artifactory/libs-release</url>
+        </repository>
+      </repositories>
+      <id>artifactory</id>
+    </profile>
+  </profiles>
+  <activeProfiles>
+    <activeProfile>artifactory</activeProfile>
+  </activeProfiles>
+</settings>
+


Mime
View raw message