diff mbox

Make browser tests work again

Message ID 20170701040651.1019-1-dja@axtens.net
State Accepted
Headers show

Commit Message

Daniel Axtens July 1, 2017, 4:06 a.m. UTC
Save us the embarassement of releasing v2 with broken tests.

Signed-off-by: Daniel Axtens <dja@axtens.net>
---
 patchwork/tests/browser.py | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

Comments

Stephen Finucane July 3, 2017, 7:38 p.m. UTC | #1
On Sat, 2017-07-01 at 14:06 +1000, Daniel Axtens wrote:
> Save us the embarassement of releasing v2 with broken tests.
> 
> Signed-off-by: Daniel Axtens <dja@axtens.net>
> ---
>  patchwork/tests/browser.py | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/patchwork/tests/browser.py b/patchwork/tests/browser.py
> index 38413d5130cd..921b5d4af033 100644
> --- a/patchwork/tests/browser.py
> +++ b/patchwork/tests/browser.py
> @@ -30,6 +30,7 @@ from selenium.common.exceptions import (
>      TimeoutException)
>  from selenium import webdriver
>  from selenium.webdriver.support.ui import WebDriverWait
> +from selenium.webdriver.chrome.options import Options
>  
>  
>  class Wait(WebDriverWait):
> @@ -110,8 +111,15 @@ class SeleniumTestCase(StaticLiveServerTestCase):
>          if self.browser == 'firefox':
>              self.selenium = webdriver.Firefox()
>          if self.browser == 'chrome':
> +            chrome_options = Options()
> +            # chrome's aggressive sandboxing doesn't work well with
> +            # docker so disable the sandbox. We're only looking at our
> +            # own site so it should be safe enough
> +            chrome_options.add_argument("--no-sandbox")
> +            driver = webdriver.Chrome(chrome_options=chrome_options)

Is this line supposed to be here? It does the same thing as the line below
minus the service_args, and isn't used anywhere.

>              self.selenium = webdriver.Chrome(
> -                service_args=['--verbose', '--log-path=selenium.log']
> +                service_args=['--verbose', '--log-path=selenium.log'],
> +                chrome_options=chrome_options
>              )
>  
>          mkdir(self._SCREENSHOT_DIR)
Daniel Axtens July 3, 2017, 10:38 p.m. UTC | #2
Stephen Finucane <stephen@that.guru> writes:

> On Sat, 2017-07-01 at 14:06 +1000, Daniel Axtens wrote:

>> Save us the embarassement of releasing v2 with broken tests.

>> 

>> Signed-off-by: Daniel Axtens <dja@axtens.net>

>> ---

>>  patchwork/tests/browser.py | 10 +++++++++-

>>  1 file changed, 9 insertions(+), 1 deletion(-)

>> 

>> diff --git a/patchwork/tests/browser.py b/patchwork/tests/browser.py

>> index 38413d5130cd..921b5d4af033 100644

>> --- a/patchwork/tests/browser.py

>> +++ b/patchwork/tests/browser.py

>> @@ -30,6 +30,7 @@ from selenium.common.exceptions import (

>>      TimeoutException)

>>  from selenium import webdriver

>>  from selenium.webdriver.support.ui import WebDriverWait

>> +from selenium.webdriver.chrome.options import Options

>>  

>>  

>>  class Wait(WebDriverWait):

>> @@ -110,8 +111,15 @@ class SeleniumTestCase(StaticLiveServerTestCase):

>>          if self.browser == 'firefox':

>>              self.selenium = webdriver.Firefox()

>>          if self.browser == 'chrome':

>> +            chrome_options = Options()

>> +            # chrome's aggressive sandboxing doesn't work well with

>> +            # docker so disable the sandbox. We're only looking at our

>> +            # own site so it should be safe enough

>> +            chrome_options.add_argument("--no-sandbox")

>> +            driver = webdriver.Chrome(chrome_options=chrome_options)

>

> Is this line supposed to be here? It does the same thing as the line below

> minus the service_args, and isn't used anywhere.


Ah oops, no - sorry - copy-paste mishap.

Good catch!

Regards,
Daniel

>

>>              self.selenium = webdriver.Chrome(

>> -                service_args=['--verbose', '--log-path=selenium.log']

>> +                service_args=['--verbose', '--log-path=selenium.log'],

>> +                chrome_options=chrome_options

>>              )

>>  

>>          mkdir(self._SCREENSHOT_DIR)
Stephen Finucane July 4, 2017, 8:15 a.m. UTC | #3
On Tue, 2017-07-04 at 08:38 +1000, Daniel Axtens wrote:
> Stephen Finucane <stephen@that.guru> writes:
> 
> > On Sat, 2017-07-01 at 14:06 +1000, Daniel Axtens wrote:
> > > Save us the embarassement of releasing v2 with broken tests.
> > > 
> > > Signed-off-by: Daniel Axtens <dja@axtens.net>
> > > ---
> > >  patchwork/tests/browser.py | 10 +++++++++-
> > >  1 file changed, 9 insertions(+), 1 deletion(-)
> > > 
> > > diff --git a/patchwork/tests/browser.py b/patchwork/tests/browser.py
> > > index 38413d5130cd..921b5d4af033 100644
> > > --- a/patchwork/tests/browser.py
> > > +++ b/patchwork/tests/browser.py
> > > @@ -30,6 +30,7 @@ from selenium.common.exceptions import (
> > >      TimeoutException)
> > >  from selenium import webdriver
> > >  from selenium.webdriver.support.ui import WebDriverWait
> > > +from selenium.webdriver.chrome.options import Options
> > >  
> > >  
> > >  class Wait(WebDriverWait):
> > > @@ -110,8 +111,15 @@ class SeleniumTestCase(StaticLiveServerTestCase):
> > >          if self.browser == 'firefox':
> > >              self.selenium = webdriver.Firefox()
> > >          if self.browser == 'chrome':
> > > +            chrome_options = Options()
> > > +            # chrome's aggressive sandboxing doesn't work well with
> > > +            # docker so disable the sandbox. We're only looking at our
> > > +            # own site so it should be safe enough
> > > +            chrome_options.add_argument("--no-sandbox")
> > > +            driver = webdriver.Chrome(chrome_options=chrome_options)
> > 
> > Is this line supposed to be here? It does the same thing as the line below
> > minus the service_args, and isn't used anywhere.
> 
> Ah oops, no - sorry - copy-paste mishap.
> 
> Good catch!

Cool cool. I've this applied sans this line now.

Reviewed-by: Stephen Finucane <stephen@that.guru>
diff mbox

Patch

diff --git a/patchwork/tests/browser.py b/patchwork/tests/browser.py
index 38413d5130cd..921b5d4af033 100644
--- a/patchwork/tests/browser.py
+++ b/patchwork/tests/browser.py
@@ -30,6 +30,7 @@  from selenium.common.exceptions import (
     TimeoutException)
 from selenium import webdriver
 from selenium.webdriver.support.ui import WebDriverWait
+from selenium.webdriver.chrome.options import Options
 
 
 class Wait(WebDriverWait):
@@ -110,8 +111,15 @@  class SeleniumTestCase(StaticLiveServerTestCase):
         if self.browser == 'firefox':
             self.selenium = webdriver.Firefox()
         if self.browser == 'chrome':
+            chrome_options = Options()
+            # chrome's aggressive sandboxing doesn't work well with
+            # docker so disable the sandbox. We're only looking at our
+            # own site so it should be safe enough
+            chrome_options.add_argument("--no-sandbox")
+            driver = webdriver.Chrome(chrome_options=chrome_options)
             self.selenium = webdriver.Chrome(
-                service_args=['--verbose', '--log-path=selenium.log']
+                service_args=['--verbose', '--log-path=selenium.log'],
+                chrome_options=chrome_options
             )
 
         mkdir(self._SCREENSHOT_DIR)