Skip to content
This repository was archived by the owner on Apr 3, 2024. It is now read-only.

Commit 334fba2

Browse files
authored
fixe typos: waitExpired, successOnTimeout (#287)
1 parent 8906108 commit 334fba2

File tree

6 files changed

+62
-32
lines changed

6 files changed

+62
-32
lines changed

src.ts/agent/debuglet.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -533,7 +533,13 @@ export class Debuglet extends EventEmitter {
533533
that.logger_.info(
534534
'\t' + (response as http.ServerResponse).statusCode +
535535
' completed.');
536-
if (body.wait_expired) {
536+
if (!body) {
537+
that.logger_.error('\tinvalid list response: empty body');
538+
that.scheduleBreakpointFetch_(
539+
that.config_.breakpointUpdateIntervalSec);
540+
return;
541+
}
542+
if (body.waitExpired) {
537543
that.logger_.info('\tLong poll completed.');
538544
that.scheduleBreakpointFetch_(0 /*immediately*/);
539545
return;

src.ts/controller.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import * as qs from 'querystring';
2727

2828
import {Debug} from './debug';
2929
import {Debuggee} from './debuggee';
30-
import {Breakpoint} from './types/api-types';
30+
import {Breakpoint, ListBreakpointsQuery, ListBreakpointsResponse} from './types/api-types';
3131

3232
/** @const {string} Cloud Debug API endpoint */
3333
const API = 'https://clouddebugger.googleapis.com/v2/controller';
@@ -85,11 +85,12 @@ export class Controller extends common.ServiceObject {
8585
*/
8686
listBreakpoints(
8787
debuggee: Debuggee,
88-
callback: (err: Error|null, response?: http.ServerResponse, body?: any) =>
89-
void): void {
88+
callback:
89+
(err: Error|null, response?: http.ServerResponse,
90+
body?: ListBreakpointsResponse) => void): void {
9091
const that = this;
9192
assert(debuggee.id, 'should have a registered debuggee');
92-
const query: any = {success_on_timeout: true};
93+
const query: ListBreakpointsQuery = {successOnTimeout: true};
9394
if (that.nextWaitToken_) {
9495
query.waitToken = that.nextWaitToken_;
9596
}

src.ts/types/api-types.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,14 @@ export interface Breakpoint {
103103
[key: string]: string,
104104
};
105105
}
106+
107+
export interface ListBreakpointsQuery {
108+
waitToken?: string;
109+
successOnTimeout?: boolean;
110+
}
111+
112+
export interface ListBreakpointsResponse {
113+
breakpoints: Breakpoint[];
114+
nextWaitToken: string;
115+
waitExpired: boolean;
116+
}

system-test/test-e2e.js

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ describe('@google-cloud/debug end-to-end behavior', function () {
129129
});
130130

131131
it('should set breakpoints correctly', function() {
132-
this.timeout(25 * 1000);
132+
this.timeout(90 * 1000);
133133
// Kick off promise chain by getting a list of debuggees
134134
return api.listDebuggees(projectId).then(function(results) {
135135
// Check that the debuggee created in this test is among the list of
@@ -188,7 +188,7 @@ describe('@google-cloud/debug end-to-end behavior', function () {
188188
console.log('-- waiting before checking if the log was written');
189189
return Promise.all([breakpoint, delay(10 * 1000)]);
190190
}).then(function(results) {
191-
// Check the contents of the log, and then delete the breakpoint
191+
// Check the contents of the log, but keep the original breakpoint.
192192

193193
var breakpoint = results[0];
194194

@@ -197,13 +197,13 @@ describe('@google-cloud/debug end-to-end behavior', function () {
197197
'transcript in child ' + index + ' should contain value of o: ' +
198198
child.transcript);
199199
});
200-
return api.deleteBreakpoint(debuggeeId, breakpoint.id);
200+
return Promise.resolve();
201201
}).then(function() {
202202
// Set another breakpoint at the same location
203203

204204
console.log('-- setting a breakpoint');
205205
return api.setBreakpoint(debuggeeId, {
206-
id: 'breakpoint-1',
206+
id: 'breakpoint-2',
207207
location: {path: FILENAME, line: 5},
208208
expressions: ['process'], // Process for large variable
209209
condition: 'n === 10'
@@ -254,12 +254,24 @@ describe('@google-cloud/debug end-to-end behavior', function () {
254254
assert.strictEqual(arg.value, '10');
255255
console.log('-- checking log point was hit again');
256256
children.forEach(function(child) {
257-
assert.ok(child.transcript
258-
.split('LOGPOINT: o is: {"a":[1,"hi",true]}').length > 4);
257+
const count = (child.transcript
258+
.match(/LOGPOINT: o is: \{"a":\[1,"hi",true\]\}/g) || []).length;
259+
assert.ok(count > 4);
259260
});
260261

261262
return api.deleteBreakpoint(debuggeeId, breakpoint.id);
262263
}).then(function() {
264+
// wait for 60 seconds
265+
console.log('-- waiting for 60 seconds');
266+
return delay(60 * 1000);
267+
}).then(function() {
268+
// Make sure the log point is continuing to be hit.
269+
console.log('-- checking log point was hit again');
270+
children.forEach(function(child) {
271+
const count = (child.transcript
272+
.match(/LOGPOINT: o is: \{"a":\[1,"hi",true\]\}/g) || []).length;
273+
assert.ok(count > 60);
274+
});
263275
console.log('-- test passed');
264276
return Promise.resolve();
265277
});
@@ -305,7 +317,7 @@ describe('@google-cloud/debug end-to-end behavior', function () {
305317

306318
console.log('-- setting a logpoint');
307319
return api.setBreakpoint(debuggeeId, {
308-
id: 'breakpoint-1',
320+
id: 'breakpoint-3',
309321
location: {path: FILENAME, line: 5},
310322
condition: 'n === 10',
311323
action: 'LOG',
@@ -332,8 +344,8 @@ describe('@google-cloud/debug end-to-end behavior', function () {
332344
// If no throttling occurs, we expect ~20 logs since we are logging
333345
// 2x per second over a 10 second period.
334346
children.forEach(function(child) {
335-
var logCount = child.transcript
336-
.split('LOGPOINT: o is: {"a":[1,"hi",true]}').length - 1;
347+
const logCount = (child.transcript
348+
.match(/LOGPOINT: o is: \{"a":\[1,"hi",true\]\}/g) || []).length;
337349
// A log count of greater than 10 indicates that we did not successfully
338350
// pause when the rate of `maxLogsPerSecond` was reached.
339351
assert(logCount <= 10, 'log count is greater than 10: ' + logCount);

test/test-controller.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ describe('Controller API', function() {
106106

107107
it('should deal with a missing breakpoints response', function(done) {
108108
var scope = nock(url)
109-
.get(api + '/debuggees/fake-debuggee/breakpoints?success_on_timeout=true')
109+
.get(api + '/debuggees/fake-debuggee/breakpoints?successOnTimeout=true')
110110
.reply(200, { kind: 'whatever' });
111111

112112
var debuggee = { id: 'fake-debuggee' };
@@ -124,7 +124,7 @@ describe('Controller API', function() {
124124
tests.forEach(function(invalidResponse, index) {
125125
it('should pass test ' + index, function(done) {
126126
var scope = nock(url)
127-
.get(api + '/debuggees/fake-debuggee/breakpoints?success_on_timeout=true')
127+
.get(api + '/debuggees/fake-debuggee/breakpoints?successOnTimeout=true')
128128
.reply(200, invalidResponse);
129129
var debuggee = { id: 'fake-debuggee' };
130130
var controller = new Controller(fakeDebug);
@@ -140,7 +140,7 @@ describe('Controller API', function() {
140140

141141
it('should throw error on http errors', function(done) {
142142
var scope = nock(url)
143-
.get(api + '/debuggees/fake-debuggee/breakpoints?success_on_timeout=true')
143+
.get(api + '/debuggees/fake-debuggee/breakpoints?successOnTimeout=true')
144144
.reply(403);
145145
var debuggee = { id: 'fake-debuggee' };
146146
var controller = new Controller(fakeDebug);
@@ -154,15 +154,15 @@ describe('Controller API', function() {
154154

155155
it('should work with waitTokens', function(done) {
156156
var scope = nock(url)
157-
.get(api + '/debuggees/fake-debuggee/breakpoints?success_on_timeout=true')
157+
.get(api + '/debuggees/fake-debuggee/breakpoints?successOnTimeout=true')
158158
.reply(200, {
159-
wait_expired: true
159+
waitExpired: true
160160
});
161161
var debuggee = { id: 'fake-debuggee' };
162162
var controller = new Controller(fakeDebug);
163163
controller.listBreakpoints(debuggee, function(err, response, result) {
164164
assert.ifError(err, 'not expecting an error');
165-
assert(response.body.wait_expired, 'should have expired set');
165+
assert(response.body.waitExpired, 'should have expired set');
166166
scope.done();
167167
done();
168168
});
@@ -176,7 +176,7 @@ describe('Controller API', function() {
176176
testsBreakpoints.forEach(function(breakpoints, index) {
177177
it('should pass test ' + index, function(done) {
178178
var scope = nock(url)
179-
.get(api + '/debuggees/fake-debuggee/breakpoints?success_on_timeout=true')
179+
.get(api + '/debuggees/fake-debuggee/breakpoints?successOnTimeout=true')
180180
.reply(200, {
181181
breakpoints: breakpoints
182182
});

test/test-debuglet.js

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ describe('Debuglet', function() {
498498
var scope = nock(API)
499499
.post(REGISTER_PATH)
500500
.reply(200, {debuggee: {id: DEBUGGEE_ID}})
501-
.get(BPS_PATH + '?success_on_timeout=true')
501+
.get(BPS_PATH + '?successOnTimeout=true')
502502
.reply(404)
503503
.post(REGISTER_PATH)
504504
.reply(200, {debuggee: {id: DEBUGGEE_ID}});
@@ -525,7 +525,7 @@ describe('Debuglet', function() {
525525
var scope = nock(API)
526526
.post(REGISTER_PATH)
527527
.reply(200, {debuggee: {id: DEBUGGEE_ID}})
528-
.get(BPS_PATH + '?success_on_timeout=true')
528+
.get(BPS_PATH + '?successOnTimeout=true')
529529
.reply(200, {breakpoints: [bp]});
530530

531531
debuglet.once('registered', function reg(id) {
@@ -552,7 +552,7 @@ describe('Debuglet', function() {
552552
var scope = nock(API)
553553
.post(REGISTER_PATH)
554554
.reply(200, { debuggee: { id: DEBUGGEE_ID } })
555-
.get(BPS_PATH + '?success_on_timeout=true')
555+
.get(BPS_PATH + '?successOnTimeout=true')
556556
.reply(200, {
557557
breakpoints: [{
558558
id: 'test',
@@ -590,7 +590,7 @@ describe('Debuglet', function() {
590590
var scope = nock(API)
591591
.post(REGISTER_PATH)
592592
.reply(200, { debuggee: { id: DEBUGGEE_ID } })
593-
.get(BPS_PATH + '?success_on_timeout=true')
593+
.get(BPS_PATH + '?successOnTimeout=true')
594594
.reply(200, {
595595
breakpoints: [{
596596
id: 'test',
@@ -629,11 +629,11 @@ describe('Debuglet', function() {
629629
.reply(200, {debuggee: {id: DEBUGGEE_ID}})
630630
.post(REGISTER_PATH)
631631
.reply(200, {debuggee: {id: DEBUGGEE_ID}})
632-
.get(BPS_PATH + '?success_on_timeout=true')
632+
.get(BPS_PATH + '?successOnTimeout=true')
633633
.reply(404)
634-
.get(BPS_PATH + '?success_on_timeout=true')
635-
.reply(200, {wait_expired: true})
636-
.get(BPS_PATH + '?success_on_timeout=true')
634+
.get(BPS_PATH + '?successOnTimeout=true')
635+
.reply(200, {waitExpired: true})
636+
.get(BPS_PATH + '?successOnTimeout=true')
637637
.reply(200, {breakpoints: [bp, errorBp]})
638638
.put(BPS_PATH + '/' + errorBp.id,
639639
function(body) {
@@ -669,7 +669,7 @@ describe('Debuglet', function() {
669669
nock(API)
670670
.post(REGISTER_PATH)
671671
.reply(200, {debuggee: {id: DEBUGGEE_ID}})
672-
.get(BPS_PATH + '?success_on_timeout=true')
672+
.get(BPS_PATH + '?successOnTimeout=true')
673673
.reply(200, {breakpoints: [bp]})
674674
.put(BPS_PATH + '/test',
675675
function(body) {
@@ -717,15 +717,15 @@ describe('Debuglet', function() {
717717
nock(API)
718718
.post(REGISTER_PATH)
719719
.reply(200, {debuggee: {id: DEBUGGEE_ID}})
720-
.get(BPS_PATH + '?success_on_timeout=true')
720+
.get(BPS_PATH + '?successOnTimeout=true')
721721
.reply(200, {breakpoints: [bp]})
722722
.put(BPS_PATH + '/test',
723723
function(body) {
724724
return body.breakpoint.status.description.format ===
725725
'The snapshot has expired';
726726
})
727727
.reply(200)
728-
.get(BPS_PATH + '?success_on_timeout=true')
728+
.get(BPS_PATH + '?successOnTimeout=true')
729729
.times(4)
730730
.reply(200, {breakpoints: [bp]});
731731

0 commit comments

Comments
 (0)