qinjunjerry commented on a change in pull request #13309: URL: https://github.com/apache/flink/pull/13309#discussion_r482458090
########## File path: flink-libraries/flink-state-processing-api/src/test/java/org/apache/flink/state/api/SavepointDeepCopyTest.java ########## @@ -0,0 +1,212 @@ +/* + * 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.state.api; + +import org.apache.flink.api.common.state.ValueState; +import org.apache.flink.api.common.state.ValueStateDescriptor; +import org.apache.flink.api.common.typeinfo.TypeHint; +import org.apache.flink.api.common.typeinfo.TypeInformation; +import org.apache.flink.api.java.DataSet; +import org.apache.flink.api.java.ExecutionEnvironment; +import org.apache.flink.api.java.tuple.Tuple2; +import org.apache.flink.configuration.Configuration; +import org.apache.flink.contrib.streaming.state.RocksDBStateBackend; +import org.apache.flink.core.fs.Path; +import org.apache.flink.runtime.state.StateBackend; +import org.apache.flink.runtime.state.filesystem.FsStateBackend; +import org.apache.flink.state.api.functions.KeyedStateBootstrapFunction; +import org.apache.flink.state.api.functions.KeyedStateReaderFunction; +import org.apache.flink.test.util.AbstractTestBase; +import org.apache.flink.util.AbstractID; +import org.apache.flink.util.Collector; + +import org.apache.commons.lang3.RandomStringUtils; +import org.junit.Assert; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +import java.io.File; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.Collection; +import java.util.Set; +import java.util.stream.Collectors; + +import static org.hamcrest.Matchers.everyItem; +import static org.hamcrest.Matchers.isIn; +import static org.junit.Assert.assertThat; + +/** + * Test the savepoint deep copy. + */ +@RunWith(value = Parameterized.class) +public class SavepointDeepCopyTest extends AbstractTestBase { + + private static final String TEXT = "The quick brown fox jumps over the lazy dog"; + private static final String RANDOM_VALUE = RandomStringUtils.randomAlphanumeric(120); + + private final StateBackend backend; + + public SavepointDeepCopyTest(StateBackend backend) throws Exception { + this.backend = backend; + //reset the cluster so we can change the state backend + miniClusterResource.after(); + miniClusterResource.before(); + } + + @Parameterized.Parameters(name = "State Backend: {0}") + public static Collection<StateBackend> data() { + // set the threshold to 1024 bytes to allow generate additional state data files with a small state + int fileStateSizeThreshold = 1024; + return Arrays.asList( + new FsStateBackend(new Path("file:///tmp").toUri(), fileStateSizeThreshold), + new RocksDBStateBackend( + (StateBackend) new FsStateBackend(new Path("file:///tmp").toUri(), fileStateSizeThreshold) + ) + ); + } + + /** + * To bootstrapper a savepoint for testing. + */ + static class WordMapBootstrapper extends KeyedStateBootstrapFunction<String, String> { + private ValueState<Tuple2<String, String>> state; + + @Override + public void open(Configuration parameters) { + ValueStateDescriptor<Tuple2<String, String>> descriptor = new ValueStateDescriptor<>( + "state", + TypeInformation.of(new TypeHint<Tuple2<String, String>>(){})); Review comment: Thanks for the hint! ---------------------------------------------------------------- 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: us...@infra.apache.org