Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: show url tip #428

Merged
merged 2 commits into from
Nov 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"f2elint": "^0.4.4",
"husky": "^7.0.2",
"jest": "^26.4.0",
"promise-retry": "^2.0.1",
"rimraf": "^3.0.2",
"ts-jest": "^26.2.0",
"ts-loader": "^8.0.14",
Expand Down
6 changes: 3 additions & 3 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,6 @@ export default class FcBaseComponent extends BaseComponent {
};
this.logger.debug(`Using event options: \n${yaml.dump(eventTypeOpts)}`);
} else if (stressOpts?.functionType === 'http') {
if (!argsData?.url) {
this.logger.error('Function type is http, please specify --url');
}
httpTypeOpts = {
url: argsData?.url,
method: argsData?.method,
Expand All @@ -486,6 +483,9 @@ export default class FcBaseComponent extends BaseComponent {
const fcStress: FcStress = new FcStress(project?.access, props?.region || argsData?.region, stressOpts, httpTypeOpts, eventTypeOpts, payloadOpts);
let fcStressArgs: string;
if (commandName === 'start') {
if (stressOpts?.functionType === 'http' && !argsData?.url) {
this.logger.error('Function type is http, please specify --url');
}
fcStressArgs = fcStress.makeStartArgs();
} else if (commandName === 'clean') {
fcStressArgs = fcStress.makeCleanArgs(argsData['assume-yes']);
Expand Down
36 changes: 33 additions & 3 deletions test/deploy-integration.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as core from '@serverless-devs/core';
import promiseRetry from 'promise-retry';
import _ from 'lodash';
import path from 'path';
import fse from 'fs-extra';
Expand Down Expand Up @@ -46,6 +47,13 @@ import {
import { NasConfig } from '../src/lib/interface/nas';
import { LogConfig } from '../src/lib/interface/sls';

const retryOptions = {
retries: 2,
factor: 2,
minTimeout: 1 * 1000,
randomize: true,
};

describe('Integration::deploy', () => {
let fcClient: any;

Expand Down Expand Up @@ -193,7 +201,14 @@ describe('Integration::deploy', () => {
};

const fcComponent = await new FcComponent(inputs);
await fcComponent.deploy(inputs);
await promiseRetry(async (retry: any, times: number) => {
try {
await fcComponent.deploy(inputs);
} catch (ex) {
console.log('deploy service with auto, retry ', times);
retry(ex);
}
}, retryOptions);

const serviceConfig = (await fcClient.getService(SERVICE_NAME)).data;

Expand Down Expand Up @@ -251,7 +266,15 @@ describe('Integration::deploy', () => {
},
},
};
await new FcComponent(inputs2).deploy(inputs2);

await promiseRetry(async (retry: any, times: number) => {
try {
await new FcComponent(inputs2).deploy(inputs2);
} catch (ex) {
console.log('update service, retry ', times);
retry(ex);
}
}, retryOptions);

const serviceConfig2 = (await fcClient.getService(SERVICE_NAME)).data;
expect(serviceConfig2).toMatchObject({
Expand All @@ -274,7 +297,14 @@ describe('Integration::deploy', () => {
...SERVICE_CONFIG,
},
};
await new FcComponent(inputs3).deploy(inputs3);
await promiseRetry(async (retry: any, times: number) => {
try {
await new FcComponent(inputs3).deploy(inputs3);
} catch (ex) {
console.log('update service2, retry ', times);
retry(ex);
}
}, retryOptions);
const serviceConfig3 = (await fcClient.getService(SERVICE_NAME)).data;

expect(serviceConfig3.role).toBe('');
Expand Down
5 changes: 5 additions & 0 deletions test/mock-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export const OSS_TRIGGER_NAME = 'ossTrigger';
export const MNS_TRIGGER_NAME = 'mnsTrigger';

export const SERVICE_NAME = `s-devs-ci-service-${os.platform()}-${new Date().getTime()}-${Math.random().toString(36).substr(2)}`;
export const REMOVE_SERVICE_NAME = `s-devs-ci-service-remove-${os.platform()}-${new Date().getTime()}-${Math.random().toString(36).substr(2)}`;
export const OSS_BUCKET_NAME = `s-devs-ci-bucket-${os.platform()}-${new Date().getTime()}-${Math.random().toString(36).substr(2)}`;
export const MNS_TOPIC_NAME = `s-devs-ci-${os.platform()}-${new Date().getTime()}-${Math.random().toString(36).substr(2)}`;
export const ROLE_NAME = `s-devs-ci-role-${os.platform()}-${new Date().getTime()}-${Math.random().toString(36).substr(2)}`;
Expand All @@ -22,6 +23,10 @@ export const SERVICE_CONFIG = {
name: SERVICE_NAME,
description: 'This is for fc test',
};
export const REMOVE_SERVICE_CONFIG = {
name: REMOVE_SERVICE_NAME,
description: 'This is for fc test',
};

export const FUNCTION_CONFIG = {
name: FUNCTION_NAME,
Expand Down
4 changes: 2 additions & 2 deletions test/remove-integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ import {
INPUTS,
REGION,
ACCESS,
SERVICE_CONFIG,
REMOVE_SERVICE_CONFIG as SERVICE_CONFIG,
FUNCTION_CONFIG,
HTTP_TRIGGER_CONFIG,
DOMAIN_CONFIG,
SERVICE_NAME,
REMOVE_SERVICE_NAME as SERVICE_NAME,
FUNCTION_NAME,
HTTP_TRIGGER_NAME,
} from './mock-data';
Expand Down