예제 #1
0
        protected override ConsoleOutput Run(params string[] args)
        {
            string uriPrefix =
                "https://raw.githubusercontent.com/GoogleCloudPlatform/";
            string uriSampleFilePath =
                "dotnet-docs-samples/master/vision/api/VisionTest/data/";
            string filePublicUri =
                uriPrefix + uriSampleFilePath + Path.GetFileName(args[1]);

            return(_retryRobot.Eventually(
                       () => _detect.Run(args[0], filePublicUri)));
        }
        public void Dispose()
        {
            var robot = new RetryRobot()
            {
                MaxTryCount = 10,
                ShouldRetry = (e) => true,
            };

            robot.Eventually(() =>
            {
                _storage.DeleteBucket(BucketName);
            });
        }
        public void TestJobs()
        {
            // Create job.
            DlpServiceClient dlp = DlpServiceClient.Create();
            var dlpJob           = dlp.CreateDlpJob(new CreateDlpJobRequest()
            {
                ParentAsProjectName = new ProjectName(ProjectId),
                RiskJob             = new RiskAnalysisJobConfig()
                {
                    PrivacyMetric = new PrivacyMetric()
                    {
                        CategoricalStatsConfig = new PrivacyMetric.Types.CategoricalStatsConfig()
                        {
                            Field = new FieldId()
                            {
                                Name = "zip_code"
                            }
                        }
                    },
                    SourceTable = new BigQueryTable()
                    {
                        ProjectId = "bigquery-public-data",
                        DatasetId = "san_francisco",
                        TableId   = "bikeshare_trips"
                    }
                }
            });
            Regex dlpJobRegex = new Regex("projects/.*/dlpJobs/r-\\d+");

            _retryRobot.ShouldRetry = ex => true;
            _retryRobot.Eventually(() =>
            {
                // List jobs.
                ConsoleOutput listOutput = _dlp.Run("listJobs", CallingProjectId, "state=DONE", "RiskAnalysisJob");
                Assert.Matches(dlpJobRegex, listOutput.Stdout);

                // Delete created job.
                string jobName             = dlpJobRegex.Match(listOutput.Stdout).Value;
                ConsoleOutput deleteOutput = _dlp.Run("deleteJob", jobName);
                Assert.Contains($"Successfully deleted job {jobName}", deleteOutput.Stdout);
            });
        }
예제 #4
0
        public void Dispose()
        {
            var robot = new RetryRobot()
            {
                MaxTryCount = 10,
                ShouldRetry = (e) => true,
            };

            foreach (var bucket in _garbage)
            {
                foreach (var objectName in bucket.Value)
                {
                    robot.Eventually(() =>
                    {
                        _storage.DeleteObject(bucket.Key, objectName);
                    });
                }
            }
            _garbage.Clear();
        }
예제 #5
0
        public void Dispose()
        {
            RetryRobot robot = new RetryRobot()
            {
                MaxTryCount = 10,
                ShouldRetry = (e) => true,
            };

            foreach (KeyValuePair <string, SortedSet <string> > bucket in _garbage)
            {
                foreach (string objectName in bucket.Value)
                {
                    robot.Eventually(() =>
                    {
                        _storage.DeleteObject(bucket.Key, objectName);
                    });
                }
            }
            _garbage.Clear();
        }
예제 #6
0
        public void TestImportDataFromStream()
        {
            string datasetId         = "datasetForTestImportDataFromStream";
            string newTableId        = "tableForTestImportDataFromStream" + RandomSuffix();
            string gcsUploadTestWord = "exampleJsonFromStream";
            string valueToTest       = "";

            _tablesToDelete.Add(new Tuple <string, string>(datasetId, newTableId));
            _datasetsToDelete.Add(datasetId);
            CreateDataset(datasetId, _client);
            CreateTable(datasetId, newTableId, _client);
            // Import data.
            UploadJsonStreaming(datasetId, newTableId, _client);
            // Query table to get first row and confirm it contains the expected value.
            var    newTable = _client.GetTable(datasetId, newTableId);
            string query    = $"SELECT title, unique_words FROM {newTable} ORDER BY title";

            try
            {
                var retryRobot = new RetryRobot();
                retryRobot.ShouldRetry       = (ex) => ex is InvalidOperationException;
                retryRobot.FirstRetryDelayMs = 100;
                retryRobot.Eventually(() =>
                {
                    BigQueryResults results = AsyncQuery(_projectId, datasetId, newTableId, query, _client);
                    var row     = results.First();
                    valueToTest = row["title"].ToString();
                });
            }
            catch (Exception)
            {
                // All of the retries failed.
            }

            Assert.Equal(gcsUploadTestWord, valueToTest);
        }
예제 #7
0
 /// <summary>Runs StorageSample.exe with the provided arguments</summary>
 /// <returns>The console output of this program</returns>
 public static ConsoleOutput Run(params string[] arguments)
 {
     return(s_retryTransientRpcErrors.Eventually(
                () => s_runner.Run(arguments)));
 }
예제 #8
0
 /// <summary>
 /// Retry action.
 /// Datastore guarantees only eventual consistency.  Many tests write
 /// an entity and then query it afterward, but may not find it immediately.
 /// </summary>
 /// <param name="action"></param>
 private static void Eventually(Action action) =>
 s_retryFailedAssertions.Eventually(action);
예제 #9
0
 void Eventually(Action action) => _retryRobot.Eventually(action);
예제 #10
0
        // [END bigquery_create_table]

        public void DeleteDataset(string datasetId, BigQueryClient client)
        {
            _retryDeleteBusy.Eventually(() => client.DeleteDataset(datasetId));
        }