public void UpdateDataset() { var client = BigQueryClient.Create(_fixture.ProjectId); var id = _fixture.CreateDatasetId(); var original = client.CreateDataset(id, new CreateDatasetOptions { Description = "Description1", FriendlyName = "FriendlyName1" }); // Modify locally... original.Resource.Description = "Description2"; original.Resource.FriendlyName = "FriendlyName2"; // FIXME: I shouldn't need to do this. original.Resource.ETag = client.GetDataset(id).Resource.ETag; // Check the results of the update var updated = original.Update(); Assert.Equal("Description2", updated.Resource.Description); Assert.Equal("FriendlyName2", updated.Resource.FriendlyName); // Check that it's still valid if fetched directly var fetched = client.GetDataset(id); Assert.Equal("Description2", fetched.Resource.Description); Assert.Equal("FriendlyName2", fetched.Resource.FriendlyName); }
public void GetOrCreateTable_HighContention() { var client = BigQueryClient.Create(_fixture.ProjectId); var datasetId = _fixture.CreateDatasetId(); client.CreateDataset(datasetId); int successes = 0; ConcurrentBag <Exception> exceptions = new ConcurrentBag <Exception>(); var threads = Enumerable.Range(0, 5).Select(_ => new Thread(() => { try { client.GetOrCreateTable(datasetId, "highcontention", new Table()); Interlocked.Increment(ref successes); } catch (Exception ex) { exceptions.Add(ex); } })).ToList(); // Start all the threads at roughly the same time threads.ForEach(t => t.Start()); // ... and wait for them all to finish threads.ForEach(t => t.Join(5000)); Assert.Empty(exceptions); // If any threads timed out, we won't have enough successes. Assert.Equal(threads.Count, successes); }
public void CreateDataset_InitialEtag() { var client = BigQueryClient.Create(_fixture.ProjectId); var id = _fixture.CreateDatasetId(); var created = client.CreateDataset(id, new CreateDatasetOptions { Description = "Description1", FriendlyName = "FriendlyName1" }); var fetched = client.GetDataset(id); Assert.Equal(created.Resource.ETag, fetched.Resource.ETag); }