Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

problem with Parallelization Options #353

Open
awasall opened this issue Apr 20, 2021 · 33 comments
Open

problem with Parallelization Options #353

awasall opened this issue Apr 20, 2021 · 33 comments

Comments

@awasall
Copy link

awasall commented Apr 20, 2021

Hello,
I'm having trouble with the docker command for the parallelize option.
I configured the browser, the platform and a specific version in ac. by launching the command I passed it -e PABOT_OPTIONS = "- argumentfile chrome_config.txt"

*here is the command to run
docker run --rm -u root --shm-size=1g -v ${PWD}/reports:/opt/robotframework/reports:Z -v ${PWD}:/opt/robotframework/tests:Z -e PABOT_OPTIONS="--argumentfile chrome_config.txt" sonatel_rbfwk:latest

here is the file resource.robot
`
** Settings ***
Library SeleniumLibrary
@{_tmp}
... browserName: ${browserName},
... platform: ${platform},
... version: ${version},
... name: ${SUITE_NAME},
... build: Python-Robot-Selenium-VDC

${browser} ${browserName}
${capabilities} ${EMPTY.join(${_tmp})}
${remote_url} https://saucelab

*** Keywords ***

Open login page
Open browser https://www.saucedemo.com/v1/ browser=${browser}
... remote_url=${remote_url}
... desired_capabilities=${capabilities}

Open inventory page
Open browser https://www.saucedemo.com/v1/inventory.html browser=${browserName}
... remote_url=${remote_url}
... desired_capabilities=${capabilities}

Login As Standard User

Input text  id:user-name  standard_user
Input text  id:password  secret_sauce
Click button  class:btn_action

Login As Invalid User

Input text  id:user-name  invalid
Input text  id:password  invalid
Click button  class:btn_action

Add Item To Cart

Click button  class:btn_primary

Remove Item From Cart

Click button  class:btn_secondary

Has Items In Cart

Page should contain element  class:shopping_cart_badge

End Session
Run Keyword If '${TEST_STATUS}'== 'PASS' Execute Javascript sauce:job-result=passed
... ELSE Execute Javascript sauce:job-result=failed
Close Browser`

*Here is the file txt
--variable browserName:chrome --variable platform:windows 10 --variable version:latest

@awasall
Copy link
Author

awasall commented Apr 20, 2021

this is the error 👍

[ ERROR ] Error in file '/opt/robotframework/tests/resource.robot': Setting variable '${browser}' failed: Variable '${browserName}' not found. [ ERROR ] Error in file '/opt/robotframework/tests/resource.robot': Setting variable '@{_tmp}' failed: Variable '${browserName}' not found.

@UltimateDogg
Copy link
Collaborator

UltimateDogg commented Apr 20, 2021

since you are using the default ROBOT_THREADS of 1 you will not be actually using pabot or its options env. So you can either use ROBOT_OPTIONS instead of PABOT_OPTIONS (since you dont have any pabot specific things it doesnt matter), or set ROBOT_THREADS to > 1 and keep the same command.

@awasall
Copy link
Author

awasall commented Apr 20, 2021

If I need it because I have three txt files,
the first is chrome_config.txt

--variable browserName:chrome --variable platform:windows 10 --variable version:latest

the second: firefox_config.txt
--variable browserName:firefox --variable platform:OS X 10.14 --variable version:latest

the third: ie_config.txt
--variable browserName:internet explorer --variable platform:windows 10 --variable version:latest

I want to run these three configuration files at the same time i.e. parallelization I hope you can understand me

@awasall
Copy link
Author

awasall commented Apr 20, 2021

if I understand correctly le ROBOT_OPTIONS is to tag the test

@UltimateDogg
Copy link
Collaborator

something like this should work docker run --rm -u root --shm-size=1g -v ${PWD}/reports:/opt/robotframework/reports:Z -v ${PWD}:/opt/robotframework/tests:Z -e ROBOT_THREADS=4 -e PABOT_OPTIONS="--argumentfile1 chrome_config.txt --argumentfile2 firefox_config.txt --argumentfile3 ie_config.txt" ppodgorsek/robot-framework:latest

@awasall
Copy link
Author

awasall commented Apr 20, 2021

but locally without the use of docker everything is ok but with docker I have problems
I had done it but I have this error

[ ERROR ] Opening argument file 'chrome_config.txt' failed: [Errno 2] No such file or directory: 'chrome_config.txt'

@UltimateDogg
Copy link
Collaborator

well where in the docker container is the file? if its in the /opt/robotframework/tests folder do
docker run --rm -u root --shm-size=1g -v ${PWD}/reports:/opt/robotframework/reports:Z -v ${PWD}:/opt/robotframework/tests:Z -e ROBOT_THREADS=4 -e PABOT_OPTIONS="--argumentfile1 /opt/robotframework/tests/chrome_config.txt --argumentfile2 /opt/robotframework/tests/firefox_config.txt --argumentfile3 /opt/robotframework/tests/ie_config.txt" ppodgorsek/robot-framework:latest

@awasall
Copy link
Author

awasall commented Apr 20, 2021

It is the command that i run locally and and it works

pabot --argumentfile1 chrome_config.txt --argumentfile2 firefox_config.txt --argumentfi
le3 ie_config.txt Tests

@awasall
Copy link
Author

awasall commented Apr 20, 2021

thank you the last command line that you sent me helped me and it is working
Thanks

@UltimateDogg
Copy link
Collaborator

👍 glad it worked

@awasall
Copy link
Author

awasall commented Jul 26, 2021

Hello,
I have another problem with the parallelization

@awasall
Copy link
Author

awasall commented Jul 26, 2021

I have two test files, one for the recipe environment and the other for the preproduction environment and I want to run them as desired with parallel browsers but once I run the command I have an error No such file or directory

Here is the command line
docker run --rm -u root --shm-size=1g -v ${PWD}/reports:/opt/robotframework/reports:Z -v ${PWD}/Tests_Recette:/opt/robotframework/tests:Z -e ROBOT_THREADS=4 -e PABOT_OPTIONS="--argumentfile /opt/robotframework/tests/chrome_config.txt" -e ENVIRONMENT=rec -e ROBOT_OPTIONS="--include TA_01" robot-framework

@awasall
Copy link
Author

awasall commented Jul 26, 2021

The error is Opening argument file '/opt/robotframework/tests/chrome_config.txt' failed: [Errno 2] No such file or directory: '/opt/robotframework/tests/chrome_config.txt'

@ppodgorsek
Copy link
Owner

Are you sure ${PWD}/Tests_Recette is correctly replaced by its full path when mounted? Could you try replacing ${PWD} by the correct path and see if that works please?

@awasall
Copy link
Author

awasall commented Jul 26, 2021

When I do ${PWD} only, It will not be able to make a choice on a test file so it will run all the tests that are in recipe and preprod as well

my pipeline is like that

`pipeline {
agent {
      label 'test-autotion'
  }
  parameters{
choice(name: 'ENVIRONMENT', choices: ['rec', 'preprod'], description: 'Pick one environnement')
choice(name: 'BROWSER', choices: ['chrome_config', 'firefox_config', 'ie_config'], description: 'Pick one Browser')
choice(name: 'Tests', choices: ['Tests_Preprod', 'Tests_Recette'], description: 'Pick one tests')




}
    stages {
         stage('intialize') {
              steps {
                sh 'echo "PATH= ${PATH}"'
              }
            }
        stage('Execute Tests') {
            steps{
                  sh 'docker run --rm -u root --shm-size=1g -v ${PWD}/reports:/opt/robotframework/reports:Z -v ${PWD}/${Tests}:/opt/robotframework/tests:Z -e ROBOT_THREADS=4 -e PABOT_OPTIONS="--argumentfile /opt/robotframework/tests/${BROWSER}.txt"  -e ENVIRONMENT=${ENVIRONMENT} -e ROBOT_OPTIONS="--include  TA_01" robot-framework:'
            }
        }`

@ppodgorsek
Copy link
Owner

The ${PWD} syntax is for Windows. As you're running it in a shell script, please try using `pwd` instead.

@awasall
Copy link
Author

awasall commented Jul 26, 2021

I did it but I have the same error

@awasall
Copy link
Author

awasall commented Jul 26, 2021

Can you help me @UltimateDogg and @ppodgorsek

@awasall
Copy link
Author

awasall commented Jul 26, 2021

I think the problem arises when I add the test folder on 'pwd' the volume mount does not take the other folders and files

@ppodgorsek ppodgorsek reopened this Jul 26, 2021
@ppodgorsek
Copy link
Owner

ppodgorsek commented Jul 26, 2021

The No such file or directory errors are usually due to:

  • a wrong path,
  • wrong file permissions.

If the former is good, I'd try checking the latter by making sure:

  • read (r) permissions are granted on those files for user/group/other,
  • traversal (x) permissions are granted on the folders for user/group/other.

PS: Next time you comment on a closed ticket, could you reopen it at the same time please? If you can't reopen it, it would probably be best to simply open a new ticket. It makes it much easier to track, otherwise it gets lost.

@awasall
Copy link
Author

awasall commented Jul 26, 2021

Sorry I didn't have the possibility to reopen it

@awasall
Copy link
Author

awasall commented Jul 26, 2021

if I put pwdonly without adding the pwd / Tests_Recette I will have no problem with no such file or direcrory on the other hand if I add it I have problems but at the level of the chrome config.txt file

@ppodgorsek
Copy link
Owner

Is chrome_config.txt inside the Tests_Recette/ folder, or at the same level?

@awasall
Copy link
Author

awasall commented Jul 26, 2021

at the same level

@ppodgorsek
Copy link
Owner

Well, I guess you have your answer in that case! :)
You're mounting Tests_Recette/, the chrome_config.txt file therefore cannot be found within it.

I'd suggest keeping your `pwd`/Tests_Recette/ mount and also mounting chrome_config.txt separately.

@awasall
Copy link
Author

awasall commented Jul 26, 2021

I tried to put it in but when I do it I have other concerns i.e. it does not see the files which are in resources but still I test what you just told me

@awasall
Copy link
Author

awasall commented Jul 26, 2021

I did it but it doesn't see the files that are in resources

[ ERROR ] Error in file '/opt/robotframework/tests/Alertes.robot' on line 2: Resource file '../Resources/common.robot' does not exist.
[ ERROR ] Error in file '/opt/robotframework/tests/Alertes.robot' on line 3: Resource file '../Resources/AlertesKeyword.robot' does not exist.

@ppodgorsek
Copy link
Owner

It's exactly the same problem. You need to remember what Docker has access to.
In that case, ../Resources/ means /opt/robotframework/Resources/ in the container, which does not exist.

@awasall
Copy link
Author

awasall commented Jul 26, 2021

I didn't have this problem before

@ppodgorsek
Copy link
Owner

I'm sorry to say but, with the screenshot you sent, it is simply impossible that you had access to Resources when mounting Tests_Recette, no matter how hard you try, that's not how Docker works.

@awasall
Copy link
Author

awasall commented Jul 26, 2021

OKAY

@awasall
Copy link
Author

awasall commented Jul 26, 2021

@ppodgorsek I fixed the problems with these directories but another one appears as

`==============================================================================
Tests

Tests.Login

000_Authentification :: Acceder a l application Radar | FAIL |
ValueError: too many values to unpack (expected 2)`

@ppodgorsek
Copy link
Owner

This issue seems related to your tests.
A quick online search shows for example: https://stackoverflow.com/questions/42760864/too-many-values-to-unpack-robotframework-rest-api

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants