Restarting a user thread conditionally in JMeter











up vote
0
down vote

favorite












I know that I can stop a thread conditionally in JMeter.



In my script I'm sending a requests and then I'm extracting their response json to further process it. There are some rare cases, where the parameter response provides some value that I cannot process in further steps.



I could actually detect this valid response by extracting another parameter. Would it be possible to just restart the thread based on condition, instead of stopping it?










share|improve this question


















  • 1




    Even if you can you may get infinite loop, why you need to restart?
    – user7294900
    15 hours ago










  • I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
    – ArturS
    15 hours ago















up vote
0
down vote

favorite












I know that I can stop a thread conditionally in JMeter.



In my script I'm sending a requests and then I'm extracting their response json to further process it. There are some rare cases, where the parameter response provides some value that I cannot process in further steps.



I could actually detect this valid response by extracting another parameter. Would it be possible to just restart the thread based on condition, instead of stopping it?










share|improve this question


















  • 1




    Even if you can you may get infinite loop, why you need to restart?
    – user7294900
    15 hours ago










  • I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
    – ArturS
    15 hours ago













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I know that I can stop a thread conditionally in JMeter.



In my script I'm sending a requests and then I'm extracting their response json to further process it. There are some rare cases, where the parameter response provides some value that I cannot process in further steps.



I could actually detect this valid response by extracting another parameter. Would it be possible to just restart the thread based on condition, instead of stopping it?










share|improve this question













I know that I can stop a thread conditionally in JMeter.



In my script I'm sending a requests and then I'm extracting their response json to further process it. There are some rare cases, where the parameter response provides some value that I cannot process in further steps.



I could actually detect this valid response by extracting another parameter. Would it be possible to just restart the thread based on condition, instead of stopping it?







jmeter






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 18 hours ago









ArturS

46110




46110








  • 1




    Even if you can you may get infinite loop, why you need to restart?
    – user7294900
    15 hours ago










  • I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
    – ArturS
    15 hours ago














  • 1




    Even if you can you may get infinite loop, why you need to restart?
    – user7294900
    15 hours ago










  • I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
    – ArturS
    15 hours ago








1




1




Even if you can you may get infinite loop, why you need to restart?
– user7294900
15 hours ago




Even if you can you may get infinite loop, why you need to restart?
– user7294900
15 hours ago












I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
– ArturS
15 hours ago




I was uploading file that would get converted next, and then I was just waiting with next upload request until previous file gets converted (in order not to stack the conversion processes to queue). Getting wrong response and passing its value further caused wrong data being extracted into the next request, which was causing the script loop. Anyway I've managed to restart the script though, I'll post the solution for this kind of work, so it might be useful for someone.
– ArturS
15 hours ago












2 Answers
2






active

oldest

votes

















up vote
1
down vote













Without scripting, you can add Flow Control Action (was: Test Action )



Choose Target: Current Thread and Action: Start Next Thread Loop



It'll skip "damaged" thread and continue to the next thread






share|improve this answer




























    up vote
    0
    down vote













    For further researchers:



    The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.



        import org.apache.jmeter.samplers.SampleResult;
    import org.apache.jmeter.threads.JMeterContext;
    import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;


    String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)

    if(statVar.equals("NOK")){ . //checking the condition

    SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
    AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
    }





    share|improve this answer



















    • 1




      Next iteration isn't equal to restart
      – user7294900
      14 hours ago










    • You're right it's more like moving to another iteration in terms of skipping current thread.
      – ArturS
      13 hours ago











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371798%2frestarting-a-user-thread-conditionally-in-jmeter%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    Without scripting, you can add Flow Control Action (was: Test Action )



    Choose Target: Current Thread and Action: Start Next Thread Loop



    It'll skip "damaged" thread and continue to the next thread






    share|improve this answer

























      up vote
      1
      down vote













      Without scripting, you can add Flow Control Action (was: Test Action )



      Choose Target: Current Thread and Action: Start Next Thread Loop



      It'll skip "damaged" thread and continue to the next thread






      share|improve this answer























        up vote
        1
        down vote










        up vote
        1
        down vote









        Without scripting, you can add Flow Control Action (was: Test Action )



        Choose Target: Current Thread and Action: Start Next Thread Loop



        It'll skip "damaged" thread and continue to the next thread






        share|improve this answer












        Without scripting, you can add Flow Control Action (was: Test Action )



        Choose Target: Current Thread and Action: Start Next Thread Loop



        It'll skip "damaged" thread and continue to the next thread







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered 13 hours ago









        user7294900

        17.9k93056




        17.9k93056
























            up vote
            0
            down vote













            For further researchers:



            The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.



                import org.apache.jmeter.samplers.SampleResult;
            import org.apache.jmeter.threads.JMeterContext;
            import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;


            String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)

            if(statVar.equals("NOK")){ . //checking the condition

            SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
            AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
            }





            share|improve this answer



















            • 1




              Next iteration isn't equal to restart
              – user7294900
              14 hours ago










            • You're right it's more like moving to another iteration in terms of skipping current thread.
              – ArturS
              13 hours ago















            up vote
            0
            down vote













            For further researchers:



            The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.



                import org.apache.jmeter.samplers.SampleResult;
            import org.apache.jmeter.threads.JMeterContext;
            import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;


            String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)

            if(statVar.equals("NOK")){ . //checking the condition

            SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
            AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
            }





            share|improve this answer



















            • 1




              Next iteration isn't equal to restart
              – user7294900
              14 hours ago










            • You're right it's more like moving to another iteration in terms of skipping current thread.
              – ArturS
              13 hours ago













            up vote
            0
            down vote










            up vote
            0
            down vote









            For further researchers:



            The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.



                import org.apache.jmeter.samplers.SampleResult;
            import org.apache.jmeter.threads.JMeterContext;
            import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;


            String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)

            if(statVar.equals("NOK")){ . //checking the condition

            SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
            AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
            }





            share|improve this answer














            For further researchers:



            The easy way to start another iteration of a thread based on condition (i.e extracting some data out of json) is to use a BeanShell Sampler in way like described above.



                import org.apache.jmeter.samplers.SampleResult;
            import org.apache.jmeter.threads.JMeterContext;
            import org.apache.jmeter.threads.JMeterContext.TestLogicalAction;


            String statVar = vars.get("statusVariable"); //getting some data for condition check (statusVariable is a variable that has been set previously in the Jmeter JSON Extractor)

            if(statVar.equals("NOK")){ . //checking the condition

            SampleResult.setTestLogicalAction(TestLogicalAction.START_NEXT_ITERATION_OF_THRE
            AD); //Starting thread again (it starts the thread from the beginning, so we may compare this to restart effect)
            }






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited 13 hours ago

























            answered 15 hours ago









            ArturS

            46110




            46110








            • 1




              Next iteration isn't equal to restart
              – user7294900
              14 hours ago










            • You're right it's more like moving to another iteration in terms of skipping current thread.
              – ArturS
              13 hours ago














            • 1




              Next iteration isn't equal to restart
              – user7294900
              14 hours ago










            • You're right it's more like moving to another iteration in terms of skipping current thread.
              – ArturS
              13 hours ago








            1




            1




            Next iteration isn't equal to restart
            – user7294900
            14 hours ago




            Next iteration isn't equal to restart
            – user7294900
            14 hours ago












            You're right it's more like moving to another iteration in terms of skipping current thread.
            – ArturS
            13 hours ago




            You're right it's more like moving to another iteration in terms of skipping current thread.
            – ArturS
            13 hours ago


















             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53371798%2frestarting-a-user-thread-conditionally-in-jmeter%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Can a sorcerer learn a 5th-level spell early by creating spell slots using the Font of Magic feature?

            ts Property 'filter' does not exist on type '{}'

            mat-slide-toggle shouldn't change it's state when I click cancel in confirmation window