Skip to content

Commit

Permalink
[FLINK-8982][e2e tests] Add E2E Tests for queryable state.
Browse files Browse the repository at this point in the history
Adds one test for normal execution and
one with a TM failure scenario.

This closes apache#5807.
  • Loading branch information
florianschmidt1994 authored and kl0u committed Jun 21, 2018
1 parent 0bdde83 commit 59a58e5
Show file tree
Hide file tree
Showing 14 changed files with 1,143 additions and 1 deletion.
134 changes: 134 additions & 0 deletions flink-end-to-end-tests/flink-queryable-state-test/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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:https://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.
-->
<project xmlns="http:https://maven.apache.org/POM/4.0.0"
xmlns:xsi="http:https://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http:https://maven.apache.org/POM/4.0.0 http:https://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>flink-end-to-end-tests</artifactId>
<groupId>org.apache.flink</groupId>
<version>1.6-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>flink-queryable-state-test_${scala.binary.version}</artifactId>
<name>flink-queryable-state-test</name>

<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-streaming-java_${scala.binary.version}</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-statebackend-rocksdb_${scala.binary.version}</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>

<executions>
<execution>
<id>QsStateProducer</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<classifier>QsStateProducer</classifier>
<archive>
<manifestEntries>
<program-class>
org.apache.flink.streaming.tests.queryablestate.QsStateProducer
</program-class>
</manifestEntries>
</archive>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<executions>

<execution>
<id>QsStateClient</id>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<shadeTestJar>false</shadeTestJar>
<shadedArtifactAttached>false</shadedArtifactAttached>
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>
org.apache.flink.streaming.tests.queryablestate.QsStateClient
</mainClass>
</transformer>
</transformers>
<finalName>QsStateClient</finalName>
</configuration>
</execution>
</executions>
</plugin>

<!--simplify the name of the testing JARs for referring to them in the end-to-end test scripts-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>rename</id>
<phase>package</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<target>
<copy
file="${project.basedir}/target/flink-queryable-state-test_${scala.binary.version}-${project.version}-QsStateProducer.jar"
tofile="${project.basedir}/target/QsStateProducer.jar"/>
</target>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
* 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:https://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.streaming.tests.queryablestate;

import java.time.Instant;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;

/**
* Toy email resentation.
*/
public class Email {

private EmailId emailId;
private Instant timestamp;
private String foo;
private LabelSurrogate label;

public Email(EmailId emailId, Instant timestamp, String foo, LabelSurrogate label) {
this.emailId = emailId;
this.timestamp = timestamp;
this.foo = foo;
this.label = label;
}

public EmailId getEmailId() {
return emailId;
}

public void setEmailId(EmailId emailId) {
this.emailId = emailId;
}

public Instant getTimestamp() {
return timestamp;
}

public void setTimestamp(Instant timestamp) {
this.timestamp = timestamp;
}

public String getFoo() {
return foo;
}

public void setFoo(String foo) {
this.foo = foo;
}

public LabelSurrogate getLabel() {
return label;
}

public void setLabel(LabelSurrogate label) {
this.label = label;
}

public String getDate() {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd").withZone(ZoneId.of("UTC"));
return formatter.format(timestamp);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* 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:https://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.streaming.tests.queryablestate;

import java.io.Serializable;
import java.util.Objects;

/**
* POJO representing an EmailId.
*/
public class EmailId implements Serializable {

private static final long serialVersionUID = -5001464312464872467L;

private String emailId;

public EmailId() {

}

public EmailId(String emailId) {
this.emailId = Objects.requireNonNull(emailId);
}

public void setEmailId(String emailId) {
this.emailId = emailId;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

EmailId emailId1 = (EmailId) o;

return Objects.equals(emailId, emailId1.emailId);
}

@Override
public int hashCode() {
return Objects.hash(emailId);
}

public String getEmailId() {
return emailId;
}

@Override
public String toString() {
return "EmailId{" +
"emailId='" + emailId + '\'' +
'}';
}
}
Loading

0 comments on commit 59a58e5

Please sign in to comment.