To test an API using oauth2 I have to obtain a token and refresh it before it gets invalid.
(refresh is necessary if a test run for one VU takes longer than a token is valid)
My Idea was to request a token and work with it , but loop in the background to refresh the token before it gets invalid.
The fork should get deleted after each iteration of the VU (as far as I understand that's the default behaviour if I do this within "Actions" instead of "Init")
So I created
- Action1: request a token and extract it to Variable "token"
- Action2: create a fork with an endless loop containing 2 Subactions:
- ..Subaction1: wait until token is going to be invalid soon (e.g. expirationDate - 60 sec)
- ..Subaction2: refresh token, update Variable "token" and start over again
- Action3-x: In the main thread, test my API using "token"
Expected behaviour: the token in the main thread is updated as soon as the forked thread updates the token; subsequent requests use the updated token.
Current behaviour: the token variable is only updated within the fork (and in other forks); but it is unchanged in the main thread.
Is there a way to propagate updates to the main thread?