Skip to content

Commit 8c63cfb

Browse files
nnegreyAce Nassri
authored andcommitted
test: address flaky v3 tests, by using unique identifiers (#366)
1 parent cf33016 commit 8c63cfb

8 files changed

+16
-14
lines changed

translate/test/v3/translate_batch_translate_text_with_glossary.test.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const REGION_TAG = 'translate_batch_translate_text_with_glossary';
2828
describe(REGION_TAG, () => {
2929
const translationClient = new TranslationServiceClient();
3030
const location = 'us-central1';
31-
const glossaryId = 'my-fake_glossary';
31+
const glossaryId = `my_test_glossary_${uuid.v4()}`;
3232
const bucketUuid = uuid.v4();
3333
const bucketName = `translation-${bucketUuid}/BATCH_TRANSLATION_OUTPUT/`;
3434
const storage = new Storage();
@@ -71,8 +71,7 @@ describe(REGION_TAG, () => {
7171
await operation.promise();
7272
});
7373

74-
// see: https://github.com/googleapis/nodejs-translate/issues/364
75-
it.skip('should batch translate the input text with a glossary [FLAKY]', async () => {
74+
it('should batch translate the input text with a glossary', async () => {
7675
const projectId = await translationClient.getProjectId();
7776
const inputUri = `gs://cloud-samples-data/translation/text.txt`;
7877

translate/test/v3/translate_batch_translate_text_with_glossary_and_model.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ const REGION_TAG = 'translate_batch_translate_text_with_glossary_and_model';
2828
describe(REGION_TAG, () => {
2929
const translationClient = new TranslationServiceClient();
3030
const location = 'us-central1';
31-
const glossaryId = 'my-fake_glossary';
31+
const glossaryId = `my_test_glossary_${uuid.v4()}`;
3232
const modelId = 'TRL1218052175389786112';
3333
const bucketUuid = uuid.v4();
3434
const bucketName = `translation-${bucketUuid}/BATCH_TRANSLATION_OUTPUT/`;

translate/test/v3/translate_create_glossary.test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,19 @@
1717
const {assert} = require('chai');
1818
const {TranslationServiceClient} = require('@google-cloud/translate');
1919
const cp = require('child_process');
20+
const uuid = require('uuid');
2021

2122
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2223

2324
const REGION_TAG = 'translate_create_glossary';
2425

2526
describe(REGION_TAG, () => {
2627
const translationClient = new TranslationServiceClient();
28+
const glossaryId = `my_test_glossary_${uuid.v4()}`;
29+
const location = 'us-central1';
2730

2831
it('should create a glossary', async function() {
2932
const projectId = await translationClient.getProjectId();
30-
const location = 'us-central1';
31-
const glossaryId = 'test-glossary';
3233
const output = execSync(
3334
`node v3/${REGION_TAG}.js ${projectId} ${location} ${glossaryId}`
3435
);
@@ -40,8 +41,6 @@ describe(REGION_TAG, () => {
4041

4142
after('cleanup for glossary create', async function() {
4243
const projectId = await translationClient.getProjectId();
43-
const location = 'us-central1';
44-
const glossaryId = 'test-glossary';
4544
// Delete the glossary to clean up
4645
const request = {
4746
parent: `projects/${projectId}/locations/${location}`,

translate/test/v3/translate_delete_glossary.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
const {assert} = require('chai');
1818
const {TranslationServiceClient} = require('@google-cloud/translate');
1919
const cp = require('child_process');
20+
const uuid = require('uuid');
2021

2122
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2223

@@ -25,7 +26,7 @@ const REGION_TAG = 'translate_delete_glossary';
2526
describe(REGION_TAG, () => {
2627
const translationClient = new TranslationServiceClient();
2728
const location = 'us-central1';
28-
const glossaryId = 'glossary';
29+
const glossaryId = `my_test_glossary_${uuid.v4()}`;
2930

3031
before(async function() {
3132
// Add a glossary to be deleted

translate/test/v3/translate_get_glossary.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
const {assert} = require('chai');
1818
const {TranslationServiceClient} = require('@google-cloud/translate');
1919
const cp = require('child_process');
20+
const uuid = require('uuid');
2021

2122
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
2223

@@ -25,7 +26,7 @@ const REGION_TAG = 'translate_get_glossary';
2526
describe(REGION_TAG, () => {
2627
const translationClient = new TranslationServiceClient();
2728
const location = 'us-central1';
28-
const glossaryId = 'test-glossary';
29+
const glossaryId = `my_test_glossary_${uuid.v4()}`;
2930

3031
before(async function() {
3132
// Add a glossary to get
@@ -62,7 +63,7 @@ describe(REGION_TAG, () => {
6263
const output = execSync(
6364
`node v3/${REGION_TAG}.js ${projectId} ${location} ${glossaryId}`
6465
);
65-
assert.match(output, /test-glossary/);
66+
assert.match(output, /my_test_glossary_/);
6667
});
6768

6869
after(async function() {

translate/test/v3/translate_list_glossary.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const REGION_TAG = 'translate_list_glossary';
2626
describe(REGION_TAG, () => {
2727
const translationClient = new TranslationServiceClient();
2828
const location = 'us-central1';
29-
const glossaryId = `test-glossary-${uuid.v4()}`;
29+
const glossaryId = `my_test_glossary_${uuid.v4()}`;
3030

3131
before(async function() {
3232
// Add a glossary to be deleted

translate/test/v3/translate_translate_text_with_glossary.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
const {assert} = require('chai');
1818
const {TranslationServiceClient} = require('@google-cloud/translate');
19+
const uuid = require('uuid');
1920
const cp = require('child_process');
2021

2122
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
@@ -25,7 +26,7 @@ const REGION_TAG = 'translate_translate_text_with_glossary';
2526
describe(REGION_TAG, () => {
2627
const translationClient = new TranslationServiceClient();
2728
const location = 'us-central1';
28-
const glossaryId = 'test-glossary';
29+
const glossaryId = `my_test_glossary_${uuid.v4()}`;
2930

3031
before(async function() {
3132
// Add a glossary to be translate with

translate/test/v3/translate_translate_text_with_glossary_and_model.test.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
const {assert} = require('chai');
1818
const {TranslationServiceClient} = require('@google-cloud/translate');
19+
const uuid = require('uuid');
1920
const cp = require('child_process');
2021

2122
const execSync = cmd => cp.execSync(cmd, {encoding: 'utf-8'});
@@ -25,7 +26,7 @@ const REGION_TAG = 'translate_translate_text_with_glossary_and_model';
2526
describe(REGION_TAG, () => {
2627
const translationClient = new TranslationServiceClient();
2728
const location = 'us-central1';
28-
const glossaryId = 'test-glossary';
29+
const glossaryId = `my_test_glossary_${uuid.v4()}`;
2930
const modelId = 'TRL1218052175389786112';
3031

3132
before(async function() {

0 commit comments

Comments
 (0)