Return-Path: Delivered-To: apmail-incubator-lucene-net-dev-archive@locus.apache.org Received: (qmail 63020 invoked from network); 13 Jan 2009 02:32:07 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jan 2009 02:32:07 -0000 Received: (qmail 16992 invoked by uid 500); 13 Jan 2009 02:32:07 -0000 Delivered-To: apmail-incubator-lucene-net-dev-archive@incubator.apache.org Received: (qmail 16966 invoked by uid 500); 13 Jan 2009 02:32:07 -0000 Mailing-List: contact lucene-net-dev-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: lucene-net-dev@incubator.apache.org Delivered-To: mailing list lucene-net-dev@incubator.apache.org Received: (qmail 16952 invoked by uid 99); 13 Jan 2009 02:32:07 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 12 Jan 2009 18:32:07 -0800 X-ASF-Spam-Status: No, hits=-0.0 required=10.0 tests=SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of tjkolev@gmail.com designates 209.85.134.185 as permitted sender) Received: from [209.85.134.185] (HELO mu-out-0910.google.com) (209.85.134.185) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 13 Jan 2009 02:32:00 +0000 Received: by mu-out-0910.google.com with SMTP id w9so6598396mue.0 for ; Mon, 12 Jan 2009 18:31:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=alyx2VLcIIFobUXfx9nG1ODyiZb2feW7TDSH+b3sEF8=; b=jToicFPOhS63GcHqKUrttW30pr9x3OhcfDYPgmPDmD22Vo6lb0aditv+ajLQspVtlb EJSeTEW6x+6g/lGBtIq0smhq+CqHuXVRXE1wfnSt7bK88tUr99eC7MFdtVxgzVbL5yNj 3dzi++fLumOFAFG+g+Lf62RxJ8c08kDsUdvJk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=aDOUU0t0ClOQnzStFU6WjtX4Ryp1pyHTsSlyOlCY6ZUGj5IJ+DWrJC5oIRlPvdaJUY q64+Ruy8qDWt8/Ku9VEDREZASPlvDoyBm3RHThityhAhMnpVy6VlV0nrirWArGRsIopC a7QdoYgyAv65KAf4viO/TuJv7lKlTxv4TPutY= Received: by 10.103.102.17 with SMTP id e17mr11080153mum.136.1231813898941; Mon, 12 Jan 2009 18:31:38 -0800 (PST) Received: by 10.103.174.14 with HTTP; Mon, 12 Jan 2009 18:31:38 -0800 (PST) Message-ID: <743c5bb40901121831j7a0e94d4m197a52a0016479c6@mail.gmail.com> Date: Mon, 12 Jan 2009 20:31:38 -0600 From: "TJ Kolev" To: lucene-net-dev@incubator.apache.org Subject: Re: TestRemoteSearchable and random port In-Reply-To: <003801c9750c$af57bd30$0e073790$@com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <743c5bb40901121312i235ccffch990142ab7baaf8eb@mail.gmail.com> <002a01c974ff$ded085e0$9c7191a0$@com> <380bd16a0901121357k32382716v95bd685185e38432@mail.gmail.com> <003401c97506$2cc26240$864726c0$@com> <743c5bb40901121455y35c3635etdf3c49d0936b2c01@mail.gmail.com> <003801c9750c$af57bd30$0e073790$@com> X-Virus-Checked: Checked by ClamAV on apache.org I just finished trying HttpChannel(0) :) I initially misread Ben's suggestion and he and you are correct: HttpChannel(0) does give you an available port. The HttpChannel() I used is of not much use. Another improvement I found while testing. The port variable is not needed (unless we decide to report on it). This works instead: private static Lucene.Net.Search.Searchable LookupRemote() { //return (Lucene.Net.Search.Searchable)Activator.GetObject(typeof(Lucene.Net.Search.Searchable), string.Format("http://localhost:{0}/RemoteSearchable", port)); return (Lucene.Net.Search.Searchable)Activator.GetObject(typeof(Lucene.Net.Search.Searchable), httpChannel.GetUrlsForUri("RemoteSearchable")[0]); } I will make a jira and attach a patch. tjk :) On Mon, Jan 12, 2009 at 5:22 PM, Digy wrote: > Hi TJ, > > I haven't tested your code yet but it seems to be a good solution. > > > And,a sample code to create a HttpChannel with a free port: > > httpChannel = new > System.Runtime.Remoting.Channels.Http.HttpChannel(0); > port = > Convert.ToInt32((httpChannel.GetUrlsForUri("")[0]).Split(new char[] { ':' > })[2].Replace("/", "")); > > DIGY > > -----Original Message----- > From: TJ Kolev [mailto:tjkolev@gmail.com] > Sent: Tuesday, January 13, 2009 12:55 AM > To: lucene-net-dev@incubator.apache.org > Subject: Re: TestRemoteSearchable and random port > > All right, > > I looked into this further and I guess I found a better solution. > Basically the server needs to be setup once for all the [Test] > methods. [SetUp] SetUp() and [TearDown] TearDown() will "bracket" each > call to a [Test] method. So I dropped those altogether. Instead I have > these: > > [TestFixtureSetUp] > public void FixtureSetup() > { > if (!serverStarted) > { > Random rnd = new > Random((int)(DateTime.Now.Ticks & 0x7fffffff)); > port = > rnd.Next(System.Net.IPEndPoint.MinPort, > System.Net.IPEndPoint.MaxPort); > Console.WriteLine("Port " + port); > httpChannel = new > System.Runtime.Remoting.Channels.Http.HttpChannel(port); > StartServer(); > } > } > > [TestFixtureTearDown] > public void FixtureTeardown() > { > try > { > > System.Runtime.Remoting.Channels.ChannelServices.UnregisterChannel(httpChann > el); > } > catch > { > } > > httpChannel = null; > } > > [TestFixtureSetUp] and [TestFixtureTearDown] methods are called only > once and "bracket" the [TestFixutre] class. So the server gets setup, > then all the [Test] methods are run, and the we do > UnregisterChannel(). > > I ran the test a whole bunch of times without a single failure. > > What do you say? > tjk :) > > P.S. HttpChannel() does not automatically get an available port. :( > > On Mon, Jan 12, 2009 at 4:36 PM, Digy wrote: >> Hi Ben, >> You are right, but it is still possible to choose a free port rather that > a >> random port which may be in use. >> >> DIGY. >> >> -----Original Message----- >> From: Ben Martz [mailto:benmartz@gmail.com] >> Sent: Monday, January 12, 2009 11:57 PM >> To: lucene-net-dev@incubator.apache.org >> Subject: Re: TestRemoteSearchable and random port >> >> Hi DIGY, >> >> That's what I thought at first as well until I realized that the SetUp >> method is explicitly choosing a random port number each time its called. > If >> it wasn't for the random port numbering I would perhaps suggest an > explicit >> call to UnregisterChannel. >> >> Cheers, >> Ben >> >> On Mon, Jan 12, 2009 at 1:51 PM, Digy wrote: >> >>> Hi TJ, >>> >>> You can open an issue on JIRA >>> (https://issues.apache.org/jira/browse/LUCENENET) and submit your > patches. >>> But as far as I can see, your patch reduces the probability of a port >>> conflict but does not solve the real problem. I think, the real problem >>> lies >>> in some previously running test cases not closing the ports > appropriately. >>> >>> DIGY >>> >>> >> -- >> 13:37 - Someone stole the precinct toilet. The cops have nothing to go on. >> 14:37 - Officers dispatched to a daycare where a three-year-old was >> resisting a rest. >> 21:11 - Hole found in nudist camp wall. Officers are looking into it. >> >> > >