1. quali/torque@1.1.0

quali/torque@1.1.0

Partner
Sections
This orb integrates Torque into your CI/CD pipeline. You can use the available build tasks to create a sandbox from any blueprint, start your tests and end the sandbox when finished. To use this orb you need to have an account in Torque and API token
Created: November 18, 2021Version Published: June 23, 2022Releases: 5
Org Usage:
< 25

Orb Quick Start Guide

Use CircleCI version 2.1 at the top of your .circleci/config.yml file.

1 version: 2.1

Add the orbs stanza below your version, invoking the orb:

1 2 orbs: torque: quali/torque@1.1.0

Use torque elements in your existing workflows and jobs.

Opt-in to use of uncertified orbs on your organization’s Security settings page.

Usage Examples

fetch-info

Start sandbox, echo its full description, stop sandbox

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 version: '2.1' orbs: torque: quali/torque@1.1 jobs: build: docker: - image: circleci/ruby:2.4.1 steps: - torque/start-sandbox: blueprint: my-application inputs: '{''AWS_INSTANCE_TYPE'': ''m5.large''}' sandbox-name: test-sandbox - run: command: echo "Sandbox ID is ${SANDBOX_ID}" name: Fetch Details - torque/end-sandbox: sandbox-id: SANDBOX_ID workflows: easy: jobs: - build

test-app

This example demonstrates how you can build and test your app using Torque Orb. First build app and publish it to s3 bucket. Than deploy Torque Sandbox with your new application as an artifact parameter and do some testing against the endpoint of your deployed application.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 version: '2.1' orbs: aws-s3: circleci/aws-s3@1.0.11 torque: quali/torque@1.1 jobs: build-and-publish: docker: - image: circleci/ruby:2.4.1 steps: - checkout - run: command: | mkdir -p workspace tar -zcf my-webapp.latest.tar.gz -C my_app/ . name: Archive app - aws-s3/copy: from: my-webapp.latest.tar.gz to: s3://my-webapp-artifacts/latest/ workflows: leadeasy: jobs: - build-and-publish - torque/sandbox: blueprint: my-web-application inputs: '{''AWS_INSTANCE_TYPE'': ''m5.large''}' name: Test Application requires: - build-and-publish sandbox-name: test-sandbox steps: - run: echo "Do some testing here" - run: command: | echo "Getting sandbox details" echo "You can process the json with jq and perform some tests" echo "${SANDBOX_DETAILS}"

Jobs

sandbox

Run your build scenario once sandbox environment is ready.

Show job Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
blueprint
Name of the blueprint used for creating a Torque sandbox.
Yes
-
string
image
The name of image
No
circleci/python
string
inputs
String with the list of inputs. Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
No
'{}'
string
sandbox-name
Name of sandbox.
No
circleci-orb-sandbox
string
space
Name of Torque space
No
TORQUE_SPACE
env_var_name
steps
Steps to execute once the Torque Sandbox is available
Yes
-
steps
tag
The image version tag
No
latest
string
torque-token
Name of environment variable containing Torque API Token
No
TORQUE_TOKEN
env_var_name
torque-url
URL of Torque Server
No
TORQUE_SERVER
env_var_name

Commands

end-sandbox

Stops Torque sandbox environment

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
sandbox-id
Environment variable with the ID of the sandbox
No
SANDBOX_ID
env_var_name
space
Name of Torque space
No
TORQUE_SPACE
env_var_name
torque-token
Name of environment variable containing Torque API Token
No
TORQUE_TOKEN
env_var_name
torque-url
URL of Torque Server
No
TORQUE_SERVER
env_var_name

start-sandbox

Launches Torque Sandbox from a blueprint

Show command Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
blueprint
Name of the blueprint used for creating a Torque sandbox.
No
''
string
duration
Duration (ISO 8601), after which Torque will stop the deployment
No
PT2H
string
inputs
String with the list of inputs. Json format {'key1': 'value1', ..., 'keyN': 'valueN'}
No
'{}'
string
sandbox-details-variable
The name of environment variable which will be used to store full information about sandbox
No
SANDBOX_DETAILS
string
sandbox-id-variable
The name of environment variable which will be used to store sandbox id
No
SANDBOX_ID
string
sandbox-name
Name of sandbox.
No
circleci-orb-sandbox
string
space
Name of Torque space
No
TORQUE_SPACE
env_var_name
timeout
Timeout for this step in minutes. If the sandbox will not be ready when the timeout is reached, Torque will abort the deployment
No
30
integer
torque-token
Name of environment variable containing Torque API Token
No
TORQUE_TOKEN
env_var_name
torque-url
URL of Torque Server
No
TORQUE_SERVER
env_var_name

Executors

default

The sample executor. Any executor with curl pre-installed can be used instead

Show executor Source
PARAMETER
DESCRIPTION
REQUIRED
DEFAULT
TYPE
image
The name of image
No
circleci/python
string
tag
The image version tag
No
latest
string

Orb Source

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 # This code is licensed from CircleCI to the user under the MIT license. # See here for details: https://circleci.com/developer/orbs/licensing version: 2.1 description: | This orb integrates Torque into your CI/CD pipeline. You can use the available build tasks to create a sandbox from any blueprint, start your tests and end the sandbox when finished. To use this orb you need to have an account in Torque and API token display: home_url: https://www.quali.com/torque/ source_url: https://github.com/QualiTorque/torque-orb commands: end-sandbox: description: | Stops Torque sandbox environment parameters: sandbox-id: default: SANDBOX_ID description: | Environment variable with the ID of the sandbox type: env_var_name space: default: TORQUE_SPACE description: | Name of Torque space type: env_var_name torque-token: default: TORQUE_TOKEN description: | Name of environment variable containing Torque API Token type: env_var_name torque-url: default: TORQUE_SERVER description: | URL of Torque Server type: env_var_name steps: - run: command: | curl --silent -X DELETE "$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/sandbox/$<<parameters.sandbox-id>>" \ --header "User-Agent: Torque-Plugin-CirceCI/1.1.X" \ --header "accept: text/plain" \ --header "Authorization: bearer $<<parameters.torque-token>>" || exit 1 name: End Torque Sandbox start-sandbox: description: | Launches Torque Sandbox from a blueprint parameters: blueprint: default: "" description: | Name of the blueprint used for creating a Torque sandbox. type: string duration: default: PT2H description: | Duration (ISO 8601), after which Torque will stop the deployment type: string inputs: default: '{}' description: | String with the list of inputs. Json format {'key1': 'value1', ..., 'keyN': 'valueN'} type: string sandbox-details-variable: default: SANDBOX_DETAILS description: | The name of environment variable which will be used to store full information about sandbox type: string sandbox-id-variable: default: SANDBOX_ID description: | The name of environment variable which will be used to store sandbox id type: string sandbox-name: default: circleci-orb-sandbox description: | Name of sandbox. type: string space: default: TORQUE_SPACE description: | Name of Torque space type: env_var_name timeout: default: 30 description: | Timeout for this step in minutes. If the sandbox will not be ready when the timeout is reached, Torque will abort the deployment type: integer torque-token: default: TORQUE_TOKEN description: | Name of environment variable containing Torque API Token type: env_var_name torque-url: default: TORQUE_SERVER description: | URL of Torque Server type: env_var_name steps: - run: command: | PAYLOAD=( "{ 'sandbox_name':'<<parameters.sandbox-name>>-${CIRCLE_BUILD_NUM}', 'blueprint_name':'<<parameters.blueprint>>', 'duration': '<<parameters.duration>>', 'inputs': <<parameters.inputs>>, 'automation': true }" ) echo $PAYLOAD status_code=`curl --write-out "%{http_code}\n" --output result.txt \ --silent -X POST "$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/environments" \ --header "User-Agent: Torque-Plugin-CirceCI/1.1.X" \ --header "accept: text/plain" \ --header "Authorization: bearer $<<parameters.torque-token>>" \ --header "Content-Type: application/json" -d "$PAYLOAD"` || exit 1 if [[ $status_code -ge 400 ]]; then echo "Unable to start sandbox. Details: $(cat result.txt)" exit 1 else sb=`cat result.txt | sed 's/.*:"//' | sed 's/".*//'` echo "Sandbox with id $sb has been started" echo "export <<parameters.sandbox-id-variable>>=$sb" >> $BASH_ENV fi name: Deploy Torque Sandbox - run: command: | echo "Waiting for sandbox $<<parameters.sandbox-id-variable>>" timeout=`date --date="<<parameters.timeout>> minutes" +%s` status='' prev_status='' while [[ $(date +%s) -le $timeout ]]; do url="$<<parameters.torque-url>>/api/spaces/$<<parameters.space>>/environments/$<<parameters.sandbox-id-variable>>" echo "****" details=`curl --silent \ -X GET "${url}" \ --header "User-Agent: Torque-Plugin-CirceCI/1.1.X" \ --header "accept: text/plain" \ --header "Authorization: bearer $<<parameters.torque-token>>"` status=`echo $details | sed "s/.*\"computed_status\":\"//" | sed "s/\".*//"` if [[ $status != $prev_status ]]; then echo "Status is $status" prev_status=$status fi if [[ $status == "Active" ]]; then break fi if [[ $status == "Ended" ]]; then echo "Error: sandbox is ended" exit 1 fi if [[ $status == "Active With Error" ]]; then echo "Error: sandbox is active with error!" exit 1 fi sleep 20 done if [[ $status != "Active" ]]; then echo "Timeout was reached or Sandbox is active with errors" exit 1 fi echo "export <<parameters.sandbox-details-variable>>=$details" >> $BASH_ENV name: Wait For Sandbox executors: default: description: | The sample executor. Any executor with curl pre-installed can be used instead docker: - image: << parameters.image >>:<< parameters.tag >> parameters: image: default: circleci/python description: The name of image type: string tag: default: latest description: The image version tag type: string jobs: sandbox: description: | Run your build scenario once sandbox environment is ready. executor: image: <<parameters.image>> name: default tag: <<parameters.tag>> parameters: blueprint: description: | Name of the blueprint used for creating a Torque sandbox. type: string image: default: circleci/python description: The name of image type: string inputs: default: '{}' description: | String with the list of inputs. Json format {'key1': 'value1', ..., 'keyN': 'valueN'} type: string sandbox-name: default: circleci-orb-sandbox description: | Name of sandbox. type: string space: default: TORQUE_SPACE description: | Name of Torque space type: env_var_name steps: description: Steps to execute once the Torque Sandbox is available type: steps tag: default: latest description: The image version tag type: string torque-token: default: TORQUE_TOKEN description: | Name of environment variable containing Torque API Token type: env_var_name torque-url: default: TORQUE_SERVER description: | URL of Torque Server type: env_var_name steps: - checkout - start-sandbox: blueprint: <<parameters.blueprint>> inputs: <<parameters.inputs>> sandbox-name: <<parameters.sandbox-name>> space: <<parameters.space>> torque-token: <<parameters.torque-token>> torque-url: <<parameters.torque-url>> - steps: <<parameters.steps>> - end-sandbox examples: fetch-info: description: | Start sandbox, echo its full description, stop sandbox usage: version: "2.1" orbs: torque: quali/torque@1.1 jobs: build: docker: - image: circleci/ruby:2.4.1 steps: - torque/start-sandbox: blueprint: my-application inputs: '{''AWS_INSTANCE_TYPE'': ''m5.large''}' sandbox-name: test-sandbox - run: command: echo "Sandbox ID is ${SANDBOX_ID}" name: Fetch Details - torque/end-sandbox: sandbox-id: SANDBOX_ID workflows: easy: jobs: - build test-app: description: | This example demonstrates how you can build and test your app using Torque Orb. First build app and publish it to s3 bucket. Than deploy Torque Sandbox with your new application as an artifact parameter and do some testing against the endpoint of your deployed application. usage: version: "2.1" orbs: aws-s3: circleci/aws-s3@1.0.11 torque: quali/torque@1.1 jobs: build-and-publish: docker: - image: circleci/ruby:2.4.1 steps: - checkout - run: command: | mkdir -p workspace tar -zcf my-webapp.latest.tar.gz -C my_app/ . name: Archive app - aws-s3/copy: from: my-webapp.latest.tar.gz to: s3://my-webapp-artifacts/latest/ workflows: leadeasy: jobs: - build-and-publish - torque/sandbox: blueprint: my-web-application inputs: '{''AWS_INSTANCE_TYPE'': ''m5.large''}' name: Test Application requires: - build-and-publish sandbox-name: test-sandbox steps: - run: echo "Do some testing here" - run: command: | echo "Getting sandbox details" echo "You can process the json with jq and perform some tests" echo "${SANDBOX_DETAILS}"
Developer Updates
Get tips to optimize your builds
Or join our research panel and give feedback
By submitting this form, you are agreeing to ourTerms of UseandPrivacy Policy.