mcdcorp / opentest

Open source test automation tool for web applications, mobile apps and APIs
https://getopentest.org
MIT License
447 stars 107 forks source link

Template is not found when started from WebAPI #517

Closed TripleG closed 2 years ago

TripleG commented 2 years ago

Hi,

When I try to start a new template session using WebAPI from Jenkins pipeline(using httpRequest step), I am getting error response from OpenTest Server that template is not found. But the template is existing.

From Jenkins:

debug request: [validResponseCodes:100:599, url:http://localhost:3000/api/session, httpMode:POST, contentType:APPLICATION_JSON, requestBody:
                                {
                                    "actorTags": "windows-chrome",
                                    "environment": "us-dev",
                                    "sessionLabel": "test_template_1[us-dev, windows, chrome]",
                                    "template":{
                                        "path": ".",
                                        "name": "test_template_1"
                                    }
                                }
                            ]

Result is:

HttpMethod: POST
URL: http://localhost:3000/api/session
Content-Type: application/json
Sending request to url: http://localhost:3000/api/session
Response Code: HTTP/1.1 400 Bad Request
Success: Status code 400 is in the accepted range: 100:599
[Pipeline] echo
400
[Pipeline] echo
Template file test_template_1 was not found

If I execute the same request, but from Postman, the template is found and session is created. Jenkins Server, Jenkins Node and OpenTest server are running on the same machine.

Any idea what is going on?

adrianth commented 2 years ago

Are you sure that the request payload sent using the HttpRequest action is identical with the one you're sending with Postman? One error I've seen people make in the past is ignoring capitalization of file names when running OpenTest on a Linux OS. I have just reviewed the code that deals with retrieving the session template data and I don't see what could be the root cause for this behavior. One thing that I would do is compare the exact contents of the HTTP requests that you are making with HttpRequest and Postman (because there's clearly something that's different between the two). Once you find the difference you'll likely be able to understand the reason for the error.

And just to state what you probably know already - the error message you're getting means that the OpenTest server expects to find the template in a file called templates/test_template_1.yaml in the root of your test repo. Please make sure that file exists in there with the correct capitalization.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.