Jmeter - Break a loop once the condition is met











up vote
1
down vote

favorite












In my thread I get active_status parameter from Cassandra DataBase. I need to run on each active_status var been created from Cassandra sample (active_status_1, active_status_2, etc..) and check if it's active.



When not active it should skip and do nothing and if it's active I need to do an action only once and then stop (so even if I have 10 active results, it will perform the action ("report" in my case) only on the first one).



Thread flow



active_status vars from debug response



inactive vars



media_id vars from debug response



media_id



http request where I use the counter



enter image description here



enter image description here



enter image description here



enter image description here



enter image description here



My action (report) request is: story_id=evE0-001-085121182-5&media_id=1021372295263777595_175887011&who=admin&reason=offensive&blogger_id=Amit even though "1021372295263777595_175887011" is not ACTIVE










share|improve this question




























    up vote
    1
    down vote

    favorite












    In my thread I get active_status parameter from Cassandra DataBase. I need to run on each active_status var been created from Cassandra sample (active_status_1, active_status_2, etc..) and check if it's active.



    When not active it should skip and do nothing and if it's active I need to do an action only once and then stop (so even if I have 10 active results, it will perform the action ("report" in my case) only on the first one).



    Thread flow



    active_status vars from debug response



    inactive vars



    media_id vars from debug response



    media_id



    http request where I use the counter



    enter image description here



    enter image description here



    enter image description here



    enter image description here



    enter image description here



    My action (report) request is: story_id=evE0-001-085121182-5&media_id=1021372295263777595_175887011&who=admin&reason=offensive&blogger_id=Amit even though "1021372295263777595_175887011" is not ACTIVE










    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      In my thread I get active_status parameter from Cassandra DataBase. I need to run on each active_status var been created from Cassandra sample (active_status_1, active_status_2, etc..) and check if it's active.



      When not active it should skip and do nothing and if it's active I need to do an action only once and then stop (so even if I have 10 active results, it will perform the action ("report" in my case) only on the first one).



      Thread flow



      active_status vars from debug response



      inactive vars



      media_id vars from debug response



      media_id



      http request where I use the counter



      enter image description here



      enter image description here



      enter image description here



      enter image description here



      enter image description here



      My action (report) request is: story_id=evE0-001-085121182-5&media_id=1021372295263777595_175887011&who=admin&reason=offensive&blogger_id=Amit even though "1021372295263777595_175887011" is not ACTIVE










      share|improve this question















      In my thread I get active_status parameter from Cassandra DataBase. I need to run on each active_status var been created from Cassandra sample (active_status_1, active_status_2, etc..) and check if it's active.



      When not active it should skip and do nothing and if it's active I need to do an action only once and then stop (so even if I have 10 active results, it will perform the action ("report" in my case) only on the first one).



      Thread flow



      active_status vars from debug response



      inactive vars



      media_id vars from debug response



      media_id



      http request where I use the counter



      enter image description here



      enter image description here



      enter image description here



      enter image description here



      enter image description here



      My action (report) request is: story_id=evE0-001-085121182-5&media_id=1021372295263777595_175887011&who=admin&reason=offensive&blogger_id=Amit even though "1021372295263777595_175887011" is not ACTIVE







      jmeter






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 12 '15 at 10:51

























      asked Jul 9 '15 at 10:42









      Amit Ronen

      69213




      69213
























          2 Answers
          2






          active

          oldest

          votes

















          up vote
          1
          down vote



          accepted










          Use :





          • User Parameters PreProcessor once as a child of a Sampler before the ForEach Controller to init RUN_ONCE to false:


          enter image description here



          and once as a child of the HTTP Request that runs on active status to set RUN_ONCE to true
          enter image description here




          • ForEach Controller with following settingsenter image description here:


          • If Controller and put in condition:




          ${__jexl2( "${status}" == "ACTIVE" && "${RUN_ONCE}" == "false")}




          enter image description here
          - Test Plan would look like this:



          enter image description here



          You counter should be in ForEachController not in If Controller as it will not increment correctly and give the ID for the correct status






          share|improve this answer























          • Where should I put the counter? I've tried this code in While: ${__jexl2( "${active_status${counter}}" == "ACTIVE" && "${counter}" < 1 )}. and put the counter under the while controller (starts with "0" and increments by 1). But it's not getting inside the while..
            – Amit Ronen
            Jul 12 '15 at 6:33










          • I managed to solve this one. The problem was with the quotes on "counter" var. So it's getting into the while controller but stops only after "counter" 1, even though the first two "active_status" are not active so it should continue to the next one
            – Amit Ronen
            Jul 12 '15 at 6:49










          • But in that case, won't it just run on all "active_status"? If if get it right, with this option, it will run on all "active_status_(number)" and make the report action on all of them which are active. I don't need to report more than once. So to explain again: Run on active_status_1 -> if active -> report and stop the loop. Only if not active -> skip to active_status_2 -> if active - > report and stop
            – Amit Ronen
            Jul 12 '15 at 9:02












          • I updated my post with screenshot trying your solution. The action (report) is done on a media which is not active .(INACTIVE_FORCED_ADMIN in this case).
            – Amit Ronen
            Jul 12 '15 at 9:59










          • Added requested screenshots
            – Amit Ronen
            Jul 12 '15 at 10:14


















          up vote
          0
          down vote













          You can use 'while controller' with a condition:



          ${__javaScript( "${some_var}" = "something" && "${some_other_var}" < "${something_else}"; )}



          One of those expressions should refer to counter, another to status.






          share|improve this answer





















            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%2f31315096%2fjmeter-break-a-loop-once-the-condition-is-met%23new-answer', 'question_page');
            }
            );

            Post as a guest
































            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote



            accepted










            Use :





            • User Parameters PreProcessor once as a child of a Sampler before the ForEach Controller to init RUN_ONCE to false:


            enter image description here



            and once as a child of the HTTP Request that runs on active status to set RUN_ONCE to true
            enter image description here




            • ForEach Controller with following settingsenter image description here:


            • If Controller and put in condition:




            ${__jexl2( "${status}" == "ACTIVE" && "${RUN_ONCE}" == "false")}




            enter image description here
            - Test Plan would look like this:



            enter image description here



            You counter should be in ForEachController not in If Controller as it will not increment correctly and give the ID for the correct status






            share|improve this answer























            • Where should I put the counter? I've tried this code in While: ${__jexl2( "${active_status${counter}}" == "ACTIVE" && "${counter}" < 1 )}. and put the counter under the while controller (starts with "0" and increments by 1). But it's not getting inside the while..
              – Amit Ronen
              Jul 12 '15 at 6:33










            • I managed to solve this one. The problem was with the quotes on "counter" var. So it's getting into the while controller but stops only after "counter" 1, even though the first two "active_status" are not active so it should continue to the next one
              – Amit Ronen
              Jul 12 '15 at 6:49










            • But in that case, won't it just run on all "active_status"? If if get it right, with this option, it will run on all "active_status_(number)" and make the report action on all of them which are active. I don't need to report more than once. So to explain again: Run on active_status_1 -> if active -> report and stop the loop. Only if not active -> skip to active_status_2 -> if active - > report and stop
              – Amit Ronen
              Jul 12 '15 at 9:02












            • I updated my post with screenshot trying your solution. The action (report) is done on a media which is not active .(INACTIVE_FORCED_ADMIN in this case).
              – Amit Ronen
              Jul 12 '15 at 9:59










            • Added requested screenshots
              – Amit Ronen
              Jul 12 '15 at 10:14















            up vote
            1
            down vote



            accepted










            Use :





            • User Parameters PreProcessor once as a child of a Sampler before the ForEach Controller to init RUN_ONCE to false:


            enter image description here



            and once as a child of the HTTP Request that runs on active status to set RUN_ONCE to true
            enter image description here




            • ForEach Controller with following settingsenter image description here:


            • If Controller and put in condition:




            ${__jexl2( "${status}" == "ACTIVE" && "${RUN_ONCE}" == "false")}




            enter image description here
            - Test Plan would look like this:



            enter image description here



            You counter should be in ForEachController not in If Controller as it will not increment correctly and give the ID for the correct status






            share|improve this answer























            • Where should I put the counter? I've tried this code in While: ${__jexl2( "${active_status${counter}}" == "ACTIVE" && "${counter}" < 1 )}. and put the counter under the while controller (starts with "0" and increments by 1). But it's not getting inside the while..
              – Amit Ronen
              Jul 12 '15 at 6:33










            • I managed to solve this one. The problem was with the quotes on "counter" var. So it's getting into the while controller but stops only after "counter" 1, even though the first two "active_status" are not active so it should continue to the next one
              – Amit Ronen
              Jul 12 '15 at 6:49










            • But in that case, won't it just run on all "active_status"? If if get it right, with this option, it will run on all "active_status_(number)" and make the report action on all of them which are active. I don't need to report more than once. So to explain again: Run on active_status_1 -> if active -> report and stop the loop. Only if not active -> skip to active_status_2 -> if active - > report and stop
              – Amit Ronen
              Jul 12 '15 at 9:02












            • I updated my post with screenshot trying your solution. The action (report) is done on a media which is not active .(INACTIVE_FORCED_ADMIN in this case).
              – Amit Ronen
              Jul 12 '15 at 9:59










            • Added requested screenshots
              – Amit Ronen
              Jul 12 '15 at 10:14













            up vote
            1
            down vote



            accepted







            up vote
            1
            down vote



            accepted






            Use :





            • User Parameters PreProcessor once as a child of a Sampler before the ForEach Controller to init RUN_ONCE to false:


            enter image description here



            and once as a child of the HTTP Request that runs on active status to set RUN_ONCE to true
            enter image description here




            • ForEach Controller with following settingsenter image description here:


            • If Controller and put in condition:




            ${__jexl2( "${status}" == "ACTIVE" && "${RUN_ONCE}" == "false")}




            enter image description here
            - Test Plan would look like this:



            enter image description here



            You counter should be in ForEachController not in If Controller as it will not increment correctly and give the ID for the correct status






            share|improve this answer














            Use :





            • User Parameters PreProcessor once as a child of a Sampler before the ForEach Controller to init RUN_ONCE to false:


            enter image description here



            and once as a child of the HTTP Request that runs on active status to set RUN_ONCE to true
            enter image description here




            • ForEach Controller with following settingsenter image description here:


            • If Controller and put in condition:




            ${__jexl2( "${status}" == "ACTIVE" && "${RUN_ONCE}" == "false")}




            enter image description here
            - Test Plan would look like this:



            enter image description here



            You counter should be in ForEachController not in If Controller as it will not increment correctly and give the ID for the correct status







            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Jul 12 '15 at 10:33

























            answered Jul 9 '15 at 20:46









            UBIK LOAD PACK

            24k43465




            24k43465












            • Where should I put the counter? I've tried this code in While: ${__jexl2( "${active_status${counter}}" == "ACTIVE" && "${counter}" < 1 )}. and put the counter under the while controller (starts with "0" and increments by 1). But it's not getting inside the while..
              – Amit Ronen
              Jul 12 '15 at 6:33










            • I managed to solve this one. The problem was with the quotes on "counter" var. So it's getting into the while controller but stops only after "counter" 1, even though the first two "active_status" are not active so it should continue to the next one
              – Amit Ronen
              Jul 12 '15 at 6:49










            • But in that case, won't it just run on all "active_status"? If if get it right, with this option, it will run on all "active_status_(number)" and make the report action on all of them which are active. I don't need to report more than once. So to explain again: Run on active_status_1 -> if active -> report and stop the loop. Only if not active -> skip to active_status_2 -> if active - > report and stop
              – Amit Ronen
              Jul 12 '15 at 9:02












            • I updated my post with screenshot trying your solution. The action (report) is done on a media which is not active .(INACTIVE_FORCED_ADMIN in this case).
              – Amit Ronen
              Jul 12 '15 at 9:59










            • Added requested screenshots
              – Amit Ronen
              Jul 12 '15 at 10:14


















            • Where should I put the counter? I've tried this code in While: ${__jexl2( "${active_status${counter}}" == "ACTIVE" && "${counter}" < 1 )}. and put the counter under the while controller (starts with "0" and increments by 1). But it's not getting inside the while..
              – Amit Ronen
              Jul 12 '15 at 6:33










            • I managed to solve this one. The problem was with the quotes on "counter" var. So it's getting into the while controller but stops only after "counter" 1, even though the first two "active_status" are not active so it should continue to the next one
              – Amit Ronen
              Jul 12 '15 at 6:49










            • But in that case, won't it just run on all "active_status"? If if get it right, with this option, it will run on all "active_status_(number)" and make the report action on all of them which are active. I don't need to report more than once. So to explain again: Run on active_status_1 -> if active -> report and stop the loop. Only if not active -> skip to active_status_2 -> if active - > report and stop
              – Amit Ronen
              Jul 12 '15 at 9:02












            • I updated my post with screenshot trying your solution. The action (report) is done on a media which is not active .(INACTIVE_FORCED_ADMIN in this case).
              – Amit Ronen
              Jul 12 '15 at 9:59










            • Added requested screenshots
              – Amit Ronen
              Jul 12 '15 at 10:14
















            Where should I put the counter? I've tried this code in While: ${__jexl2( "${active_status${counter}}" == "ACTIVE" && "${counter}" < 1 )}. and put the counter under the while controller (starts with "0" and increments by 1). But it's not getting inside the while..
            – Amit Ronen
            Jul 12 '15 at 6:33




            Where should I put the counter? I've tried this code in While: ${__jexl2( "${active_status${counter}}" == "ACTIVE" && "${counter}" < 1 )}. and put the counter under the while controller (starts with "0" and increments by 1). But it's not getting inside the while..
            – Amit Ronen
            Jul 12 '15 at 6:33












            I managed to solve this one. The problem was with the quotes on "counter" var. So it's getting into the while controller but stops only after "counter" 1, even though the first two "active_status" are not active so it should continue to the next one
            – Amit Ronen
            Jul 12 '15 at 6:49




            I managed to solve this one. The problem was with the quotes on "counter" var. So it's getting into the while controller but stops only after "counter" 1, even though the first two "active_status" are not active so it should continue to the next one
            – Amit Ronen
            Jul 12 '15 at 6:49












            But in that case, won't it just run on all "active_status"? If if get it right, with this option, it will run on all "active_status_(number)" and make the report action on all of them which are active. I don't need to report more than once. So to explain again: Run on active_status_1 -> if active -> report and stop the loop. Only if not active -> skip to active_status_2 -> if active - > report and stop
            – Amit Ronen
            Jul 12 '15 at 9:02






            But in that case, won't it just run on all "active_status"? If if get it right, with this option, it will run on all "active_status_(number)" and make the report action on all of them which are active. I don't need to report more than once. So to explain again: Run on active_status_1 -> if active -> report and stop the loop. Only if not active -> skip to active_status_2 -> if active - > report and stop
            – Amit Ronen
            Jul 12 '15 at 9:02














            I updated my post with screenshot trying your solution. The action (report) is done on a media which is not active .(INACTIVE_FORCED_ADMIN in this case).
            – Amit Ronen
            Jul 12 '15 at 9:59




            I updated my post with screenshot trying your solution. The action (report) is done on a media which is not active .(INACTIVE_FORCED_ADMIN in this case).
            – Amit Ronen
            Jul 12 '15 at 9:59












            Added requested screenshots
            – Amit Ronen
            Jul 12 '15 at 10:14




            Added requested screenshots
            – Amit Ronen
            Jul 12 '15 at 10:14












            up vote
            0
            down vote













            You can use 'while controller' with a condition:



            ${__javaScript( "${some_var}" = "something" && "${some_other_var}" < "${something_else}"; )}



            One of those expressions should refer to counter, another to status.






            share|improve this answer

























              up vote
              0
              down vote













              You can use 'while controller' with a condition:



              ${__javaScript( "${some_var}" = "something" && "${some_other_var}" < "${something_else}"; )}



              One of those expressions should refer to counter, another to status.






              share|improve this answer























                up vote
                0
                down vote










                up vote
                0
                down vote









                You can use 'while controller' with a condition:



                ${__javaScript( "${some_var}" = "something" && "${some_other_var}" < "${something_else}"; )}



                One of those expressions should refer to counter, another to status.






                share|improve this answer












                You can use 'while controller' with a condition:



                ${__javaScript( "${some_var}" = "something" && "${some_other_var}" < "${something_else}"; )}



                One of those expressions should refer to counter, another to status.







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Jul 9 '15 at 14:10









                automatictester

                1,014621




                1,014621






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f31315096%2fjmeter-break-a-loop-once-the-condition-is-met%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest




















































































                    Popular posts from this blog

                    Guess what letter conforming each word

                    Port of Spain

                    Run scheduled task as local user group (not BUILTIN)