Skip to content

Commit 6365ab2

Browse files
authored
makes a few tests less likely to fail (GoogleCloudPlatform#836)
1 parent 9ebebef commit 6365ab2

12 files changed

+28
-89
lines changed

bigquery/api/src/browse_table.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
require_once __DIR__ . '/../vendor/autoload.php';
2626

2727
if (count($argv) < 4 || count($argv) > 5) {
28-
return printf("Usage: php %s PROJECT_ID DATASET_ID TABLE_ID [NUM_RESULTS]\n", __FILE__);
28+
return printf("Usage: php %s PROJECT_ID DATASET_ID TABLE_ID [START_INDEX]\n", __FILE__);
2929
}
3030
list($_, $projectId, $datasetId, $tableId) = $argv;
31-
$maxResults = isset($argv[4]) ? $argv[4] : 10;
31+
$startIndex = isset($argv[4]) ? $argv[4] : 0;
3232

3333

3434
# [START bigquery_browse_table]
@@ -38,10 +38,9 @@
3838
// $projectId = 'The Google project ID';
3939
// $datasetId = 'The BigQuery dataset ID';
4040
// $tableId = 'The BigQuery table ID';
41-
// $maxResults = 10;
41+
// $startIndex = 0;
4242

4343
$maxResults = 10;
44-
$startIndex = 0;
4544

4645
$options = [
4746
'maxResults' => $maxResults,

bigquery/api/src/paginate_table.php

Lines changed: 0 additions & 49 deletions
This file was deleted.

bigquery/api/test/bigqueryTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -263,17 +263,6 @@ public function testStreamRow()
263263
$this->verifyTable($tempTable, 'Brent Shaffer', 1);
264264
}
265265

266-
public function testPaginateTable()
267-
{
268-
$tableId = $this->createTempTable();
269-
$output = $this->runSnippet('paginate_table', [
270-
self::$datasetId,
271-
$tableId,
272-
1
273-
]);
274-
$this->assertContains('Brent Shaffer', $output);
275-
}
276-
277266
public function testRunQuery()
278267
{
279268
$query = 'SELECT corpus, COUNT(*) as unique_words

dlp/src/categorical_stats.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ function categorical_stats(
107107
}
108108
}
109109

110-
// Sleep for half a second to avoid race condition with the job's status.
111-
usleep(500000);
110+
// Sleep for one second to avoid race condition with the job's status.
111+
usleep(1000000);
112112

113113
// Get the updated job
114114
$job = $dlp->getDlpJob($job->getName());
@@ -151,7 +151,7 @@ function categorical_stats(
151151
}
152152
break;
153153
default:
154-
printf('Unknown job state. Most likely, the job is either running or has not yet started.');
154+
printf('Unexpected job state. Most likely, the job is either running or has not yet started.');
155155
}
156156
}
157157
# [END dlp_categorical_stats]

dlp/src/inspect_bigquery.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,8 +122,8 @@ function inspect_bigquery(
122122
}
123123
}
124124

125-
// Sleep for half a second to avoid race condition with the job's status.
126-
usleep(500000);
125+
// Sleep for one second to avoid race condition with the job's status.
126+
usleep(1000000);
127127

128128
// Get the updated job
129129
$job = $dlp->getDlpJob($job->getName());
@@ -153,7 +153,7 @@ function inspect_bigquery(
153153
}
154154
break;
155155
default:
156-
printf('Unknown job state. Most likely, the job is either running or has not yet started.');
156+
printf('Unexpected job state. Most likely, the job is either running or has not yet started.');
157157
}
158158
}
159159
# [END dlp_inspect_bigquery]

dlp/src/inspect_datastore.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,8 @@ function inspect_datastore(
128128
}
129129
}
130130

131-
// Sleep for half a second to avoid race condition with the job's status.
132-
usleep(500000);
131+
// Sleep for one second to avoid race condition with the job's status.
132+
usleep(1000000);
133133

134134
// Get the updated job
135135
$job = $dlp->getDlpJob($job->getName());
@@ -155,7 +155,7 @@ function inspect_datastore(
155155
}
156156
break;
157157
default:
158-
print('Unknown job state. Most likely, the job is either running or has not yet started.');
158+
print('Unexpected job state. Most likely, the job is either running or has not yet started.');
159159
}
160160
}
161161
# [END dlp_inspect_datastore]

dlp/src/inspect_gcs.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,8 @@ function inspect_gcs(
123123
}
124124
}
125125

126-
// Sleep for half a second to avoid race condition with the job's status.
127-
usleep(500000);
126+
// Sleep for one second to avoid race condition with the job's status.
127+
usleep(1000000);
128128

129129
// Get the updated job
130130
$job = $dlp->getDlpJob($job->getName());
@@ -150,7 +150,7 @@ function inspect_gcs(
150150
}
151151
break;
152152
default:
153-
print('Unknown job state. Most likely, the job is either running or has not yet started.');
153+
print('Unexpected job state. Most likely, the job is either running or has not yet started.');
154154
}
155155
}
156156
# [END dlp_inspect_gcs]

dlp/src/k_anonymity.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ function ($id) {
111111
}
112112
}
113113

114-
// Sleep for half a second to avoid race condition with the job's status.
115-
usleep(500000);
114+
// Sleep for one second to avoid race condition with the job's status.
115+
usleep(1000000);
116116

117117
// Get the updated job
118118
$job = $dlp->getDlpJob($job->getName());
@@ -162,7 +162,7 @@ function ($id) {
162162
}
163163
break;
164164
default:
165-
printf('Unknown job state. Most likely, the job is either running or has not yet started.');
165+
printf('Unexpected job state. Most likely, the job is either running or has not yet started.');
166166
}
167167
}
168168
# [END dlp_k_anomymity]

dlp/src/k_map.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,8 @@ function k_map(
134134
}
135135
}
136136

137-
// Sleep for half a second to avoid race condition with the job's status.
138-
usleep(500000);
137+
// Sleep for one second to avoid race condition with the job's status.
138+
usleep(1000000);
139139

140140
// Get the updated job
141141
$job = $dlp->getDlpJob($job->getName());
@@ -186,7 +186,7 @@ function k_map(
186186
}
187187
break;
188188
default:
189-
print('Unknown job state. Most likely, the job is either running or has not yet started.');
189+
print('Unexpected job state. Most likely, the job is either running or has not yet started.');
190190
}
191191
}
192192
# [END dlp_k_map]

dlp/src/l_diversity.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,8 @@ function ($id) {
118118
}
119119
}
120120

121-
// Sleep for half a second to avoid race condition with the job's status.
122-
usleep(500000);
121+
// Sleep for one second to avoid race condition with the job's status.
122+
usleep(1000000);
123123

124124
// Get the updated job
125125
$job = $dlp->getDlpJob($job->getName());
@@ -179,7 +179,7 @@ function ($id) {
179179
}
180180
break;
181181
default:
182-
printf('Unknown job state. Most likely, the job is either running or has not yet started.');
182+
printf('Unexpected job state. Most likely, the job is either running or has not yet started.');
183183
}
184184
}
185185
# [END dlp_l_diversity]

dlp/src/numerical_stats.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,8 +109,8 @@ function numerical_stats(
109109
}
110110
}
111111

112-
// Sleep for half a second to avoid race condition with the job's status.
113-
usleep(500000);
112+
// Sleep for one second to avoid race condition with the job's status.
113+
usleep(1000000);
114114

115115
// Get the updated job
116116
$job = $dlp->getDlpJob($job->getName());
@@ -151,7 +151,7 @@ function numerical_stats(
151151
}
152152
break;
153153
default:
154-
print('Unknown job state. Most likely, the job is either running or has not yet started.');
154+
print('Unexpected job state. Most likely, the job is either running or has not yet started.');
155155
}
156156
}
157157
# [END dlp_numerical_stats]

storage/test/storageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function testListBuckets()
114114

115115
public function testCreateAndDeleteBuckets()
116116
{
117-
$bucketName = 'test-bucket-' . time();
117+
$bucketName = sprintf('test-bucket-%s-%s', time(), rand());
118118
$bucket = self::$storage->bucket($bucketName);
119119

120120
$this->assertFalse($bucket->exists());

0 commit comments

Comments
 (0)