Return-Path: X-Original-To: apmail-cloudstack-commits-archive@www.apache.org Delivered-To: apmail-cloudstack-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0263111D18 for ; Sat, 11 May 2013 01:11:32 +0000 (UTC) Received: (qmail 60533 invoked by uid 500); 11 May 2013 01:11:31 -0000 Delivered-To: apmail-cloudstack-commits-archive@cloudstack.apache.org Received: (qmail 60483 invoked by uid 500); 11 May 2013 01:11:31 -0000 Mailing-List: contact commits-help@cloudstack.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cloudstack.apache.org Delivered-To: mailing list commits@cloudstack.apache.org Received: (qmail 60475 invoked by uid 99); 11 May 2013 01:11:31 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 11 May 2013 01:11:31 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 74C5988BC0F; Sat, 11 May 2013 01:11:31 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: kelveny@apache.org To: commits@cloudstack.apache.org Message-Id: <197eae93eda144eabf750ac458a7c49e@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: git commit: updated refs/heads/vmsync to 2320b1c Date: Sat, 11 May 2013 01:11:31 +0000 (UTC) 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 Authored: Fri May 10 18:07:14 2013 -0700 Committer: Kelven Yang 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 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 @@ + + + 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 @@ + + + + + + admin + central + + + admin + snapshots + + + + + + + thirdparty + + + nonoss + + + + + + + + + + + false + + repo1 + repo1 + http://repo1.maven.org/maven2 + + + + false + + central + libs-release + http://cs.ibuildthecloud.com/artifactory/libs-release + + + artifactory + + + + artifactory + + +