Return-Path: X-Original-To: apmail-flink-issues-archive@minotaur.apache.org Delivered-To: apmail-flink-issues-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 73D5718C50 for ; Sun, 9 Aug 2015 05:37:29 +0000 (UTC) Received: (qmail 41975 invoked by uid 500); 9 Aug 2015 05:37:29 -0000 Delivered-To: apmail-flink-issues-archive@flink.apache.org Received: (qmail 41928 invoked by uid 500); 9 Aug 2015 05:37:29 -0000 Mailing-List: contact issues-help@flink.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@flink.apache.org Delivered-To: mailing list issues@flink.apache.org Received: (qmail 41918 invoked by uid 99); 9 Aug 2015 05:37:29 -0000 Received: from Unknown (HELO spamd4-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Aug 2015 05:37:29 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd4-us-west.apache.org (ASF Mail Server at spamd4-us-west.apache.org) with ESMTP id E1107C0484 for ; Sun, 9 Aug 2015 05:37:28 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd4-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.971 X-Spam-Level: X-Spam-Status: No, score=0.971 tagged_above=-999 required=6.31 tests=[KAM_LAZY_DOMAIN_SECURITY=1, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, T_RP_MATCHES_RCVD=-0.01, URIBL_BLOCKED=0.001] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd4-us-west.apache.org [10.40.0.11]) (amavisd-new, port 10024) with ESMTP id 5VjG2z5A1eAZ for ; Sun, 9 Aug 2015 05:37:21 +0000 (UTC) Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with SMTP id DE7162502B for ; Sun, 9 Aug 2015 05:37:20 +0000 (UTC) Received: (qmail 41839 invoked by uid 99); 9 Aug 2015 05:37:20 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 09 Aug 2015 05:37:20 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 94A22E033C; Sun, 9 Aug 2015 05:37:20 +0000 (UTC) From: gyfora To: issues@flink.incubator.apache.org Reply-To: issues@flink.incubator.apache.org References: In-Reply-To: Subject: [GitHub] flink pull request: [FLINK-2423] [streaming] ITCase for checkpoint... Content-Type: text/plain Message-Id: <20150809053720.94A22E033C@git1-us-west.apache.org> Date: Sun, 9 Aug 2015 05:37:20 +0000 (UTC) Github user gyfora commented on a diff in the pull request: https://github.com/apache/flink/pull/980#discussion_r36584713 --- Diff: flink-tests/src/test/java/org/apache/flink/test/checkpointing/StreamCheckpointNotifierITCase.java --- @@ -0,0 +1,340 @@ +/* + * 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.flink.test.checkpointing; + +import org.apache.flink.api.common.functions.RichFilterFunction; +import org.apache.flink.api.common.functions.RichMapFunction; +import org.apache.flink.api.common.functions.RichReduceFunction; +import org.apache.flink.api.common.state.OperatorState; +import org.apache.flink.api.java.tuple.Tuple1; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.streaming.api.checkpoint.CheckpointNotifier; +import org.apache.flink.streaming.api.checkpoint.Checkpointed; +import org.apache.flink.streaming.api.datastream.DataStream; +import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment; +import org.apache.flink.streaming.api.functions.co.RichCoFlatMapFunction; +import org.apache.flink.streaming.api.functions.sink.SinkFunction; +import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction; +import org.apache.flink.streaming.api.functions.source.RichSourceFunction; +import org.apache.flink.streaming.api.operators.OneInputStreamOperator; +import org.apache.flink.streaming.api.operators.TwoInputStreamOperator; +import org.apache.flink.util.Collector; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Random; + +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; + +/** + * Integration test for the {@link CheckpointNotifier} interface. The test ensures that + * {@link CheckpointNotifier#notifyCheckpointComplete(long)} is called for some completed + * checkpoints, that it is called at most once for any checkpoint id and that it is not + * called for a deliberately failed checkpoint. + * + *

+ * The topology tested here includes a number of {@link OneInputStreamOperator}s and a + * {@link TwoInputStreamOperator}. + * + *

+ * Note that as a result of doing the checks on the task level there is no way to verify + * that the {@link CheckpointNotifier#notifyCheckpointComplete(long)} is called for every + * successfully completed checkpoint. + */ +@SuppressWarnings("serial") +public class StreamCheckpointNotifierITCase extends StreamFaultToleranceTestBase { + + final long NUM_LONGS = 10_000_000L; + + /** + * Runs the following program: + * + *

    +	 *     [ (source)->(filter) ] -> [ (co-map) ] -> [ (map) ] -> [ (groupBy/reduce)->(sink) ]
    +	 * 
+ */ + @Override + public void testProgram(StreamExecutionEnvironment env) { + + DataStream stream = env.addSource(new GeneratingSourceFunction(NUM_LONGS)); + + stream + // -------------- first vertex, chained to the src ---------------- + .filter(new LongRichFilterFunction()) + + // -------------- second vertex, applying the co-map ---------------- + .connect(stream).flatMap(new LeftIdentityCoRichFlatMapFunction()) + + // -------------- third vertex - the stateful one that also fails ---------------- + .map(new IdentityMapFunction()) + .startNewChain() + + // -------------- fourth vertex - reducer and the sink ---------------- + .groupBy(0) + .reduce(new OnceFailingReducer(NUM_LONGS)) + .addSink(new SinkFunction>() { + @Override + public void invoke(Tuple1 value) { + // do nothing + } + }); + } + + @Override + public void postSubmit() { + List[][] checkList = new List[][]{ GeneratingSourceFunction.completedCheckpoints, + IdentityMapFunction.completedCheckpoints, + LongRichFilterFunction.completedCheckpoints, + LeftIdentityCoRichFlatMapFunction.completedCheckpoints}; + + for(List[] parallelNotifications : checkList) { + for (int i = 0; i < PARALLELISM; i++){ + List notifications = parallelNotifications[i]; + assertTrue("No checkpoint notification was received.", + notifications.size() > 0); + assertFalse("Failure checkpoint was marked as completed.", + notifications.contains(OnceFailingReducer.failureCheckpointID)); + assertTrue("Checkpoint notification was received multiple times", + notifications.size() == new HashSet(notifications).size()); --- End diff -- Maybe it would be also good to check whether we received anything after the failed checkpoint. --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastructure@apache.org or file a JIRA ticket with INFRA. ---