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

Serialize updated value of entity document in response #4646

Merged
merged 18 commits into from
Nov 29, 2019

Conversation

upgle
Copy link
Member

@upgle upgle commented Sep 26, 2019

Description

Since an action API doesn't serialize the updated value of the action entity, users can't know when the action was updated.

It changes the action API to serialize and provide the updated value of the action

Related issue and scope

#4228

My changes affect the following components

  • API
  • Controller
  • Message Bus (e.g., Kafka)
  • Loadbalancer
  • Invoker
  • Intrinsic actions (e.g., sequences, conductors)
  • Data stores (e.g., CouchDB)
  • Tests
  • Deployment
  • CLI
  • General tooling
  • Documentation

Types of changes

  • Bug fix (generally a non-breaking change which closes an issue).
  • Enhancement or new feature (adds new functionality).
  • Breaking change (a bug fix or enhancement which changes existing behavior).

Checklist:

  • I signed an Apache CLA.
  • I reviewed the style guides and followed the recommendations (Travis CI will check :).
  • I added tests to cover my changes.
  • My changes require further changes to the documentation.
  • I updated the documentation where necessary.

@upgle upgle changed the title Serialize the updated value in the db out in the action Serialize updated value in action doc Sep 26, 2019
Copy link
Member

@rabbah rabbah left a comment

Choose a reason for hiding this comment

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

Why only actions? All assets have an updated field.

@upgle
Copy link
Member Author

upgle commented Sep 27, 2019

@rabbah Thank you for review. I think the updated field of activation doesn't need to be serialized because it has start and end timestamp fields.

So I'll modify all assets (trigger, rules, and package) except activation to serialize updated field.

@upgle upgle changed the title Serialize updated value in action doc Serialize updated value of entity document in response Sep 27, 2019
@codecov-io
Copy link

codecov-io commented Sep 30, 2019

Codecov Report

Merging #4646 into master will decrease coverage by 6.66%.
The diff coverage is 92.3%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4646      +/-   ##
==========================================
- Coverage   84.99%   78.32%   -6.67%     
==========================================
  Files         198      198              
  Lines        8845     8837       -8     
  Branches      615      606       -9     
==========================================
- Hits         7518     6922     -596     
- Misses       1327     1915     +588
Impacted Files Coverage Δ
...org/apache/openwhisk/core/entity/WhiskEntity.scala 92.3% <100%> (+0.12%) ⬆️
...rg/apache/openwhisk/core/entity/WhiskTrigger.scala 100% <100%> (ø) ⬆️
...rg/apache/openwhisk/core/entity/WhiskPackage.scala 96.77% <100%> (ø) ⬆️
...a/org/apache/openwhisk/core/entity/WhiskRule.scala 82.35% <100%> (ø) ⬆️
...org/apache/openwhisk/core/entity/WhiskAction.scala 91.25% <83.33%> (+0.09%) ⬆️
...core/database/cosmosdb/RxObservableImplicits.scala 0% <0%> (-100%) ⬇️
...enwhisk/connector/kafka/KamonMetricsReporter.scala 0% <0%> (-100%) ⬇️
...e/database/cosmosdb/cache/ChangeFeedConsumer.scala 0% <0%> (-100%) ⬇️
...ore/database/cosmosdb/cache/CacheInvalidator.scala 0% <0%> (-100%) ⬇️
...core/database/cosmosdb/CosmosDBArtifactStore.scala 0% <0%> (-96.23%) ⬇️
... and 24 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3235a94...26a446f. Read the comment docs.

@upgle
Copy link
Member Author

upgle commented Sep 30, 2019

It passed all the tests 👍

@upgle upgle requested a review from rabbah September 30, 2019 06:27
@@ -48,7 +47,7 @@ abstract class WhiskEntity protected[entity] (en: EntityName, val entityType: St
val version: SemVer
val publish: Boolean
val annotations: Parameters
val updated = Instant.now(Clock.systemUTC())
val updated = WhiskEntity.currentMillis()
Copy link
Member

Choose a reason for hiding this comment

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

since all the subtypes now assign this value in the constructors, can we make this an abstract value?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we can't make this an abstract value because the WhiskActivation entity type doesn't assign this value to the constructor.

@rabbah
Copy link
Member

rabbah commented Nov 12, 2019

Changes lgtm now with the added explanation.

@@ -54,6 +54,10 @@ class PackagesApiTests extends ControllerTestCommon with WhiskPackagesApi {
def aname() = MakeName.next("packages_tests")
val parametersLimit = Parameters.sizeLimit

def checkResponse(response: WhiskPackage, expected: WhiskPackage) =
Copy link
Member

Choose a reason for hiding this comment

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

kudos - thanks for doing this.

@tysonnorris
Copy link
Contributor

Looks like a failure in RulesApiTests

@upgle
Copy link
Member Author

upgle commented Nov 14, 2019

One test case has been broken by refactoring. I just fixed it.

@upgle upgle force-pushed the feature/add-updated-field branch 2 times, most recently from 3971288 to 1606a42 Compare November 14, 2019 08:39
Copy link
Member

@style95 style95 left a comment

Choose a reason for hiding this comment

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

LGTM

My comment would not block merging this.

@@ -61,6 +63,11 @@ class RulesApiTests extends ControllerTestCommon with WhiskRulesApi {
val activeStatus = s"""{"status":"${Status.ACTIVE}"}""".parseJson.asJsObject
val inactiveStatus = s"""{"status":"${Status.INACTIVE}"}""".parseJson.asJsObject
val parametersLimit = Parameters.sizeLimit
val dummyInstant = Instant.now()

def checkResponse(response: WhiskRuleResponse, expected: WhiskRuleResponse) =
Copy link
Member

Choose a reason for hiding this comment

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

One small nit can be extracting this kind of methods into a trait.

Copy link
Member Author

Choose a reason for hiding this comment

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

@style95 Thank you for review, I've created a common method to test the WhiskAction, WhiskActionMetaData, WhiskTrigger, and WhiskPackage. But I couldn't extract the method in the RulesApiTests because WhiskRuleResponse doesn't extend WhiskEntity.

Please review it again 😄

26a446f#diff-a151ad71ab374ea12d3b9c780b59de30R88

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