How to unit test config migration in plugin

15 views
Skip to first unread message

Łukasz Jąder

unread,
Mar 17, 2017, 6:45:01 PM3/17/17
to Jenkins Developers
Hi,

The class names and structure will change in ssh-plugin version 2.5, and I wanted to unit test this.

Currently the config migration (to be backward compatibile) is performed by @Override of hudson.model.Descriptor.load().

My questions:
1. Is using Descriptor.load() a recommended way to do config migration (backward compatibility)? Maybe there is a better way?
2. Do you know any existing plugins which have unit tests for backward compatibility code? Having an example of such would be a great start for me.

Jesse Glick

unread,
Mar 18, 2017, 11:15:08 AM3/18/17
to Jenkins Dev
As noted in the wiki, typically `readResolve` is used for simple migrations.

`@LocalData` is used for testing.

Łukasz Jąder

unread,
Apr 2, 2017, 11:15:51 AM4/2/17
to Jenkins Developers
Hi Jesse,

I saw "readResolve" info in the wiki, but I tried to achieve the same thing with "load()", which was already implemented in the plugin.
It looked OK and loaded the data during plugin installation, so I was a little lazy and skipped the change to "readResolve()".

With custom load() the @LocalData was not loading and I assumed the bug must be somewhere else.

Nevertheless I switched from load() to readResolve() and @LocalData somehow worked,
so thanks for the hint.
Reply all
Reply to author
Forward
0 new messages