diff --git a/flink-kubernetes-operator-api/pom.xml b/flink-kubernetes-operator-api/pom.xml index 180c9e25e6..71b59abcc7 100644 --- a/flink-kubernetes-operator-api/pom.xml +++ b/flink-kubernetes-operator-api/pom.xml @@ -257,6 +257,23 @@ under the License. + + statesnapshot-crd-compatibility-check + package + + run + + + + + + + + + + + diff --git a/flink-kubernetes-operator-api/src/test/java/org/apache/flink/kubernetes/operator/api/validation/CrdCompatibilityCheckerTest.java b/flink-kubernetes-operator-api/src/test/java/org/apache/flink/kubernetes/operator/api/validation/CrdCompatibilityCheckerTest.java index 15e36c3bdc..90a7924b87 100644 --- a/flink-kubernetes-operator-api/src/test/java/org/apache/flink/kubernetes/operator/api/validation/CrdCompatibilityCheckerTest.java +++ b/flink-kubernetes-operator-api/src/test/java/org/apache/flink/kubernetes/operator/api/validation/CrdCompatibilityCheckerTest.java @@ -19,6 +19,7 @@ import org.apache.flink.kubernetes.operator.api.FlinkDeployment; import org.apache.flink.kubernetes.operator.api.FlinkSessionJob; +import org.apache.flink.kubernetes.operator.api.FlinkStateSnapshot; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.databind.ObjectMapper; @@ -271,6 +272,19 @@ public void testCreateFlinkDeploymentIgnoreUnknownFields() throws IOException { assertEquals(flinkDeploymentWithUnknownFields.toString(), flinkDeployment.toString()); } + @Test + public void testCreateFlinkStateSnapshotIgnoreUnknownFields() throws IOException { + FlinkStateSnapshot flinkSnapshotWithUnknownFields = + objectMapper.readValue( + new File("src/test/resources/test-snapshot-with-unknown-fields.yaml"), + FlinkStateSnapshot.class); + FlinkStateSnapshot flinkSnapshot = + objectMapper.readValue( + new File("src/test/resources/test-snapshot.yaml"), + FlinkStateSnapshot.class); + assertEquals(flinkSnapshotWithUnknownFields.toString(), flinkSnapshot.toString()); + } + @Test public void testGetSchemaFromUrl() throws IOException { var fileUrl = diff --git a/flink-kubernetes-operator-api/src/test/resources/test-snapshot-with-unknown-fields.yaml b/flink-kubernetes-operator-api/src/test/resources/test-snapshot-with-unknown-fields.yaml new file mode 100644 index 0000000000..c6e9dc8553 --- /dev/null +++ b/flink-kubernetes-operator-api/src/test/resources/test-snapshot-with-unknown-fields.yaml @@ -0,0 +1,30 @@ +################################################################################ +# 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. +################################################################################ +apiVersion: flink.apache.org/v1beta1 +kind: FlinkStateSnapshot +metadata: + name: example-savepoint +spec: + backoffLimit: 0 + jobReference: + kind: FlinkDeployment + name: example-deployment + unknownField: testUnknownField + savepoint: + unknownField: testUnknownField + unknownField: testUnknownField diff --git a/flink-kubernetes-operator-api/src/test/resources/test-snapshot.yaml b/flink-kubernetes-operator-api/src/test/resources/test-snapshot.yaml new file mode 100644 index 0000000000..e089896a8e --- /dev/null +++ b/flink-kubernetes-operator-api/src/test/resources/test-snapshot.yaml @@ -0,0 +1,27 @@ +################################################################################ +# 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. +################################################################################ +apiVersion: flink.apache.org/v1beta1 +kind: FlinkStateSnapshot +metadata: + name: example-savepoint +spec: + backoffLimit: 0 + jobReference: + kind: FlinkDeployment + name: example-deployment + savepoint: {}