diff --git a/.github/workflows/cloud-tasks.yaml b/.github/workflows/cloud-tasks.yaml new file mode 100644 index 0000000000..c4b9c47630 --- /dev/null +++ b/.github/workflows/cloud-tasks.yaml @@ -0,0 +1,67 @@ +name: cloud-tasks +on: + push: + branches: + - main + paths: + - 'cloud-tasks/snippets/*.js' + pull_request: + paths: + - 'cloud-tasks/snippets/*.js' + pull_request_target: + types: [labeled] + schedule: + - cron: '0 0 * * 0' +jobs: + test: + if: ${{ github.event.action != 'labeled' || github.event.label.name == 'actions:force-run' }} + runs-on: ubuntu-latest + timeout-minutes: 60 + permissions: + contents: 'write' + pull-requests: 'write' + id-token: 'write' + steps: + - uses: 'google-github-actions/auth@v0.3.1' + with: + workload_identity_provider: 'projects/1046198160504/locations/global/workloadIdentityPools/github-actions-pool/providers/github-actions-provider' + service_account: 'kokoro-system-test@long-door-651.iam.gserviceaccount.com' + create_credentials_file: 'true' + access_token_lifetime: 600s + - uses: actions/checkout@v3 + with: + ref: ${{github.event.pull_request.head.ref}} + repository: ${{github.event.pull_request.head.repo.full_name}} + - uses: actions/setup-node@v2 + with: + node-version: 16 + - run: npm install + working-directory: cloud-tasks/snippets + - run: npm test + working-directory: cloud-tasks/snippets + env: + MOCHA_REPORTER_SUITENAME: cloud_tasks + MOCHA_REPORTER_OUTPUT: cloud_tasks_sponge_log.xml + MOCHA_REPORTER: xunit + - if: ${{ github.event.action == 'labeled' && github.event.label.name == 'actions:force-run' }} + uses: actions/github-script@v6 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + try { + await github.rest.issues.removeLabel({ + name: 'actions:force-run', + owner: 'GoogleCloudPlatform', + repo: 'nodejs-docs-samples', + issue_number: context.payload.pull_request.number + }); + } catch (e) { + if (!e.message.includes('Label does not exist')) { + throw e; + } + } + - if: ${{ github.event_name == 'schedule'}} + run: | + curl https://github.com/googleapis/repo-automation-bots/releases/download/flakybot-1.1.0/flakybot -o flakybot -s -L + chmod +x ./flakybot + ./flakybot --repo GoogleCloudPlatform/nodejs-docs-samples --commit_hash ${{github.sha}} --build_url https://github.com/${{github.repository}}/actions/runs/${{github.run_id}} diff --git a/cloud-tasks/snippets/Dockerfile b/cloud-tasks/snippets/Dockerfile new file mode 100644 index 0000000000..9ff85bcafd --- /dev/null +++ b/cloud-tasks/snippets/Dockerfile @@ -0,0 +1,20 @@ +# Use the official Node.js 10 image. +# https://hub.docker.com/_/node +FROM node:10 + +# Create and change to the app directory. +WORKDIR /usr/src/app + +# Copy application dependency manifests to the container image. +# A wildcard is used to ensure both package.json AND package-lock.json are copied. +# Copying this separately prevents re-running npm install on every code change. +COPY package.json package*.json ./ + +# Install production dependencies. +RUN npm install --only=production + +# Copy local code to the container image. +COPY . . + +# Run the web service on container startup. +CMD [ "npm", "start" ] diff --git a/cloud-tasks/snippets/app.yaml b/cloud-tasks/snippets/app.yaml new file mode 100644 index 0000000000..24d25d8e52 --- /dev/null +++ b/cloud-tasks/snippets/app.yaml @@ -0,0 +1,14 @@ +# Copyright 2019 Google LLC +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +runtime: nodejs10 diff --git a/cloud-tasks/snippets/createHttpTask.js b/cloud-tasks/snippets/createHttpTask.js new file mode 100644 index 0000000000..a6817875a3 --- /dev/null +++ b/cloud-tasks/snippets/createHttpTask.js @@ -0,0 +1,89 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// sample-metadata: +// title: Cloud Tasks Create HTTP Target +// description: Create Cloud Tasks with a HTTP Target +// usage: node createHttpTask.js + +/** + * Create a task with an HTTP target for a given queue with an arbitrary payload. + */ +function main( + project = 'my-project-id', // Your GCP Project id + queue = 'my-appengine-queue', // Name of your Queue + location = 'us-central1', // The GCP region of your queue + url = 'https://example.com/taskhandler', // The full url path that the request will be sent to + payload = 'Hello, World!', // The task HTTP request body + inSeconds = 0 // Delay in task execution +) { + // [START cloud_tasks_create_http_task] + // Imports the Google Cloud Tasks library. + const {CloudTasksClient} = require('@google-cloud/tasks'); + + // Instantiates a client. + const client = new CloudTasksClient(); + + async function createHttpTask() { + // TODO(developer): Uncomment these lines and replace with your values. + // const project = 'my-project-id'; + // const queue = 'my-queue'; + // const location = 'us-central1'; + // const url = 'https://example.com/taskhandler'; + // const payload = 'Hello, World!'; + // const inSeconds = 180; + + // Construct the fully qualified queue name. + const parent = client.queuePath(project, location, queue); + + const task = { + httpRequest: { + headers: { + 'Content-Type': 'text/plain', + }, + httpMethod: 'POST', + url, + }, + }; + + if (payload) { + task.httpRequest.body = Buffer.from(payload).toString('base64'); + } + + if (inSeconds) { + // The time when the task is scheduled to be attempted. + task.scheduleTime = { + seconds: parseInt(inSeconds) + Date.now() / 1000, + }; + } + + // Send create task request. + console.log('Sending task:'); + console.log(task); + const request = {parent: parent, task: task}; + const [response] = await client.createTask(request); + console.log(`Created task ${response.name}`); + } + createHttpTask(); + // [END cloud_tasks_create_http_task] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); + +main(...process.argv.slice(2)); diff --git a/cloud-tasks/snippets/createHttpTaskWithToken.js b/cloud-tasks/snippets/createHttpTaskWithToken.js new file mode 100644 index 0000000000..580b912077 --- /dev/null +++ b/cloud-tasks/snippets/createHttpTaskWithToken.js @@ -0,0 +1,86 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// sample-metadata: +// title: Cloud Tasks Create HTTP Target with Token +// description: Create Cloud Tasks with a HTTP Target with Token +// usage: node createHttpTaskWithToken.js + +/** + * Create a task with an HTTP target for a given queue with an arbitrary payload. + */ +function main( + project = 'my-project-id', // Your GCP Project id + queue = 'my-queue', // Name of your Queue + location = 'us-central1', // The GCP region of your queue + url = 'https://example.com/taskhandler', // The full url path that the request will be sent to + serviceAccountEmail = 'client@.iam.gserviceaccount.com', // Cloud IAM service account + payload = 'Hello, World!' // The task HTTP request body +) { + // [START cloud_tasks_create_http_task_with_token] + // Imports the Google Cloud Tasks library. + const {CloudTasksClient} = require('@google-cloud/tasks'); + + // Instantiates a client. + const client = new CloudTasksClient(); + + async function createHttpTaskWithToken() { + // TODO(developer): Uncomment these lines and replace with your values. + // const project = 'my-project-id'; + // const queue = 'my-queue'; + // const location = 'us-central1'; + // const url = 'https://example.com/taskhandler'; + // const serviceAccountEmail = 'client@.iam.gserviceaccount.com'; + // const payload = 'Hello, World!'; + + // Construct the fully qualified queue name. + const parent = client.queuePath(project, location, queue); + + const task = { + httpRequest: { + headers: { + 'Content-Type': 'text/plain', + }, + httpMethod: 'POST', + url, + oidcToken: { + serviceAccountEmail, + }, + }, + }; + + if (payload) { + task.httpRequest.body = Buffer.from(payload).toString('base64'); + } + + console.log('Sending task:'); + console.log(task); + // Send create task request. + const request = {parent: parent, task: task}; + const [response] = await client.createTask(request); + const name = response.name; + console.log(`Created task ${name}`); + } + createHttpTaskWithToken(); + // [END cloud_tasks_create_http_task_with_token] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); + +main(...process.argv.slice(2)); diff --git a/cloud-tasks/snippets/createQueue.js b/cloud-tasks/snippets/createQueue.js new file mode 100644 index 0000000000..6d0c223d70 --- /dev/null +++ b/cloud-tasks/snippets/createQueue.js @@ -0,0 +1,59 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +/** + * Create a new Task Queue + */ +function main( + project = 'my-project-id', // Your GCP Project id + queue = 'my-appengine-queue', // Name of the Queue to create + location = 'us-central1' // The GCP region in which to create the queue +) { + // [START cloud_tasks_create_queue] + // Imports the Google Cloud Tasks library. + const cloudTasks = require('@google-cloud/tasks'); + + // Instantiates a client. + const client = new cloudTasks.CloudTasksClient(); + + async function createQueue() { + // Send create queue request. + const [response] = await client.createQueue({ + // The fully qualified path to the location where the queue is created + parent: client.locationPath(project, location), + queue: { + // The fully qualified path to the queue + name: client.queuePath(project, location, queue), + appEngineHttpQueue: { + appEngineRoutingOverride: { + // The App Engine service that will receive the tasks. + service: 'default', + }, + }, + }, + }); + console.log(`Created queue ${response.name}`); + } + createQueue(); + // [END cloud_tasks_create_queue] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); + +main(...process.argv.slice(2)); diff --git a/cloud-tasks/snippets/createTask.js b/cloud-tasks/snippets/createTask.js new file mode 100644 index 0000000000..6496ca7862 --- /dev/null +++ b/cloud-tasks/snippets/createTask.js @@ -0,0 +1,89 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// sample-metadata: +// title: Cloud Tasks Create App Engine Target +// description: Create Cloud Tasks with a Google App Engine Target +// usage: node createTask.js + +/** + * Create a task for a given queue with an arbitrary payload. + */ +function main( + project = 'my-project-id', // Your GCP Project id + queue = 'my-appengine-queue', // Name of your Queue + location = 'us-central1', // The GCP region of your queue + payload = 'Hello, World!', // The task HTTP request body + inSeconds = 0 // Delay in task execution +) { + // [START cloud_tasks_appengine_create_task] + // Imports the Google Cloud Tasks library. + const {CloudTasksClient} = require('@google-cloud/tasks'); + + // Instantiates a client. + const client = new CloudTasksClient(); + + async function createTask() { + // TODO(developer): Uncomment these lines and replace with your values. + // const project = 'my-project-id'; + // const queue = 'my-appengine-queue'; + // const location = 'us-central1'; + // const payload = 'Hello, World!'; + + // Construct the fully qualified queue name. + const parent = client.queuePath(project, location, queue); + + const task = { + appEngineHttpRequest: { + headers: { + 'Content-Type': 'text/plain', + }, + httpMethod: 'POST', + relativeUri: '/log_payload', + }, + }; + + if (payload) { + task.appEngineHttpRequest.body = Buffer.from(payload).toString('base64'); + } + + if (inSeconds) { + // The time when the task is scheduled to be attempted. + task.scheduleTime = { + seconds: inSeconds + Date.now() / 1000, + }; + } + + console.log('Sending task:'); + console.log(task); + + // Send create task request. + const request = {parent: parent, task: task}; + const [response] = await client.createTask(request); + const name = response.name; + console.log(`Created task ${name}`); + } + + createTask(); + // [END cloud_tasks_appengine_create_task] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); + +main(...process.argv.slice(2)); diff --git a/cloud-tasks/snippets/deleteQueue.js b/cloud-tasks/snippets/deleteQueue.js new file mode 100644 index 0000000000..ab124aed9d --- /dev/null +++ b/cloud-tasks/snippets/deleteQueue.js @@ -0,0 +1,49 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +/** + * Delete a given Queue + */ +function main( + project = 'my-project-id', // Your GCP Project id + queue = 'my-appengine-queue', // Name of the Queue to delete + location = 'us-central1' // The GCP region in which to delete the queue +) { + // [START cloud_tasks_delete_queue] + // Imports the Google Cloud Tasks library. + const cloudTasks = require('@google-cloud/tasks'); + + // Instantiates a client. + const client = new cloudTasks.CloudTasksClient(); + + async function deleteQueue() { + // Get the fully qualified path to the queue + const name = client.queuePath(project, location, queue); + + // Send delete queue request. + await client.deleteQueue({name}); + console.log(`Deleted queue '${queue}'.`); + } + deleteQueue(); + // [END cloud_tasks_delete_queue] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); + +main(...process.argv.slice(2)); diff --git a/cloud-tasks/snippets/listQueues.js b/cloud-tasks/snippets/listQueues.js new file mode 100644 index 0000000000..8f14a7f6f8 --- /dev/null +++ b/cloud-tasks/snippets/listQueues.js @@ -0,0 +1,53 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +function main( + project = 'my-project-id', // Your GCP Project id + location = 'us-central1' // The GCP region to search for queues +) { + // [START cloud_tasks_list_queues] + // Imports the Google Cloud Tasks library. + const cloudTasks = require('@google-cloud/tasks'); + + // Instantiates a client. + const client = new cloudTasks.CloudTasksClient(); + + async function listQueues() { + // Get the fully qualified path to the region + const parent = client.locationPath(project, location); + + // list all fo the queues + const [queues] = await client.listQueues({parent}); + + if (queues.length > 0) { + console.log('Queues:'); + queues.forEach(queue => { + console.log(` ${queue.name}`); + }); + } else { + console.log('No queues found!'); + } + } + listQueues(); + // [END cloud_tasks_list_queues] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); + +main(...process.argv.slice(2)); diff --git a/cloud-tasks/snippets/package.json b/cloud-tasks/snippets/package.json new file mode 100644 index 0000000000..60845bf6b3 --- /dev/null +++ b/cloud-tasks/snippets/package.json @@ -0,0 +1,27 @@ +{ + "name": "appengine-cloudtasks", + "description": "Google App Engine Cloud Tasks example.", + "license": "Apache-2.0", + "author": "Google Inc.", + "private": true, + "engines": { + "node": ">=12.0.0" + }, + "files": [ + "*.js" + ], + "scripts": { + "test": "mocha --timeout 30000", + "start": "node server.js" + }, + "dependencies": { + "@google-cloud/tasks": "^3.0.4", + "body-parser": "^1.18.3", + "express": "^4.16.3" + }, + "devDependencies": { + "chai": "^4.2.0", + "mocha": "^8.0.0", + "uuid": "^9.0.0" + } +} diff --git a/cloud-tasks/snippets/quickstart.js b/cloud-tasks/snippets/quickstart.js new file mode 100644 index 0000000000..a0eedd8349 --- /dev/null +++ b/cloud-tasks/snippets/quickstart.js @@ -0,0 +1,76 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +/** + * Create a task for a given queue with an arbitrary payload. + */ +function main(project, location, queue, payload, inSeconds) { + // [START cloud_tasks_quickstart] + // Imports the Google Cloud Tasks library. + const {CloudTasksClient} = require('@google-cloud/tasks'); + + // Instantiates a client. + const client = new CloudTasksClient(); + + async function quickstart() { + // TODO(developer): Uncomment these lines and replace with your values. + // const project = 'my-project-id'; + // const queue = 'my-appengine-queue'; + // const location = 'us-central1'; + // const payload = 'hello'; + + // Construct the fully qualified queue name. + const parent = client.queuePath(project, location, queue); + + const task = { + appEngineHttpRequest: { + httpMethod: 'POST', + relativeUri: '/log_payload', + }, + }; + + if (payload) { + task.appEngineHttpRequest.body = Buffer.from(payload).toString('base64'); + } + + if (inSeconds) { + task.scheduleTime = { + seconds: inSeconds + Date.now() / 1000, + }; + } + + const request = { + parent: parent, + task: task, + }; + + console.log('Sending task:'); + console.log(task); + // Send create task request. + const [response] = await client.createTask(request); + const name = response.name; + console.log(`Created task ${name}`); + } + quickstart(); + // [END cloud_tasks_quickstart] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); + +main(...process.argv.slice(2)); diff --git a/cloud-tasks/snippets/server.js b/cloud-tasks/snippets/server.js new file mode 100644 index 0000000000..1e1293a72d --- /dev/null +++ b/cloud-tasks/snippets/server.js @@ -0,0 +1,48 @@ +// Copyright 2019 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +// [START cloud_tasks_appengine_quickstart] +const bodyParser = require('body-parser'); +const express = require('express'); + +const app = express(); +app.enable('trust proxy'); + +// By default, the Content-Type header of the Task request is set to "application/octet-stream" +// see https://cloud.google.com/tasks/docs/reference/rest/v2beta3/projects.locations.queues.tasks#AppEngineHttpRequest +app.use(bodyParser.raw({type: 'application/octet-stream'})); + +app.get('/', (req, res) => { + // Basic index to verify app is serving + res.send('Hello, World!').end(); +}); + +app.post('/log_payload', (req, res) => { + // Log the request payload + console.log('Received task with payload: %s', req.body); + res.send(`Printed task payload: ${req.body}`).end(); +}); + +app.get('*', (req, res) => { + res.send('OK').end(); +}); + +const PORT = process.env.PORT || 8080; +app.listen(process.env.PORT || 8080, () => { + console.log(`App listening on port ${PORT}`); + console.log('Press Ctrl+C to quit.'); +}); +// [END cloud_tasks_appengine_quickstart] diff --git a/cloud-tasks/snippets/test/test.samples.js b/cloud-tasks/snippets/test/test.samples.js new file mode 100644 index 0000000000..83543b9cd8 --- /dev/null +++ b/cloud-tasks/snippets/test/test.samples.js @@ -0,0 +1,75 @@ +// Copyright 2018 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +'use strict'; + +const {assert} = require('chai'); +const {describe, it, before} = require('mocha'); +const {execSync} = require('child_process'); +const uuid = require('uuid'); +const {CloudTasksClient} = require('@google-cloud/tasks'); + +const exec = cmd => execSync(cmd, {encoding: 'utf-8'}); +const queueName = `gcloud-${uuid.v4().split('-')[0]}`; +const SERVICE_ACCOUNT = + 'test-run-invoker@long-door-651.iam.gserviceaccount.com'; + +describe('Cloud Task Sample Tests', () => { + let url; + let projectId; + + before(async () => { + const client = new CloudTasksClient(); + projectId = await client.getProjectId(); + url = 'https://example.com/taskhandler'; + }); + + it('should create a queue', () => { + const stdout = exec(`node createQueue ${projectId} ${queueName}`); + assert.match(stdout, /Created queue/); + }); + + it('should create a task', () => { + const stdout = exec( + `node createTask ${projectId} ${queueName} us-central1` + ); + assert.match(stdout, /Created task/); + }); + + it('quickstart sample should create a task', () => { + const stdout = exec( + `node quickstart ${projectId} us-central1 ${queueName}` + ); + assert.match(stdout, /Created task/); + }); + + it('should create a HTTP task', () => { + const stdout = exec( + `node createHttpTask ${projectId} my-queue us-central1 ${url}` + ); + assert.match(stdout, /Created task/); + }); + + it('should create a HTTP task with token', () => { + const stdout = exec( + `node createHttpTaskWithToken ${projectId} my-queue us-central1 ${url} ${SERVICE_ACCOUNT}` + ); + assert.match(stdout, /Created task/); + }); + + it('should delete a queue', () => { + const stdout = exec(`node deleteQueue ${projectId} ${queueName}`); + assert.match(stdout, /Deleted queue/); + }); +});