Github user tillrohrmann commented on a diff in the pull request:
https://github.com/apache/flink/pull/4376#discussion_r130052646
--- Diff:
flink-runtime/src/test/java/org/apache/flink/runtime/highavailability/zookeeper/HighAvailabilityServiceTest.java
---
@@ -0,0 +1,115 @@
+/*
+ * 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.runtime.highavailability.zookeeper;
+
+import akka.actor.ActorRef;
+import org.apache.curator.test.TestingServer;
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.configuration.Configuration;
+import org.apache.flink.configuration.HighAvailabilityOptions;
+import org.apache.flink.core.fs.FileSystem;
+import org.apache.flink.runtime.akka.ListeningBehaviour;
+import org.apache.flink.runtime.blob.FileSystemBlobStore;
+import org.apache.flink.runtime.concurrent.Executors;
+import org.apache.flink.runtime.highavailability.HighAvailabilityServices;
+import org.apache.flink.runtime.jobgraph.JobGraph;
+import org.apache.flink.runtime.jobmanager.JobInfo;
+import org.apache.flink.runtime.jobmanager.SubmittedJobGraph;
+import org.apache.flink.runtime.jobmanager.SubmittedJobGraphStore;
+import org.apache.flink.runtime.util.ZooKeeperUtils;
+
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import org.junit.Assert;
+import org.junit.rules.ExpectedException;
+
+public class HighAvailabilityServiceTest {
+ private TestingServer testingServer;
+ private HighAvailabilityServices zkHaService;
+ private SubmittedJobGraphStore submittedJobGraphStore;
+
+ @Rule
+ public ExpectedException thrown = ExpectedException.none();
+
+ @Before
+ public void before() throws Exception {
+ testingServer = new TestingServer();
+
+ Configuration configuration = new Configuration();
+
configuration.setString(HighAvailabilityOptions.HA_ZOOKEEPER_QUORUM,
testingServer.getConnectString());
+ configuration.setString(HighAvailabilityOptions.HA_MODE,
"zookeeper");
+
configuration.setString(HighAvailabilityOptions.HA_STORAGE_PATH, "temp");
+ zkHaService = new ZooKeeperHaServices(
+
ZooKeeperUtils.startCuratorFramework(configuration),
+ Executors.directExecutor(),
+ configuration,
+ new
FileSystemBlobStore(FileSystem.getLocalFileSystem(), "local"));
+
+ submittedJobGraphStore =
zkHaService.getSubmittedJobGraphStore();
+ submittedJobGraphStore.start(new
SubmittedJobGraphStore.SubmittedJobGraphListener() {
+ @Override
+ public void onAddedJobGraph(JobID jobId) {
+
+ }
+
+ @Override
+ public void onRemovedJobGraph(JobID jobId) {
+
+ }
+ });
+ }
+
+ @After
+ public void after() throws Exception {
+ testingServer.stop();
+ testingServer = null;
+
+ submittedJobGraphStore.stop();
+ submittedJobGraphStore = null;
+
+ zkHaService.closeAndCleanupAllData();
+ zkHaService = null;
+ }
+
+ /**
+ * Tests for that the function of cleanupData(JobID) in
SubmittedJobGraph
+ */
+ @Test
+ public void testCleanSubmittedJobGraphStore() throws Exception {
+ SubmittedJobGraph jobGraph1 = new SubmittedJobGraph(
+ new
JobGraph("testSubmittedJob1"),
+ new
JobInfo(ActorRef.noSender(), ListeningBehaviour.DETACHED, 0,
Integer.MAX_VALUE));
+ SubmittedJobGraph jobGraph2 = new SubmittedJobGraph(
+ new
JobGraph("testSubmittedJob2"),
+ new
JobInfo(ActorRef.noSender(), ListeningBehaviour.DETACHED, 0,
Integer.MAX_VALUE));
+ submittedJobGraphStore.putJobGraph(jobGraph1);
+ submittedJobGraphStore.putJobGraph(jobGraph2);
+
+ zkHaService.cleanupData(jobGraph1.getJobId());
+
+ SubmittedJobGraph recoverJobGraph2 =
submittedJobGraphStore.recoverJobGraph(jobGraph2.getJobId());
+ Assert.assertEquals(recoverJobGraph2.getJobId(),
jobGraph2.getJobId());
+ thrown.expectMessage("Could not retrieve the submitted job
graph state handle for /" +
--- End diff --
Could we rather check for the exception type? Matching exception messages
is really brittle.
---
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 [email protected] or file a JIRA ticket
with INFRA.
---