6

I am looking to migrate from Jenkins to GitLab CI/CD. We currently use the BlazeMeter plugin for Jenkins to run GUI Functional tests on Blazemeter as part of a Jenkins job.

Unfortunately BlazeMeter doesn't have a plugin for GitLab but they do have a simple JSON API to start tests.

Because the tests can be long-running the Blazemeter API is asynchronous. One cUrl endpoint is used to start a test and another is used to poll and get the results (passing an ID returned in the first call).

What is the best way to handle this asynchronous process as part of a GitLab CI Pipeline job and what is the sample gitlab yaml?

Fred
  • 335
  • 1
  • 6
  • 22

3 Answers3

1

GitLab has webhook or pipeline trigger feature where you can invoke from where ever you want. Also blazemeter has notification via webhooks. By combining these two will solve your problem without having long running one job until test completion.

test-trigger:
  stage: test
  script:
    - # curl command to invoke test
  except:
    - triggers

test-completion:
  stage: test
  script:
    - # reporting script
  only:
   - triggers

Following resources will help you to get started.

Ruwanka De Silva
  • 3,555
  • 6
  • 35
  • 51
0

The general solution is to use a shell/cmd script to manage loops for gitlab-ci.

build:
  stage: runBlazeMeter
  script:
    - echo "START test run"
      echo "use curl to initiate test"
      COUNT=0
      while
        COUNT=$((COUNT + 1))
        echo "use curl to query test completion"
        RES=$(curl --silent https://jsonplaceholder.typicode.com/users/${COUNT} | wc -c)
        [ $RES -gt 3 ]
      do :; done
      echo "END test run"
Richard
  • 603
  • 3
  • 14
0

You can use two stages to achieve this by using artifacts to copy the ID from one stage to the next

start-test:
  stage: test
  artifacts:
    untracked: true
  script:
    - curl http://run/the/test > testid.json

test:
  stage: test
  dependencies: 
    - start-test
  script:
    - TESTID=`cat testid.json`
      while
        sleep 1000
        RES=$(curl https://test/status/${TESTID} | grep "COMPLETE")
        [ $RES -gt 0 ]
      do :; done
      echo "TEST COMPLETE"
codebreach
  • 2,155
  • 17
  • 30