Return-Path: X-Original-To: apmail-jmeter-user-archive@www.apache.org Delivered-To: apmail-jmeter-user-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9EC31C419 for ; Thu, 13 Jun 2013 15:20:26 +0000 (UTC) Received: (qmail 22423 invoked by uid 500); 13 Jun 2013 15:20:26 -0000 Delivered-To: apmail-jmeter-user-archive@jmeter.apache.org Received: (qmail 22403 invoked by uid 500); 13 Jun 2013 15:20:26 -0000 Mailing-List: contact user-help@jmeter.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "JMeter Users List" Delivered-To: mailing list user@jmeter.apache.org Received: (qmail 22394 invoked by uid 99); 13 Jun 2013 15:20:25 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jun 2013 15:20:25 +0000 X-ASF-Spam-Status: No, hits=1.5 required=5.0 tests=HTML_MESSAGE,RCVD_IN_DNSWL_LOW,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (nike.apache.org: domain of asp.adieu@gmail.com designates 209.85.160.44 as permitted sender) Received: from [209.85.160.44] (HELO mail-pb0-f44.google.com) (209.85.160.44) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 13 Jun 2013 15:20:19 +0000 Received: by mail-pb0-f44.google.com with SMTP id uo1so5729223pbc.17 for ; Thu, 13 Jun 2013 08:19:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=Lx61Khcg+WFpD/5e0x/3+UDx4+MP30la15TuxRMaSDU=; b=KylW7FgYZNkQ+kk2CAB24K3/zswCkHhzHK5G+5dO+h8tgPhyqAmcwjGCW5vwK462Ks IzDwL5EsIByb2OtICoNJQx8gMThFfTK673I0oxE8jOTRoboTeQ3+GorRZHyUfQ7yCfg4 8aFt4Vc80x1NvTiSlVxl7RantOXiI02iTATnBwOn/SWnEFLTORaT8rVopOsSFVsbQKZC LTlUQ6yyZXWlO7XChL25UKR/VjhdI31dZ9qHV8/c3ue2+HRXEqHkKGnVZz1QYsCbLL9L Udyk8Ri9Iw3zDO2WJXPcu38cqgbUe84CzA+tk38pXfb5sJ57kov8I8wONvd0R+OGHdBg AE6w== MIME-Version: 1.0 X-Received: by 10.66.13.8 with SMTP id d8mr3451842pac.4.1371136798478; Thu, 13 Jun 2013 08:19:58 -0700 (PDT) Received: by 10.70.103.238 with HTTP; Thu, 13 Jun 2013 08:19:58 -0700 (PDT) In-Reply-To: <7C5F515356198E45B1BD51A0D40F633B791342F0@usilms114b.ca.com> References: <7C5F515356198E45B1BD51A0D40F633B791342F0@usilms114b.ca.com> Date: Thu, 13 Jun 2013 18:19:58 +0300 Message-ID: Subject: Re: Sharing logic between thread groups From: Adrian Speteanu To: JMeter Users List Content-Type: multipart/alternative; boundary=bcaec51ddb25cfdc2a04df0aa946 X-Virus-Checked: Checked by ClamAV on apache.org --bcaec51ddb25cfdc2a04df0aa946 Content-Type: text/plain; charset=UTF-8 You can add a header manager to use the same header for all your requests. Use the header manager in a parent of all the samples that need to be in its scope. For those requests that need to over-write it, use the HM as child to those samplers. For the general question: can logic be shared between threads? It has been discussed recently, check those discussions first, maybe you find some useful tips there, or share with us what those threads don't cover. Cheers, Adrian On Thu, Jun 13, 2013 at 3:54 PM, Drach, Noa wrote: > Hello all, > > In my test I have 5 thread groups - I was wondering if it is possible to > share common logic between the thread groups. > > Basically all of my tests have user id and organization id in the headers. > For each thread that is running I am randomly selecting a user id in the > range of 1-50 and organization id in the range of 1-100. > > All this is achieved by using a Bean Shell Preprocessor that is attached > to each of the samplers. > > For each of the samplers this random editing of the header might also be > accompanied by some editing of the url as a result of the random user ID. > > By attaching a preprocessor to each sample I manage to do all this - but I > was wondering if there is some way to define some utility methods that I > can call from each Bean Shell processor and avoid repeating the logic. > > For example: > ... > HeaderManager hm = sampler.getHeaderManager(); > callMySetHeaders(hm); > // Do some specific code > > I know that it is possible to have custom functions - but my understanding > is that they only return a string - I am asking if there is a way to write > more complex code. > > Thanks, > Noa Drach > > --bcaec51ddb25cfdc2a04df0aa946--