Forum Discussion

Lewis_Beard's avatar
3 months ago

Testing LogicModules without updating?

I looked around in the LogicModules at the BGP- LogicModule (datasource) because I plan to update the current one we have (older) to the latest.

I was hoping that I could go to the Exchange page and test it in the UI (changing but not saving) or something. But I guess thats a security risk and wouldnt be allowed.

I then tried to look at the update/diff stage of the update on the MyToolbox side, hoping I could actually run the code from there somehow with an alteration. Again, I guess there is a security concern. But I did use the copy icon on the update (right) side to export the data, and I tried to edit it with a new name and import it but its not valid for import.

So then I went to our test portal, we have a separate one for testing, and I updated to the latest over there, and then did an export from a fully-installed one. I was able to edit that one by changing the names and display names and wiping out the metadata block and changing the file export name field, and the applies to was swapped to false() and then I validated I could import it BACK into the test server without breaking the one I updated (the real one). Since this work I then updated this FAKE-BUT-UPDATED one to our real portal as well. Once it was imported and saved, THEN I was able to test against real devices by changing the applied-to in the UI but never saving, just running. All was well on all the servers I tested on, so I feel good about doing the update.

But WOW. Is there an easier way? I wish I could test the updated code before actually updating, without this circuitous approach.

Am I missing something obvious? Is there a better way?

  • That is close to what I do also. Although I might just directly temp rename it in sandbox before exporting the json as I'm not really worried about breaking our sandbox instance temporarily.

    I guess you can also copy the script code from the diff page, convert the /t and /n stuff, edit the existing DataSource, paste in the new script, and just use the Test Script button, making sure not to save.

    Most of the time I'm able to review the code via diff (although I copy it to winmerge after converting /t and /n) and most past changes have been minor. So I normally only go thru this full process when the results are hard to determine or too many changes to the code.

    I just realized that My Modules doesn't appear to offer a Clone option anymore like the old DataSources UI did. Is that something that was removed or am I just not looking at the right place?

    • Anonymous's avatar
      Anonymous

      I see the clone option when editing a DS. One thing that's different is that when you clone something it saves it right away. That way the clone is one entry in the changelog and your modifications are a different entry (as far as i can guess). So if you hit the clone button, then navigate away, there will be an orphaned clone in your environment. Compound this with the fact that there's no warning that you'll lose unsaved changes if you navigate away from a DS you were in the middle of modifying.

      • Lewis_Beard's avatar
        Lewis_Beard
        Icon for Expert rankExpert

        Yeah, having to edit to clone is frustrating. I think you also have to edit to export. Urgh.

  • Anonymous's avatar
    Anonymous

    There's not a better way that I know of, except to run the code in the debug console. That won't work for non-batchscript modules, though.

    Great idea to be able to run it from the diff view. Would be nice to be able to run both versions and diff the output for you.