zentol commented on a change in pull request #8052: 
[FLINK-11458][checkpointing, rest] Add TERMINATE/SUSPEND Job with Savepoint 
(FLIP-34)
URL: https://github.com/apache/flink/pull/8052#discussion_r271697616
 
 

 ##########
 File path: 
flink-runtime/src/test/java/org/apache/flink/runtime/rest/handler/job/savepoints/StopWithSavepointHandlersTest.java
 ##########
 @@ -0,0 +1,217 @@
+/*
+ * 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.rest.handler.job.savepoints;
+
+import org.apache.flink.api.common.JobID;
+import org.apache.flink.api.common.time.Time;
+import org.apache.flink.runtime.concurrent.FutureUtils;
+import org.apache.flink.runtime.rest.handler.HandlerRequest;
+import org.apache.flink.runtime.rest.handler.HandlerRequestException;
+import org.apache.flink.runtime.rest.handler.RestHandlerException;
+import org.apache.flink.runtime.rest.handler.async.AsynchronousOperationResult;
+import org.apache.flink.runtime.rest.messages.EmptyRequestBody;
+import org.apache.flink.runtime.rest.messages.JobIDPathParameter;
+import org.apache.flink.runtime.rest.messages.TriggerId;
+import org.apache.flink.runtime.rest.messages.TriggerIdPathParameter;
+import org.apache.flink.runtime.rest.messages.job.savepoints.SavepointInfo;
+import 
org.apache.flink.runtime.rest.messages.job.savepoints.SavepointStatusMessageParameters;
+import 
org.apache.flink.runtime.rest.messages.job.savepoints.stop.StopWithSavepointMessageParameters;
+import 
org.apache.flink.runtime.rest.messages.job.savepoints.stop.StopWithSavepointRequestBody;
+import org.apache.flink.runtime.rest.messages.queue.QueueStatus;
+import org.apache.flink.runtime.webmonitor.RestfulGateway;
+import org.apache.flink.runtime.webmonitor.TestingRestfulGateway;
+import org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever;
+
+import 
org.apache.flink.shaded.netty4.io.netty.handler.codec.http.HttpResponseStatus;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.CompletableFuture;
+
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.instanceOf;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
+
+/**
+ * Test for the {@link 
org.apache.flink.runtime.rest.handler.job.savepoints.SavepointHandlers.StopWithSavepointHandler}.
+ *
+ * <p>Shamelessly copied from {@link SavepointHandlersTest}.
+ */
+public class StopWithSavepointHandlersTest {
+
+       private static final Time TIMEOUT = Time.seconds(10);
+
+       private static final JobID JOB_ID = new JobID();
+
+       private static final String COMPLETED_SAVEPOINT_EXTERNAL_POINTER = 
"/tmp/stop-savepoint-0d2fb9-8d5e0106041a";
+
+       private static final String 
DEFAULT_REQUESTED_SAVEPOINT_TARGET_DIRECTORY = "/tmp";
+
+       private SavepointHandlers.StopWithSavepointHandler 
savepointTriggerHandler;
+
+       private SavepointHandlers.SavepointStatusHandler savepointStatusHandler;
+
+       private GatewayRetriever<RestfulGateway> leaderRetriever;
+
+       @Before
+       public void setUp() throws Exception {
+               leaderRetriever = () -> CompletableFuture.completedFuture(null);
+
+               final SavepointHandlers savepointHandlers = new 
SavepointHandlers(null);
+               savepointTriggerHandler = savepointHandlers.new 
StopWithSavepointHandler(
+                               leaderRetriever,
+                               TIMEOUT,
+                               Collections.emptyMap());
+
+               savepointStatusHandler = savepointHandlers.new 
SavepointStatusHandler(
+                               leaderRetriever,
+                               TIMEOUT,
+                               Collections.emptyMap());
+       }
+
+       @Test
+       public void testSavepointCompletedSuccessfully() throws Exception {
+               final TestingRestfulGateway testingRestfulGateway = new 
TestingRestfulGateway.Builder()
+                               .setStopWithSavepointFunction((JobID jobId, 
String targetDirectory) -> 
CompletableFuture.completedFuture(COMPLETED_SAVEPOINT_EXTERNAL_POINTER))
 
 Review comment:
   isn't this twice the usual indentation?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to