Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FLINK-16234][tests] Fix unstable cases in StreamingJobGraphGeneratorTest #11187

Closed

Conversation

cpugputpu
Copy link
Contributor

This PR aims to solve the issue presented here: https://issues.apache.org/jira/browse/FLINK-16234

What is the purpose of the change

The fix is to change the HashSet to LinkedHashSet to make the tests more stable.

Verifying this change

This change is already covered by existing tests, and it can pass them successfully.

Does this pull request potentially affect one of the following parts:

  • Dependencies (does it add or upgrade a dependency): no
  • The public API, i.e., is any changed class annotated with @Public(Evolving): no
  • The serializers: don't know
  • The runtime per-record code paths (performance sensitive): no
  • Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Kubernetes/Yarn/Mesos, ZooKeeper: no
  • The S3 file system connector: no

Documentation

  • Does this pull request introduce a new feature? no
  • If yes, how is the feature documented? not applicable

@flinkbot
Copy link
Collaborator

Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
to review your pull request. We will use this comment to track the progress of the review.

Automated Checks

Last check on commit 7f887f5 (Sat Feb 22 15:03:43 UTC 2020)

Warnings:

  • No documentation files were touched! Remember to keep the Flink docs up to date!
  • This pull request references an unassigned Jira ticket. According to the code contribution guide, tickets need to be assigned before starting with the implementation work.

Mention the bot in a comment to re-run the automated checks.

Review Progress

  • ❓ 1. The [description] looks good.
  • ❓ 2. There is [consensus] that the contribution should go into to Flink.
  • ❓ 3. Needs [attention] from.
  • ❓ 4. The change fits into the overall [architecture].
  • ❓ 5. Overall code [quality] is good.

Please see the Pull Request Review Guide for a full explanation of the review process.


The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required Bot commands
The @flinkbot bot supports the following commands:

  • @flinkbot approve description to approve one or more aspects (aspects: description, consensus, architecture and quality)
  • @flinkbot approve all to approve all aspects
  • @flinkbot approve-until architecture to approve everything until architecture
  • @flinkbot attention @username1 [@username2 ..] to require somebody's attention
  • @flinkbot disapprove architecture to remove an approval you gave earlier

@flinkbot
Copy link
Collaborator

flinkbot commented Feb 22, 2020

CI report:

Bot commands The @flinkbot bot supports the following commands:
  • @flinkbot run travis re-run the last Travis build
  • @flinkbot run azure re-run the last Azure build

@StephanEwen
Copy link
Contributor

If the test assertion is flakey, why not fix the test assertion instead?

@zhuzhurk
Copy link
Contributor

Thanks for reporting this issue and trying to fix it @cpugputpu .
I second with @StephanEwen that we should fix the tests instead (testSlotSharingOnAllVerticesInSameSlotSharingGroupByDefaultEnabled and testSlotSharingOnAllVerticesInSameSlotSharingGroupByDefaultDisabled). We should not assume that the topological order of sources is the same as the order that they are added into the StreamGraph.
To fix those problematic tests, one option is to find the wanted vertex via the name rather than via the index.

@cpugputpu do you want to fix it?

@cpugputpu
Copy link
Contributor Author

Thanks for your valuable comments! I am sorry that my previous fix was not a good one. Now I fix it without changing StreamGraph.java.
@flinkbot run travis

final JobVertex source2Vertex = verticesSorted.get(1);
final JobVertex map1Vertex = verticesSorted.get(2);
final JobVertex map2Vertex = verticesSorted.get(3);
JobVertex source1Vertex = null, source2Vertex = null, map1Vertex = null, map2Vertex= null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should not declare multiple variables in one line.

final JobVertex map2Vertex = verticesSorted.get(3);
JobVertex source1Vertex = null, source2Vertex = null, map1Vertex = null, map2Vertex= null;
for (int i = 0; i < 4; i++)
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The left brace should be in the same line with the for statement.

for (int i = 0; i < 4; i++)
{
JobVertex vertex = verticesSorted.get(i);
if (vertex.getName().equals("Source: source1"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if body should always be surrounded by braces.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer to change the matching to if (vertex.getName().contains("source1")).

final JobVertex map1Vertex = verticesSorted.get(2);
final JobVertex map2Vertex = verticesSorted.get(3);
JobVertex source1Vertex = null, source2Vertex = null, map1Vertex = null, map2Vertex= null;
for (int i = 0; i < 4; i++)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we could extract this matching block to a common method to avoid duplication. It can return a list of JobVertices in the expected order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comments! I have updated the fix.


private List<JobVertex> getExpectedVerticesList(List<JobVertex> vertices) {
List<JobVertex> verticesMatched = new ArrayList<JobVertex>();
List<String> ExpectedOrder = Arrays.asList("source1", "source2", "map1", "map2");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the head letter of this variable should not be capitalized.

@@ -857,4 +860,17 @@ private static Method getSetResourcesMethodAndSetAccessible(final Class<?> clazz
setResourcesMethod.setAccessible(true);
return setResourcesMethod;
}

private List<JobVertex> getExpectedVerticesList(List<JobVertex> vertices) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this method can be static

Copy link
Contributor

@zhuzhurk zhuzhurk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing all the comments.
The change looks good to me. Merging.

zhuzhurk pushed a commit to zhuzhurk/flink that referenced this pull request Feb 27, 2020
@zhuzhurk zhuzhurk changed the title [FLINK-16234]Use LinkedHashSet for a deterministic iteration order [FLINK-16234][tests] Fix unstable cases in StreamingJobGraphGeneratorTest Feb 27, 2020
@zhuzhurk zhuzhurk closed this in 39e75eb Feb 27, 2020
zhuzhurk pushed a commit that referenced this pull request Feb 27, 2020
@cpugputpu cpugputpu deleted the Use-LinkedHashSet-in-StreamGraph.java branch February 29, 2020 08:18
@cpugputpu cpugputpu restored the Use-LinkedHashSet-in-StreamGraph.java branch February 29, 2020 08:18
@cpugputpu cpugputpu deleted the Use-LinkedHashSet-in-StreamGraph.java branch February 29, 2020 08:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants