This is an automated email from the ASF dual-hosted git repository. nju_yaho pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/kylin.git
commit c5fd42aa3b925b8e83743532234ef2351f2cd4ee Author: Zhong <nju_y...@apache.org> AuthorDate: Fri Jun 22 11:04:10 2018 +0800 KYLIN-3421 fix IT --- .../kylin/job/BaseTestDistributedScheduler.java | 5 +-- .../apache/kylin/job/ContextTestExecutable.java | 44 ---------------------- .../kylin/job/ITDistributedSchedulerBaseTest.java | 43 ++------------------- .../job/ITDistributedSchedulerTakeOverTest.java | 7 +--- 4 files changed, 8 insertions(+), 91 deletions(-) diff --git a/kylin-it/src/test/java/org/apache/kylin/job/BaseTestDistributedScheduler.java b/kylin-it/src/test/java/org/apache/kylin/job/BaseTestDistributedScheduler.java index 644b2b3..ec6faf2 100644 --- a/kylin-it/src/test/java/org/apache/kylin/job/BaseTestDistributedScheduler.java +++ b/kylin-it/src/test/java/org/apache/kylin/job/BaseTestDistributedScheduler.java @@ -57,9 +57,8 @@ public class BaseTestDistributedScheduler extends HBaseMetadataTestCase { static File localMetaDir; static String backup; - static final String SEGMENT_ID = "segmentId"; - static final String segmentId1 = "seg1" + UUID.randomUUID(); - static final String segmentId2 = "seg2" + UUID.randomUUID(); + static final String jobId1 = "job1" + UUID.randomUUID(); + static final String jobId2 = "job2" + UUID.randomUUID(); static final String serverName1 = "serverName1"; static final String serverName2 = "serverName2"; static final String confDstPath1 = "target/kylin_metadata_dist_lock_test1/kylin.properties"; diff --git a/kylin-it/src/test/java/org/apache/kylin/job/ContextTestExecutable.java b/kylin-it/src/test/java/org/apache/kylin/job/ContextTestExecutable.java deleted file mode 100644 index 9b4f299..0000000 --- a/kylin-it/src/test/java/org/apache/kylin/job/ContextTestExecutable.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 org.apache.kylin.job; - -import org.apache.kylin.job.exception.ExecuteException; -import org.apache.kylin.job.execution.AbstractExecutable; -import org.apache.kylin.job.execution.ExecutableContext; -import org.apache.kylin.job.execution.ExecuteResult; - -public class ContextTestExecutable extends AbstractExecutable { - public ContextTestExecutable() { - super(); - } - - @Override - protected ExecuteResult doWork(ExecutableContext context) throws ExecuteException { - - try { - Thread.sleep(1000); - } catch (InterruptedException e) { - } - if (context.getConfig() == BaseTestDistributedScheduler.kylinConfig1) { - return new ExecuteResult(); - } else { - return new ExecuteResult(ExecuteResult.State.ERROR, "error"); - } - } -} diff --git a/kylin-it/src/test/java/org/apache/kylin/job/ITDistributedSchedulerBaseTest.java b/kylin-it/src/test/java/org/apache/kylin/job/ITDistributedSchedulerBaseTest.java index 483d8f7..0b0a40f 100644 --- a/kylin-it/src/test/java/org/apache/kylin/job/ITDistributedSchedulerBaseTest.java +++ b/kylin-it/src/test/java/org/apache/kylin/job/ITDistributedSchedulerBaseTest.java @@ -28,23 +28,20 @@ import org.junit.Test; public class ITDistributedSchedulerBaseTest extends BaseTestDistributedScheduler { @Test public void testSchedulerLock() throws Exception { - if (!lock(jobLock1, segmentId1)) { + if (!lock(jobLock1, jobId1)) { throw new JobException("fail to get the lock"); } DefaultChainedExecutable job = new DefaultChainedExecutable(); - job.setParam(SEGMENT_ID, segmentId1); + job.setId(jobId1); AbstractExecutable task1 = new SucceedTestExecutable(); - task1.setParam(SEGMENT_ID, segmentId1); AbstractExecutable task2 = new SucceedTestExecutable(); - task2.setParam(SEGMENT_ID, segmentId1); AbstractExecutable task3 = new SucceedTestExecutable(); - task3.setParam(SEGMENT_ID, segmentId1); job.addTask(task1); job.addTask(task2); job.addTask(task3); execMgr.addJob(job); - Assert.assertEquals(serverName1, getServerName(segmentId1)); + Assert.assertEquals(serverName1, getServerName(jobId1)); waitForJobFinish(job.getId()); @@ -55,38 +52,6 @@ public class ITDistributedSchedulerBaseTest extends BaseTestDistributedScheduler Thread.sleep(5000); - Assert.assertEquals(null, getServerName(segmentId1)); - } - - @Test - public void testSchedulerConsistent() throws Exception { - if (!lock(jobLock1, segmentId2)) { - throw new JobException("fail to get the lock"); - } - DefaultChainedExecutable job = new DefaultChainedExecutable(); - job.setParam(SEGMENT_ID, segmentId2); - ContextTestExecutable task1 = new ContextTestExecutable(); - task1.setParam(SEGMENT_ID, segmentId2); - job.addTask(task1); - execMgr.addJob(job); - - waitForJobFinish(job.getId()); - Assert.assertEquals(ExecutableState.SUCCEED, execMgr.getOutput(task1.getId()).getState()); - Assert.assertEquals(ExecutableState.SUCCEED, execMgr.getOutput(job.getId()).getState()); - - if (!lock(jobLock2, segmentId2)) { - throw new JobException("fail to get the lock"); - } - - DefaultChainedExecutable job2 = new DefaultChainedExecutable(); - job2.setParam(SEGMENT_ID, segmentId2); - ContextTestExecutable task2 = new ContextTestExecutable(); - task2.setParam(SEGMENT_ID, segmentId2); - job2.addTask(task2); - execMgr.addJob(job2); - - waitForJobFinish(job2.getId()); - Assert.assertEquals(ExecutableState.ERROR, execMgr.getOutput(task2.getId()).getState()); - Assert.assertEquals(ExecutableState.ERROR, execMgr.getOutput(job2.getId()).getState()); + Assert.assertEquals(null, getServerName(jobId1)); } } diff --git a/kylin-it/src/test/java/org/apache/kylin/job/ITDistributedSchedulerTakeOverTest.java b/kylin-it/src/test/java/org/apache/kylin/job/ITDistributedSchedulerTakeOverTest.java index d9e0d9a..c2256e3 100644 --- a/kylin-it/src/test/java/org/apache/kylin/job/ITDistributedSchedulerTakeOverTest.java +++ b/kylin-it/src/test/java/org/apache/kylin/job/ITDistributedSchedulerTakeOverTest.java @@ -28,18 +28,15 @@ import org.junit.Test; public class ITDistributedSchedulerTakeOverTest extends BaseTestDistributedScheduler { @Test public void testSchedulerTakeOver() throws Exception { - if (!lock(jobLock1, segmentId2)) { + if (!lock(jobLock1, jobId2)) { throw new JobException("fail to get the lock"); } DefaultChainedExecutable job = new DefaultChainedExecutable(); - job.setParam(SEGMENT_ID, segmentId2); + job.setId(jobId2); AbstractExecutable task1 = new SucceedTestExecutable(); - task1.setParam(SEGMENT_ID, segmentId2); AbstractExecutable task2 = new SucceedTestExecutable(); - task2.setParam(SEGMENT_ID, segmentId2); AbstractExecutable task3 = new SucceedTestExecutable(); - task3.setParam(SEGMENT_ID, segmentId2); job.addTask(task1); job.addTask(task2); job.addTask(task3);