harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Andrew Zhang" <zhanghuang...@gmail.com>
Subject Re: [classlib][luni] java.net.ServerSocketTest fails - need help
Date Mon, 25 Dec 2006 14:08:37 GMT
On 12/25/06, Mikhail Markov <mikhail.a.markov@gmail.com> wrote:
>
> > Hey Mikhail, I think I have agreed with all  your words in my previous
> > letter. We've agreed to use port 0 for most network tests. Fixed port
> number
> > is required sometimes, i.e., how do you write test for ServerSocket(int
> > port)?
> Sorry, Andrew - I did not participated in original discussion and Alexei
> in
> http://issues.apache.org/jira/browse/HARMONY-2338 said that he
> understands the final decision as we will use reserved ports numbers - so
> I've decided to re-check once again.
>
> > We'd better test ServerSocket constructor with both legal value(not
> > only 0, but also some positive numbers), and illegal value. That's where
> > fixed port number is used. Make sense? Thanks!
> Why not use ServerSocket(0) to just *obtain* some positive non-busy port
> number (and close it after port number obtaining) and after that test
> ServerSocket constructor with this obtained port number? In this case
> we'll
> not require any reserved ports at all.
> I've implemented this approach and attached the patch - could you please
> take a look at it?


Hi Mikhail, the patch is good! I agree that it's a good fix as always. :-)
But without fixed port meaning that we never test the behaviour of
ServerSocket(1000).
That's why I suggest to introduce fixed port for ServerSocket constructor
test.
My suggestion is not to discard your patch, but using your patch + fixed
port to replace current getNextPort machenism. Does it make sense? Thanks!

Thanks,
> Mikhail
>
>
> On 12/24/06, Andrew Zhang <zhanghuangzhu@gmail.com> wrote:
> >
> > On 12/24/06, Mikhail Markov <mikhail.a.markov@gmail.com> wrote:
> > >
> > > I still don't like using fixed port numbers. Moreover, some tests
> might
> > > require several ports for testing.
> > > I did not see any objections against using 0 as a port number, except
> > that
> > > some functionality should be tested with fixed port numbers.
> > > How about the following scheme for *finding* non-busy port:
> > > 1) invoke ServerSocket(0) constructor
> > > 2) get the port where ServerSocket opened the socket
> > > 3) close ServerSocket
> > > 4) use the stored port from 2-nd step for further testing (it could be
> > > Socket/ServerSocket/nio tests etc.)
> > >
> > > What do you think?
> >
> >
> > Hey Mikhail, I think I have agreed with all  your words in my previous
> > letter. We've agreed to use port 0 for most network tests. Fixed port
> > number
> > is required sometimes, i.e., how do you write test for ServerSocket(int
> > port)? We'd better test ServerSocket constructor with both legal
> value(not
> > only 0, but also some positive numbers), and illegal value. That's where
> > fixed port number is used. Make sense? Thanks!
> >
> > Thanks,
> > > Mikhail
> > >
> > > On 12/8/06, Andrew Zhang <zhanghuangzhu@gmail.com> wrote:
> > > >
> > > > On 12/8/06, Zakharov, Vasily M <vasily.m.zakharov@intel.com> wrote:
> > > > >
> > > > > Andrew,
> > > > >
> > > > > Sure, we can reserve some port, but it means that we would
> > experience
> > > > > occasional fails of the test from time to time, that's not very
> > good.
> > > >
> > > >
> > > > why would we experience occasional fails? because of port conflict?
> > > > If so, I think it doesn't happen on our build system since we know
> > some
> > > > fixed ports should be reserved.
> > > > And we'll document it in "how to run Harmony test" tutorial. I think
> > > most
> > > > developers are willing to reserve some unknown ports for running
> > Harmony
> > > > test (don't tell them to close msn/gtalk/ie/firefox... :))
> > > >
> > > > Probably we may check the port using ServerSocket before testing?
> > > > > It's acceptance, not compliance testing, look like it's not a big
> > > > > problem.
> > > > >
> > > > > Also, for all tests except the test_setReuseAddressZ(),
> > > > > we way check the port by using Socket, not ServerSocket.
> > > >
> > > >
> > > > Then how to verify Socket functionality? :)
> > > >
> > > > So, I'd suggest the following measures:
> > > > >
> > > > > - For all tests, that could use port 0, use port 0.
> > > > > By the way, is there a chance that asking port 0 would return a
> > > > > TIME_WAIT port
> > > > > that cannot be reused?
> > > >
> > > >
> > > > It's complicated... even if some java api returns a TIME_WAIT port,
> > how
> > > > can
> > > > we guarantee that the port is still  TIME_WAIT when running
> > > > setReuseAddress
> > > > code?
> > > >
> > > > - For all tests except test_setReuseAddressZ() use Socket to verify
> if
> > > > > the port is free.
> > > >
> > > >
> > > > theoretically, it doesn't 100% solve port confliction either. What
> if
> > a
> > > > port
> > > > is occupied by other application after Socket test and before test
> > code?
> > > > :)
> > > >
> > > >
> > > > - For test_setReuseAddressZ() test, use ServerSocket to verify the
> > port
> > > > > is free
> > > > > or use the fixed port number from the end of port space (6xxxx).
> > > >
> > > >
> > > > Since we have to use some fixed port, why not use it for simplicity?
> > > >
> > > > Andrew, what do you think?
> > > >
> > > >
> > > > To sum up, IMHO, reversing some ports for running test is acceptable
> > and
> > > > simple. :)
> > > >
> > > > Vasily
> > > > >
> > > > >
> > > > >
> > > > > -----Original Message-----
> > > > > From: Andrew Zhang [mailto:zhanghuangzhu@gmail.com]
> > > > > Sent: Wednesday, December 06, 2006 12:59 PM
> > > > > To: dev@harmony.apache.org
> > > > > Subject: Re: [classlib][luni] java.net.ServerSocketTest fails -
> need
> > > > > help
> > > > >
> > > > > On 12/6/06, Alexey Petrenko <alexey.a.petrenko@gmail.com> wrote:
> > > > > >
> > > > > > I do not think that reserving one of widely used ports for tests
> > is
> > > a
> > > > > good
> > > > > > idea.
> > > > > > Since user can run http server on his machine for example. And
I
> > do
> > > > > > not think that he will be happy to switch it off each time.
> > > > > >
> > > > > > I think that we can reserve some port near the end of the port
> > > space.
> > > > > > Somethong like 63527 or so.
> > > > >
> > > > >
> > > > > Exactly! Does Harmony have lucky number? :)
> > > > >
> > > > > Another approach is to try another port if ServerSocket reports
> that
> > > > > > the port is busy (I do not remember does ServerSocket throw
> > > different
> > > > > > exception for busy port or not...)
> > > > >
> > > > >
> > > > > But it's a test for ServerSocket. We have to know whether this
> port
> > is
> > > > > used
> > > > > before testing ServerSocket.
> > > > >
> > > > > For other tests, we've agreed to use port 0 to get a 100% free
> port.
> > > > > Sounds
> > > > > reasonable?
> > > > >
> > > > > SY, Alexey
> > > > >
> > > > > 2006/12/6, Tony Wu <wuyuehao@gmail.com>:
> > > > > > > I think it is reasonable if some essential configuration
> should
> > be
> > > > > > > done at first when running harmony tests, especially in
> java.net
> > .
> > > My
> > > > > > > opinion is to fix some regular used port, like 80, 8080,
etc.
> > > Users
> > > > > > > should guarantee that these ports are available when running
> > > > > testcases
> > > > > > > (we could document this in our instruction for running
test).
> > > > > > >
> > > > > > >
> > > > > > > On 12/6/06, Andrew Zhang <zhanghuangzhu@gmail.com>
wrote:
> > > > > > > > On 12/6/06, Zakharov, Vasily M <vasily.m.zakharov@intel.com>
> > > > > wrote:
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > > oh... Interesting. It's the test for ServerSocket.
Some
> > > tests
> > > > > like
> > > > > > > > > > constructor test have to test not only 0,
but also
> > specified
> > > > > port.
> > > > > > > > > > Nevertheless, I think it's ok to use port
0 for the case
> > > > > described
> > > > > > in
> > > > > > > > > > Harmony-2338. Comments?
> > > > > > > > >
> > > > > > > > > That's exactly the problem - you should test
how the
> > > > > constructors
> > > > > > > > > (and methods like bind()) handle the specified
port
> numbers,
> > > but
> > > > > for
> > > > > > > > > that you have to get those numbers fronm somewhere.
> > > > > > > >
> > > > > > > >
> > > > > > > > So shall we reserve a port for running Harmony test
and
> > document
> > > > > it?
> > > > > > > >
> > > > > > > > Using port 0 makes the test running, but reduces it's
> testing
> > > > > value.
> > > > > > > > > So it's a give&take solution.
> > > > > > > >
> > > > > > > >
> > > > > > > > Agree.
> > > > > > > >
> > > > > > > > Vasily
> > > > > > > > >
> > > > > > > > > -----Original Message-----
> > > > > > > > > From: Andrew Zhang [mailto:zhanghuangzhu@gmail.com]
> > > > > > > > > Sent: Wednesday, December 06, 2006 7:33 AM
> > > > > > > > > To: dev@harmony.apache.org
> > > > > > > > > Subject: Re: [classlib][luni]
> java.net.ServerSocketTestfails
> > > -
> > > > > need
> > > > > > > > > help
> > > > > > > > >
> > > > > > > > > On 12/6/06, Andrew Zhang <zhanghuangzhu@gmail.com>
wrote:
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > On 12/6/06, Zakharov, Vasily M <
> > vasily.m.zakharov@intel.com>
> > > > > > wrote:
> > > > > > > > > > >
> > > > > > > > > > >
> > > > > > > > > > > I've investigated the
> > > > > > > > > http://issues.apache.org/jira/browse/HARMONY-2338
> > > > > > > > > > > issue,
> > > > > > > > > > > the detailed description of the problem
is available
> at
> > > the
> > > > > JIRA
> > > > > > > > > page.
> > > > > > > > > > >
> > > > > > > > > > > Could anyone qualified in java.net
please look into it
> > and
> > > > > > suggest
> > > > > > > > > how
> > > > > > > > > > > this should be fixed?
> > > > > > > > > > >
> > > > > > > > > > > There's a problem with
> > tests.api.java.net.ServerSocketTest
> > > > > test
> > > > > > > > > design
> > > > > > > > > > > that uses "random" ports for testing
and fails when
> > those
> > > > > ports
> > > > > > > > > happen
> > > > > > > > > > > to be occupied by other applications.
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > Hi Zakharov, I think we've agreed to use
port 0 to
> select
> > a
> > > > > free
> > > > > > port
> > > > > > > > > in
> > > > > > > > > > test case.
> > > > > > > > > >
> > > > > > > > > > But we're doing this lazily. I'll fix ServerSocketTest
> > soon.
> > > > > > Thanks!
> > > > > > > > > >
> > > > > > > > >
> > > > > > > > > oh... Interesting. It's the test for ServerSocket.
Some
> > tests
> > > > > like
> > > > > > > > > constructor test have to test not only 0, but
also
> specified
> > > > > port.
> > > > > > > > > Nevertheless, I think it's ok to use port 0 for
the case
> > > > > described
> > > > > > in
> > > > > > > > > Harmony-2338. Comments?
> > > > > > > > >
> > > > > > > > > I see many apparent possible fixes for the problem,
but
> none
> > > of
> > > > > them
> > > > > > > > > > > looks good enough to implement immediately
- they all
> > have
> > > > > > drawbacks
> > > > > > > > > and
> > > > > > > > > > >
> > > > > > > > > > > I'm not a java.net guru to judge which
of those
> > drawbacks
> > > > > are
> > > > > > > > > essential
> > > > > > > > > > > and which are not.
> > > > > > > > > > >
> > > > > > > > > > > Thank you!
> > > > > > > > > > >
> > > > > > > > > > > Vasily Zakharov
> > > > > > > > > > > Intel Enterprise Solutions Software
Division
> > > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > >
> > > > > > > > > > --
> > > > > > > > > > Best regards,
> > > > > > > > > > Andrew Zhang
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > >
> > > > > > > > > --
> > > > > > > > > Best regards,
> > > > > > > > > Andrew Zhang
> > > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > >
> > > > > > > > --
> > > > > > > > Best regards,
> > > > > > > > Andrew Zhang
> > > > > > > >
> > > > > > > >
> > > > > > >
> > > > > > >
> > > > > > > --
> > > > > > > Tony Wu
> > > > > > > China Software Development Lab, IBM
> > > > > > >
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Best regards,
> > > > > Andrew Zhang
> > > > >
> > > >
> > > >
> > > >
> > > > --
> > > > Best regards,
> > > > Andrew Zhang
> > > >
> > > >
> > >
> > >
> >
> >
> > --
> > Best regards,
> > Andrew Zhang
> >
> >
>
>


-- 
Best regards,
Andrew Zhang

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message