E2E Testing: Run, Test and Shutdown the HTTP Server

2.0

#1

Hi guys,

I am very beginner with CircleCI and have a problem I stuck with. My task is:

  1. Run lints, unit tests, builds, etc
  2. Run HTTP server (For example npm run start)
  3. Wait when it will be ready (There can be an initialization delay so I need to make sure it ready)
  4. Run my e2e tests
  5. Shutdown the server
  6. Done

I made node script that run steps 2 - 6 but I need to do it with pure CircleCI script.
Can you please guide me in the right direction?

Thank you!


#2

That sounds OK to me!

I don’t think there is any such thing. The normal way of running commands in CircleCI is to use shell commands e.g. Bash.

However, if you have gotten this working in Node, is there any value in converting?


#3

However, if you have gotten this working in Node, is there any value in converting?

Apparently, I cannot use a script for anything that can be done with pure Circle CI config. So the way I was approached to do it is:


2. Run HTTP server (For example npm run start)
3. Ping it with wget until it ready
4. Run my e2e tests
5. Shutdown the server by killing all node processes.

Although with my approach allowed me just sit and listen to events from the HTTP server without sending endless requests until it is ready, I have to admit that wget approach is better for maintenance since does not require an additional script and CI configuration clear and straightforward.


#4

It sounds like you have written it in your head already. What are you stuck on, in particular?

The only thing there that is not trivial to do in Bash is waiting for a socket, and that is solved with this search. You could probably use wget in the wait loop as well, if you prefer (I don’t think it is necessary).


#5

Oh, sorry for the confusion. My issue solved. I just described the approach I used since you were kind in the attempt to help me.

Thanks!


#6

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.