What is the process for configuring simultaneous services on CircleCI for testing purposes?

My current project involves running tests with Jasmine and WebdriverIO, which I want to automate using CircleCI. As someone new to testing, I'm a bit unsure of the process.

Here's what I've gathered so far:

  • To run the tests, I use npm test
  • A selenium server needs to be on port 4444 (I can initiate this with npm start)
  • The application should be accessible on port 80 (which I can set up with another npm command)
  • Once the tests are complete, I return to the command line, but the other services (on p4444 and p80) continue to run

However, there are still some aspects that puzzle me:

  • Locally, I have to utilize 3 terminals simultaneously for these tasks. Can this be simplified in CircleCI?
  • If yes, how can I determine when p4444 and p80 are ready for testing, or stop them once testing is finished?
  • Is my difficulty related to Docker or CircleCI?

Answer №1

To provide clarity in addressing your inquiries, I will assign labels to each of the commands you mentioned:

  1. Executing tests: npm test
  2. Starting Selenium: npm start selenium
  3. Running your app: npm start app

Questions/Answers:

When running locally, these commands require 3 terminals simultaneously - is there a way to achieve this on CircleCI?

Absolutely. Simply initiate a process with the background parameter set to true

For instance, starting Selenium in the background can be done as follows:

    - run:
        name: Start Selenium in background 
        command: |
          npm start selenium
        background: true

Before utilizing a process but after initiating it, ensure that the process is ready and running on the designated port.

    - run:
        name: Waiting for Selenium server to be ready
        command: |
          for i in `seq 1 10`;
          do
            nc -z localhost 4444 && echo Success && exit 0
            echo -n .
            sleep 1
          done
          echo Failed waiting for Selenium && exit 

Note that by replacing 4444 in the above command, you can wait for a process on a different port.

How do I determine when p4444 and p80 are prepared for testing, or how can they be terminated once the tests are completed?

Your CircleCi instructions might resemble the following:

     - run:
        name: Start Selenium in background 
        command: |
          npm start selenium
        background: true
    - run:
        name: Start App in background 
        command: |
          npm start app
        background: true

    - run:
        name: Waiting for Selenium server to be ready
        command: |
          for i in `seq 1 10`;
          do
            nc -z localhost 4444 && echo Success && exit 0
            echo -n .
            sleep 1
          done
          echo Failed waiting for Selenium && exit 

      - run:
        name: Waiting for App server to be ready
        command: |
          for i in `seq 1 10`;
          do
            nc -z localhost 80 && echo Success && exit 0
            echo -n .
            sleep 1
          done
          echo Failed waiting for Selenium && exit 

   - run:
        name: Run Tests 
        command: |
          npm test 

You raised a separate concern about halting the processes on ports 4444 and 80 once the tests conclude. Generally, this isn't necessary as upon finishing the test job, the container will be removed and the auxiliary applications will cease operation.

However, if you wish to halt those processes to proceed with additional job steps, you can execute kill commands (further details available upon request).

Is my issue attributed to Docker or CircleCI?

It appears to be more of a challenge in comprehending how to execute a sequence of commands within CircleCi.

By adhering to the aforementioned steps, you should be able to accomplish your objectives successfully.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Tips on how to increase and update the index value by 2 within an ngFor loop while maintaining a fixed format

I have a specific template layout that displays only two items in each row as shown below. I want to use the ngFor directive to iterate through them: <div class="row" *ngFor="let item of cityCodes; let i = index"> <div class="col-6" (click)= ...

Is there a way to swap out multiple characters within a string when using ng-repeat in AngularJS?

How can I replace multiple characters in a string using ng-repeat in AngularJS? I've tried the following code, but it's not working. I need to remove #, _, and . from the strings in my list. How can I achieve this in AngularJS? <body> &l ...

Cross-component communication in Angular

I'm currently developing a web-based application using angular version 6. Within my application, there is a component that contains another component as its child. In the parent component, there is a specific function that I would like to invoke when ...

Choose RadioButton using Selenium in Python

When I visit , I encountered a problem while trying to set filters to collect data. Specifically, I wanted to set the filter time to "Display time only" and the filter importance to 2 and 3 bulls. However, when I attempted to use the script provided below, ...

Preparing data before using Kendo UI upload function is essential

I need to pass a data (specifically a GUID) to the upload method of the kendoUpload, so that a particular MVC Controller action method can receive this data each time the upload occurs. $("#propertyAttachmentUpload").kendoUpload({ async: { ...

Guide to showcasing images dynamically within a table

I am currently working on a dynamic table that updates its data using a script. My goal is to also display corresponding images of the groups next to their names in the table. Whenever the group names change, I want the images to change as well. The funct ...

Leveraging batchWriteItem with dynamodb

I am trying to utilize batchWriteItem in my DynamoDB to add data to two tables: candidate table and user table. The formatted query is shown below: var user = { userid: usrid, role: 'candidate', password: vucrypt.encryptp ...

"Redirecting to an HTML page from the POST method is not supported in the Flask backend and Vanilla JS frontend setup

Utilizing the selected dropdown value from the frontend to perform calculations on the backend, resulting in an HTML page being returned. It's worth noting that no response is needed from the POST method, such as using return jsonify. Currently, I am ...

AngularJS continues to display an "Invalid Request" message whenever the requested resource is unavailable

When I try to fetch a group of images through AJAX and exhibit them on the page using ng-repeat, an issue arises with the image source tags. These tags send incorrect requests to the server before the collection is retrieved, leading to error messages in t ...

Error 403: ACCESS DENIED - The server comprehended the inquiry, yet declines to carry it out

Encountering a persistent 403 error when making an AJAX call to an API. This issue is specific to Microsoft Edge, while other browsers like IE, Chrome, Firefox, and Safari work without any errors. The page doesn't utilize bootstrap, as there have be ...

Is it possible to create a component with a button that triggers the rendering of a different component?

I am struggling to implement an 'edit' button within a component that, upon clicking, should display a separate component known as a 'client edit modal'. I'm facing challenges in figuring out how to achieve this functionality. The ...

Difficulty with automating tests using selenium in Linux: Unable to automatically close Firefox browser

When conducting automation testing for web GUI in Linux using Selenium (Selenium RC), I encountered an issue. While running Selenium tests on Windows yielded successful results with Firefox closing automatically after completing the test, the same could no ...

Ways to direct to a specific div upon clicking an anchor tag following a page reload?

<a href="#goto">Link 1</a> <div id="goto">DIV</div> Whenever I click on the anchor tag, my webpage reloads and displays a new div with the ID of goto. This div was previously hidden but is now visible at the bottom of the page. I ...

Implement the insertion of JSON items in real-time by leveraging the power of Angular JS and

I'm facing a challenge trying to insert JSON items into a dynamic list: The structure of my JSON file is as follows: [ { "id":"34", "City":"New York", "Country":"USA" }, { "id":"22", "City":"Las vegas", "Country":"USA" }, { "id":"44", "City":"Paris" ...

Are there any instances where CSS is overlooking certain HTML elements?

In the following HTML code snippet, the presence of the element with class ChildBar is optional: <div class="Parent"> <div class="ChildFoo"></div> <div class="ChildBar"></div> <!-- May ...

What's the issue with reducers receiving a Function instead of an Object in Redux?

I encountered an error in my react and redux project but I am unable to figure out how to fix it. Here is the error message: The reducer received unexpected type "Function" as the previous state. It was expecting an object with keys: "posts", "sidebar" ...

Obtain the result of two "Synchronous" nested queries using Express and Mongoose

I need to fetch an array of elements structured like this: ApiResponse = [ {_id: 1, name: Mike, transactions: 5}, {_id: 2, name: Jhon, Transactions: 10} ] The user data is retrieved from a query on the "Users" schema, while the tr ...

Can a JavaScript function spontaneously run without being called upon?

<a onclick="determineCountry(data)" class="installbtn">Install</a> My goal is to have the user redirected to one of three sites based on their location when they click the button above. However, there seems to be an issue with the script below ...

Having trouble inserting an image using Vue?

I am having trouble understanding why only the first image loads, while the others do not. 1. <img :src="require('../assets/batatas.jpg')" :alt="item.title" /> 2. <img :src="'../assets/batatas.jpg'" ...

I am looking to showcase images beside individuals' names or photos on my website in a vertical arrangement, similar to how it is done on Facebook

Looking for suggestions on how to display images uploaded by users on my webpage in a way similar to Facebook, with the user's photo displayed beside each image. Any recommendations or website links would be greatly appreciated. Thanks, Santosh Sahu ...