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

[BEAM-13870] [Playground] Increase test coverage for the cache package #16826

Merged
merged 5 commits into from
Feb 24, 2022

Conversation

pavel-avilov
Copy link
Contributor

[BEAM-13870]
Add unit tests to increase test coverage for the cache package


Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:

  • Choose reviewer(s) and mention them in a comment (R: @username).
  • Format the pull request title like [BEAM-XXX] Fixes bug in ApproximateQuantiles, where you replace BEAM-XXX with the appropriate JIRA issue, if applicable. This will automatically link the pull request to the issue.
  • Update CHANGES.md with noteworthy changes.
  • If this contribution is large, please file an Apache Individual Contributor License Agreement.

See the Contributor Guide for more tips on how to make review process smoother.

ValidatesRunner compliance status (on master branch)

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- Build Status Build Status Build Status Build Status ---
Java Build Status Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Build Status
Python --- Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status ---
XLang Build Status Build Status
Build Status
Build Status
Build Status Build Status Build Status ---

Examples testing status on various runners

Lang ULR Dataflow Flink Samza Spark Twister2
Go --- --- --- --- --- --- ---
Java --- Build Status
Build Status
Build Status
--- --- --- --- ---
Python --- --- --- --- --- --- ---
XLang --- --- --- --- --- --- ---

Post-Commit SDK/Transform Integration Tests Status (on master branch)

Go Java Python
Build Status Build Status Build Status
Build Status
Build Status

Pre-Commit Tests Status (on master branch)

--- Java Python Go Website Whitespace Typescript
Non-portable Build Status
Build Status
Build Status
Build Status
Build Status
Build Status Build Status Build Status Build Status
Portable --- Build Status Build Status --- --- ---

See .test-infra/jenkins/README for trigger phrase, status and link of all Jenkins jobs.

GitHub Actions Tests Status (on master branch)

Build python source distribution and wheels
Python tests
Java tests

See CI.md for more information about GitHub Actions CI.

@pavel-avilov
Copy link
Contributor Author

@ilya-kozyrev @KhaninArtur

Copy link
Contributor

@KhaninArtur KhaninArtur left a comment

Choose a reason for hiding this comment

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

The tests are LGTM, could you please also add comments to all others so it is easier to read them? That would help very much, thanks!

Comment on lines 109 to 110
// Test case with calling GetValue method with exist value the expiration time of which has ended.
// As a result, want to receive an error.
Copy link
Contributor

Choose a reason for hiding this comment

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

Thank you for adding these comments, could you please also add comments for other tests in these files? So every test in local_cache_test.go and redis_cache_test.go has a corresponding comment😊

{
// Test case with calling startGC method with nil items.
// As a result, items stay the same.
name: "Checking for deleting expired pipelines with nil items",
Copy link
Contributor

Choose a reason for hiding this comment

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

Not clear

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

want *Cache
}{
{
// Test case with calling New method.
Copy link
Contributor

Choose a reason for hiding this comment

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

Redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -243,6 +243,23 @@ func TestRedisCache_SetValue(t *testing.T) {
},
wantErr: false,
},
{
// Test case with calling SetValue method with incorrect value.
Copy link
Contributor

Choose a reason for hiding this comment

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

Redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -535,6 +555,28 @@ func Test_unmarshalBySubKey(t *testing.T) {
want: output,
wantErr: false,
},
{
// Test case with calling unmarshalBySubKey method with Canceled subKey.
// As a result, want to receive false.
Copy link
Contributor

Choose a reason for hiding this comment

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

Why it will be false?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@daria-malkova because canceledValue is JSON encoding of the false.

}{
{
// Test case with calling SetExpTime method with pipelineId and his expiration time.
Copy link
Contributor

Choose a reason for hiding this comment

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

Redundant

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@AydarZaynutdinov AydarZaynutdinov left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -103,6 +105,23 @@ func TestLocalCache_GetValue(t *testing.T) {
want: nil,
wantErr: true,
},
{
// Test case with calling GetValue method with existing value that is expiring.
Copy link
Contributor

Choose a reason for hiding this comment

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

Unuseful comment

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -159,6 +178,23 @@ func TestLocalCache_SetValue(t *testing.T) {
},
wantErr: false,
},
{
// Test case with calling SetValue method with RunOutputIndex subKey.
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

wantErr: false,
},
{
// Test case with calling SetExpTime method with pipelineId which not set in cache and expiration time.
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@@ -68,7 +68,7 @@ func TestRedisCache_GetValue(t *testing.T) {
wantErr: true,
},
{
name: "all success",
name: "get existing value",
Copy link
Contributor

Choose a reason for hiding this comment

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

Sometimes you have a name with an upper case letter, but sometimes with lower case. Do the same everywhere

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, let's start all test names with upper case letters.
E.g. here

Suggested change
name: "get existing value",
name: "Get existing value",

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@KhaninArtur KhaninArtur left a comment

Choose a reason for hiding this comment

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

Let's finalize the naming and address Daria's comments. Then we'll be good to go🙂

@@ -68,7 +68,7 @@ func TestRedisCache_GetValue(t *testing.T) {
wantErr: true,
},
{
name: "all success",
name: "get existing value",
Copy link
Contributor

Choose a reason for hiding this comment

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

I agree, let's start all test names with upper case letters.
E.g. here

Suggested change
name: "get existing value",
name: "Get existing value",

Copy link
Contributor

@KhaninArtur KhaninArtur left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@daria-malkova daria-malkova left a comment

Choose a reason for hiding this comment

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

LGTM

@pavel-avilov
Copy link
Contributor Author

R: @pabloem

@pabloem
Copy link
Member

pabloem commented Feb 24, 2022

LGTM

@pabloem pabloem merged commit 2a45a5b into apache:master Feb 24, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants