Skip to content

Conversation

@sgithens
Copy link
Member

@sgithens sgithens commented Jun 4, 2018

https://issues.gpii.net/browse/GPII-228

This is in progress work of resurrecting @kaspermarkus 2014 work on a snapshotting tool. (Now being called capture since we have some other core utilities that have been developed in the interim that are named snapshotting for journalling)

This still requires some work on the SPI settings handler, and settings handlers in general, but I would welcome any comments on the work thus far.

@sgithens sgithens changed the title GPII-228 2018 GPII-228 Capture Settings Backend (Snapshotter 2018) Jun 4, 2018
@gpii-bot
Copy link

gpii-bot commented Jun 4, 2018

CI job passed: https://ci.gpii.net/job/universal-tests/891/

@gpii-bot
Copy link

CI job failed: https://ci.gpii.net/job/universal-tests/1422/

@gpii-bot
Copy link

gpii-bot commented Jan 1, 2019

CI job failed: https://ci.gpii.net/job/universal-tests/1423/

@gpii-bot
Copy link

CI job failed: https://ci.gpii.net/job/universal-tests/1440/

@gpii-bot
Copy link

CI job failed: https://ci.gpii.net/job/universal-tests/1634/

@gpii-bot
Copy link

CI job passed: https://ci.gpii.net/job/universal-tests/2118/

@sgithens
Copy link
Member Author

I made a minor change so that the tests pass now. (previously it was using the actual live platform reporter). This should still actually work fine without the world destroying GPII-3119, since the SPI settings workaround is still in the lifecycle manager. Whenever GPII-3119 is done, that workaround can simply be removed.

);
};

gpii.flowManager.getSolutionsPromise = function (solutionsRegistryDataSource, deviceContext) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Rather than adding a new getSolutionsPromise function, have you tried to get getSolutions return a promise besides firing events and have the capture component call getSolutions?

Copy link
Member Author

Choose a reason for hiding this comment

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

Neat idea, I updated the function to handle both purposes, and cleaned up it's jsdoc


// The solutions block is a read only data structure
var adjustedSolutions = fluid.copy(solutionsRegistryDataSource.fullSolutionsRegistry);
adjustedSolutions.darwin.fakemag2.settingsHandlers.configuration.options.filename = testDataFile;
Copy link
Contributor

Choose a reason for hiding this comment

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

When all settings handlers consume same set of settings/values, it would be hard to detect a coding error that causes the same data being returned.

Copy link
Member Author

Choose a reason for hiding this comment

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

this is a really good point. I created a second file, and added a few settings and make some subtle changes to the types.

* Tests for formatting raw captures.
*/
gpii.tests.flowManager.capture.testFormatRawCapturedSettings = function () {
var allCorrectSettings = gpii.flowManager.formatRawCapturedSettings([
Copy link
Contributor

Choose a reason for hiding this comment

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

A couple of thoughts:

  1. It would be easier to read and maintain if all test cases are collected together. Just an example:
var testCases = {
    "allCorrectSettings": {
        message: "...",
        input: {...},
        expected: {...}
    },
    "withFetchError": {
        [same structure as above]
    },
    ...
};

fluid.each(testCases, function (oneTest) {
    var result = gpii.flowManager.formatRawCapturedSettings(oneTest.input);
    jqUnit.assert(oneTest.message, oneTest.expected, result);
});
  1. Please also test edge cases such as, no settings are returned, all fetch errors etc.
  2. Please use a slightly different setting sets/values especially when multiple settings are tested in one single test case so it doesn't miss the coding error when the same result is returned for all settings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reworked these, and added more edge cases.

- Updated method name packages
- Updated license header
- Removed unused code
- Converted single line methods to invoker definitions
- Used fluid.get for property access
@gpii-bot
Copy link

gpii-bot commented Feb 6, 2020

CI job passed: https://ci.gpii.net/job/universal-tests/2133/

@gpii-bot
Copy link

gpii-bot commented Feb 6, 2020

CI job passed: https://ci.gpii.net/job/universal-tests/2134/

- Updated jsdoc formatting
- Updated event names
- Restructured tests and added more
@gpii-bot
Copy link

gpii-bot commented Feb 6, 2020

CI job passed: https://ci.gpii.net/job/universal-tests/2136/

@sgithens
Copy link
Member Author

sgithens commented Feb 6, 2020

Would be clearer to use meaningful var names for event parameters: event -> onSuccessEvent; onError -> onErrorEvent.

Updated these names

@sgithens
Copy link
Member Author

sgithens commented Feb 6, 2020

@cindyli @amb26 This should be ready again now

@gpii-bot
Copy link

gpii-bot commented Feb 6, 2020

CI job passed: https://ci.gpii.net/job/universal-tests/2137/

},
getSystemSettingsCapture: {
funcName: "fluid.promise.fireTransformEvent",
args: ["{that}.events.onCaptureSettingsForCurrentDevice", {}, "{arguments}.0"] // options
Copy link
Contributor

Choose a reason for hiding this comment

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

It's confusing to have the second argument as an empty object. BTW, you didn't document it in the jsdoc for this function. I understand you use it as a placeholder for the solution list returned by getInstalledSolutionsForCurrentDevice(). But this gonna to be expressed in a more understandable way. What I can think of is:

  1. remove this argument;
  2. improve the first action onCaptureSettingsForCurrentDevice.getInstalledSolutionsForCurrentDevice in the promise chain to return:
{
    installedSolutions: {},
    options: {}
}
  1. This structure will be the input of the next listener.

Copy link
Contributor

@cindyli cindyli Feb 7, 2020

Choose a reason for hiding this comment

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

Well, you did have a doc for this empty object although it's inaccurate:
* @param {Object} solutions - Solutions registry entries for solutions available on the current machine.

"solutions available on the current machine" is a value waiting to be calculated within this function rather than an empty object.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ok, so I cleaned things up abit. I also removed another internal invoker that was just for the promise chain and declared it in line. The remaining two invokers are both for external usage, and I added a jsdoc for the first one as well.

I cleaned up the arguments on the other jsdoc... actually it had a couple arguments that were no longer relevant anymore, it only takes the one single options argument. It was still documenting the parameters from the function version rather than the invoker setup.

I changed the transforming promise chain invocation's argument from an empty object to just null, to hopefully make it more clear. It is only there so I can use the 3rd argument from the fire transform api. https://github.com/fluid-project/infusion-docs/blob/master/src/documents/PromisesAPI.md#fluidpromisefiretransformeventevent-payload-options

I'd like to keep the promise chains set up the way they are if possible, and keep the options in the designated 3rd parameter that each of the listeners can optionally except. I think it's pretty nice that each member in the chain takes the previous value and returns the next promise with no extra stuff. It's just that the promise chain doesn't require any payload to start, which is which is why the null is there.

@gpii-bot
Copy link

gpii-bot commented Feb 7, 2020

CI job passed: https://ci.gpii.net/job/universal-tests/2141/

@cindyli
Copy link
Contributor

cindyli commented Feb 12, 2020

This pull request looks good to me. Thanks, @sgithens.

@sgithens
Copy link
Member Author

Awesome, thanks @cindyli . @amb26 Can we go ahead and merge this now?

@amb26 amb26 merged commit 3834082 into GPII:master Feb 17, 2020
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.

4 participants