Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C66B22004F1 for ; Wed, 30 Aug 2017 18:14:18 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C2EE61696A4; Wed, 30 Aug 2017 16:14:18 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id E32901696A2 for ; Wed, 30 Aug 2017 18:14:17 +0200 (CEST) Received: (qmail 86701 invoked by uid 500); 30 Aug 2017 16:14:17 -0000 Mailing-List: contact notifications-help@asterixdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@asterixdb.apache.org Delivered-To: mailing list notifications@asterixdb.apache.org Received: (qmail 86692 invoked by uid 99); 30 Aug 2017 16:14:17 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd2-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 30 Aug 2017 16:14:17 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd2-us-west.apache.org (ASF Mail Server at spamd2-us-west.apache.org) with ESMTP id 971201A0B87 for ; Wed, 30 Aug 2017 16:14:16 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd2-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 4.072 X-Spam-Level: **** X-Spam-Status: No, score=4.072 tagged_above=-999 required=6.31 tests=[MISSING_HEADERS=1.207, REPLYTO_WITHOUT_TO_CC=1.946, SPF_FAIL=0.919] autolearn=disabled Received: from mx1-lw-eu.apache.org ([10.40.0.8]) by localhost (spamd2-us-west.apache.org [10.40.0.9]) (amavisd-new, port 10024) with ESMTP id qTnq6r4Ee_1A for ; Wed, 30 Aug 2017 16:14:14 +0000 (UTC) Received: from vitalstatistix.ics.uci.edu (vitalstatistix.ics.uci.edu [128.195.52.38]) by mx1-lw-eu.apache.org (ASF Mail Server at mx1-lw-eu.apache.org) with ESMTP id D31175FE5F for ; Wed, 30 Aug 2017 16:14:13 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by vitalstatistix.ics.uci.edu (Postfix) with ESMTP id D7DC21009C2; Wed, 30 Aug 2017 09:14:12 -0700 (PDT) Date: Wed, 30 Aug 2017 09:14:12 -0700 From: "abdullah alamoudi (Code Review)" Message-ID: Reply-To: bamousaa@gmail.com X-Gerrit-MessageType: newchange Subject: Change in asterixdb[master]: [NO ISSUE][TEST] Improve Job Failure Tests X-Gerrit-Change-Id: I9cdf53a88e07aaa3dc7cd11c5bb7ef9369835da6 X-Gerrit-ChangeURL: X-Gerrit-Commit: e6f1c59cd2cbb930280d062cb7270f22932bf526 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Content-Disposition: inline User-Agent: Gerrit/2.12.7 archived-at: Wed, 30 Aug 2017 16:14:19 -0000 abdullah alamoudi has uploaded a new change for review. https://asterix-gerrit.ics.uci.edu/1983 Change subject: [NO ISSUE][TEST] Improve Job Failure Tests ...................................................................... [NO ISSUE][TEST] Improve Job Failure Tests - user model changes: no - storage format changes: no - interface changes: no details: - Add a check that all started jobs finished. Change-Id: I9cdf53a88e07aaa3dc7cd11c5bb7ef9369835da6 --- M asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveNotificationHandler.java M hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/AbstractMultiNCIntegrationTest.java A hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TestJobLifecycleListener.java 3 files changed, 117 insertions(+), 1 deletion(-) git pull ssh://asterix-gerrit.ics.uci.edu:29418/asterixdb refs/changes/83/1983/1 diff --git a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveNotificationHandler.java b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveNotificationHandler.java index d36d9b7..cbcc44f 100644 --- a/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveNotificationHandler.java +++ b/asterixdb/asterix-app/src/main/java/org/apache/asterix/app/active/ActiveNotificationHandler.java @@ -132,6 +132,7 @@ @Override public synchronized void notifyJobFinish(JobId jobId, JobStatus jobStatus, List exceptions) throws HyracksException { + LOGGER.log(level, "Getting notified of job finish for JobId: " + jobId); EntityId entityId = jobId2EntityId.get(jobId); if (entityId != null) { add(new ActiveEvent(jobId, Kind.JOB_FINISHED, entityId, Pair.of(jobStatus, exceptions))); diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/AbstractMultiNCIntegrationTest.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/AbstractMultiNCIntegrationTest.java index 18479e2..3fe17fc 100644 --- a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/AbstractMultiNCIntegrationTest.java +++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/AbstractMultiNCIntegrationTest.java @@ -43,13 +43,16 @@ import org.apache.hyracks.client.dataset.HyracksDataset; import org.apache.hyracks.control.cc.BaseCCApplication; import org.apache.hyracks.control.cc.ClusterControllerService; +import org.apache.hyracks.control.cc.application.CCServiceContext; import org.apache.hyracks.control.common.controllers.CCConfig; import org.apache.hyracks.control.common.controllers.NCConfig; import org.apache.hyracks.control.nc.NodeControllerService; import org.apache.hyracks.control.nc.resources.memory.FrameManager; import org.apache.hyracks.dataflow.common.comm.io.ResultFrameTupleAccessor; import org.apache.hyracks.dataflow.common.comm.util.ByteBufferInputStream; +import org.junit.After; import org.junit.AfterClass; +import org.junit.Before; import org.junit.BeforeClass; import com.fasterxml.jackson.databind.ObjectMapper; @@ -67,6 +70,8 @@ private static NodeControllerService[] asterixNCs; private static IHyracksClientConnection hcc; + + private static final TestJobLifecycleListener jobLifecycleListener = new TestJobLifecycleListener(); private final List outputFiles; @@ -91,7 +96,8 @@ ccConfig.setAppClass(DummyApplication.class.getName()); cc = new ClusterControllerService(ccConfig); cc.start(); - + CCServiceContext serviceCtx = cc.getContext(); + serviceCtx.addJobLifecycleListener(jobLifecycleListener); asterixNCs = new NodeControllerService[ASTERIX_IDS.length]; for (int i = 0; i < ASTERIX_IDS.length; i++) { File ioDev = new File("target" + File.separator + ASTERIX_IDS[i] + File.separator + "ioDevice"); @@ -122,6 +128,16 @@ cc.stop(); } + @Before + public void setUp() { + jobLifecycleListener.reset(); + } + + @After + public void validate() throws Exception { + jobLifecycleListener.check(); + } + protected JobId startJob(JobSpecification spec) throws Exception { return hcc.startJob(spec); } diff --git a/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TestJobLifecycleListener.java b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TestJobLifecycleListener.java new file mode 100644 index 0000000..1bbf8d5 --- /dev/null +++ b/hyracks-fullstack/hyracks/hyracks-examples/hyracks-integration-tests/src/test/java/org/apache/hyracks/tests/integration/TestJobLifecycleListener.java @@ -0,0 +1,99 @@ +/* + * 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.hyracks.tests.integration; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.logging.Level; +import java.util.logging.Logger; + +import org.apache.hyracks.api.exceptions.HyracksDataException; +import org.apache.hyracks.api.exceptions.HyracksException; +import org.apache.hyracks.api.job.IJobLifecycleListener; +import org.apache.hyracks.api.job.JobId; +import org.apache.hyracks.api.job.JobSpecification; +import org.apache.hyracks.api.job.JobStatus; + +@SuppressWarnings("deprecation") +public class TestJobLifecycleListener implements IJobLifecycleListener { + + private static final Logger LOGGER = Logger.getLogger(TestJobLifecycleListener.class.getName()); + private final Map created = new HashMap<>(); + private final Set started = new HashSet<>(); + private final Set finished = new HashSet<>(); + + @Override + public void notifyJobCreation(JobId jobId, JobSpecification spec) throws HyracksException { + if (created.containsKey(jobId)) { + throw new HyracksDataException("Job " + jobId + "has been created before"); + } + created.put(jobId, spec); + } + + @Override + public void notifyJobStart(JobId jobId) throws HyracksException { + if (!created.containsKey(jobId)) { + throw new HyracksDataException("Job " + jobId + "has not been created"); + } + if (started.contains(jobId)) { + throw new HyracksDataException("Job " + jobId + "has been started before"); + } + started.add(jobId); + } + + @Override + public void notifyJobFinish(JobId jobId, JobStatus jobStatus, List exceptions) throws HyracksException { + if (!started.contains(jobId)) { + throw new HyracksDataException("Job " + jobId + "has not been started"); + } + if (finished.contains(jobId)) { + // TODO: job finish should be called once only when it has really completed + // throw new HyracksDataException("Job " + jobId + "has been finished before"); + LOGGER.log(Level.WARNING, "Dangerous: Duplicate Job: " + jobId + " has finished with status: " + jobStatus); + } else { + LOGGER.log(Level.WARNING, "Job: " + jobId + " has finished with status: " + jobStatus); + } + finished.add(jobId); + } + + public void reset() { + created.clear(); + started.clear(); + finished.clear(); + } + + public void check() throws Exception { + LOGGER.log(Level.WARNING, "Checking all created jobs have started"); + for (JobId jobId : created.keySet()) { + if (!started.contains(jobId)) { + throw new Exception("JobId " + jobId + " has been created but never started"); + } + } + LOGGER.log(Level.WARNING, "Checking all started jobs have terminated"); + for (JobId jobId : started) { + if (!finished.contains(jobId)) { + throw new Exception("JobId " + jobId + " has started but not finished"); + } + } + LOGGER.log(Level.WARNING, "All is good"); + } +} -- To view, visit https://asterix-gerrit.ics.uci.edu/1983 To unsubscribe, visit https://asterix-gerrit.ics.uci.edu/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I9cdf53a88e07aaa3dc7cd11c5bb7ef9369835da6 Gerrit-PatchSet: 1 Gerrit-Project: asterixdb Gerrit-Branch: master Gerrit-Owner: abdullah alamoudi