예제 #1
0
 public ExampleCapture(string secretsFile, string outputFolder, string outputFolderWorkarounds = null)
 {
     this.secrets                 = ExampleHelpers.ReadSecretsFile(secretsFile);
     this.outputFolder            = outputFolder;
     this.outputFolderWorkarounds = outputFolderWorkarounds;
     this.client      = ExampleHelpers.GetRealClient(secrets);
     this.rmClient    = ExampleHelpers.GetRealRmClient(secrets);
     this.authClient  = ExampleHelpers.GetAuthorizationClient(secrets);
     this.interceptor = new ExampleTracingInterceptor(client.SubscriptionId, client.ApiVersion);
     ServiceClientTracing.AddTracingInterceptor(interceptor);
 }
예제 #2
0
        public void CaptureAllExamples()
        {
            // Note: This should take under two minutes if everything works as expected
            try
            {
                // Delete factory if it exists, before turning on tracing, to give consistent clean state for capture
                EnsureResourceGroupExists();
                EnsureFactoryDoesNotExist();
                ServiceClientTracing.IsEnabled = true;

                // Start Factories operations, leaving factory available
                CaptureFactories_CreateOrUpdate();       // 200
                CaptureFactories_Update();               // 200
                CaptureFactories_ConfigureRepo();        // 200
                CaptureFactories_Get();                  // 200
                CaptureFactories_ListByResourceGroup();  // 200
                CaptureFactories_List();
                CaptureFactories_GetGitHubAccessToken(); // 200, needs real github code in order to return valid access token

                // All Integration runtime operations, creating/deleting integration runtime
                CaptureIntegrationRuntimes_Create(); // 200
                // Before running this method, please make sure the SQL Database "SSISDB" does *NOT* exist in yandongeverest.database.windows.net by SSMS,
                // otherwise the operation will fail. The connection string for this server could be found in GetIntegrationRuntimeResource().
                // Note this operation is quite time consuming, normally it will take more than 30 minutes to finish the starting process.
                CaptureIntegrationRuntimes_Start();             // 200, 202
                CaptureIntegrationRuntimes_Stop();              // 200, 202
                CaptureIntegrationRuntimes_Update();            // 200
                CaptureIntegrationRuntimes_Get();               // 200
                CaptureIntegrationRuntimes_ListByFactory();     // 200
                CaptureIntegrationRuntimes_GetConnectionInfo(); // 200
                CaptureIntegrationRuntimes_ListAuthKeys();      // 200
                CaptureIntegrationRuntimes_RegenerateAuthKey(); // 200
                CaptureIntegrationRuntimes_GetStatus();         // 200
                CaptureIntegrationRuntimes_Upgrade();

                // The following 3 methods invovling a mannual step as prerequisites. We need to install an integration runtime node and register it.
                // After the integration runtime node is online, we can run methods.
                CaptureIntegrationRuntimeNodes_GetIpAddress();
                CaptureIntegrationRuntimeNodes_Update(); // 200
                CaptureIntegrationRuntimeNodes_Delete(); // 200
                CaptureIntegrationRuntimeNodes_Delete(); // 204

                // Start LinkedServices operations, leaving linked service available
                CaptureLinkedServices_Create();        // 200
                CaptureLinkedServices_Update();        // 200
                CaptureLinkedServices_Get();           // 200
                CaptureLinkedServices_ListByFactory(); // 200

                // Start Datasets operations, leaving dataset available
                CaptureDatasets_Create();        // 200
                CaptureDatasets_Update();        // 200
                CaptureDatasets_Get();           // 200
                CaptureDatasets_ListByFactory(); // 200

                // All Pipelines and PipelineRuns operations, creating/running/monitoring/deleting pipeline
                CapturePipelines_Create();                                 // 200
                CapturePipelines_Update();                                 // 200
                CapturePipelines_Get();                                    // 200
                CapturePipelines_ListByFactory();                          // 200
                DateTime beforeStartTime = DateTime.UtcNow.AddMinutes(-1); // allow 1 minute for clock skew
                string   runId           = CapturePipelines_CreateRun();   // 200
                System.Threading.Thread.Sleep(TimeSpan.FromSeconds(120));  // Prefer to get succeeded monitoring result on first attempt even if it slows capture
                DateTime afterEndTime = DateTime.UtcNow.AddMinutes(10);    // allow 10 minutes for run time, monitoring latency, and clock skew
                CapturePipelineRuns_Cancel();

                CapturePipelineRuns_QueryByFactory(runId, beforeStartTime, afterEndTime);     // 200, waits until succeeded so ready to get logs
                CapturePipelineRuns_Get(runId);                                               // 200
                CaptureActivityRuns_QueryByPipelineRun(runId, beforeStartTime, afterEndTime); // 200

                // Start Trigger operations, leaving triggers available
                CaptureTriggers_Create();                                         // 200
                CaptureTriggers_Update();                                         // 200
                CaptureTriggers_Get();                                            // 200
                CaptureTriggers_Start();                                          // 202
                CaptureTriggers_ListByFactory();                                  // 200
                CaptureTriggerRuns_QueryByFactory(beforeStartTime, afterEndTime); // 200
                CaptureTriggers_Stop();                                           // 202

                // Finish Triggers operations, deleting triggers
                CaptureTriggers_Delete();  // 200
                CaptureTriggers_Delete();  // 204

                CapturePipelines_Delete(); // 200
                CapturePipelines_Delete(); // 204

                // Finish Datasets operations, deleting dataset
                CaptureDatasets_Delete(); // 200
                CaptureDatasets_Delete(); // 204

                // Finish LinkedServices operations, deleting linked service
                CaptureLinkedServices_Delete(); // 200
                CaptureLinkedServices_Delete(); // 204

                // Finish integration runtime operations, deleting integration runtime
                CaptureIntegrationRuntimes_Delete(); // 202
                CaptureIntegrationRuntimes_Delete(); // 204

                // Finish Factories operations, deleting factory
                CaptureFactories_Delete(); // 200
                CaptureFactories_Delete(); // 204

                CaptureOperations_List();  // 200
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            finally
            {
                ServiceClientTracing.IsEnabled = false;
                ServiceClientTracing.RemoveTracingInterceptor(this.interceptor);
                // Merge and write all captured examples, whether or not the entire run was successful
                List <Example> examples = ExampleHelpers.GetMergedExamples(interceptor);
                ExampleHelpers.FixExampleModelParameters(examples, client);
                ExampleHelpers.WriteExamples(examples, outputFolder, secrets);
                if (outputFolderWorkarounds != null)
                {
                    ExampleHelpers.ApplyTemporaryWorkaroundsForServiceDefects(examples, client);
                    ExampleHelpers.WriteExamples(examples, outputFolderWorkarounds, secrets);
                }
            }
        }