public async Task InitializeAsync() { Environment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, _functionsWorkerRuntime); _copiedRootPath = Path.Combine(Path.GetTempPath(), "FunctionsE2E", DateTime.UtcNow.ToString("yyMMdd-HHmmss")); FileUtility.CopyDirectory(_rootPath, _copiedRootPath); var extensionsToInstall = GetExtensionsToInstall(); if (extensionsToInstall != null && extensionsToInstall.Length > 0) { TestFunctionHost.WriteNugetPackageSources(_copiedRootPath, "http://www.myget.org/F/azure-appservice/api/v2", "https://www.myget.org/F/azure-appservice-staging/api/v2", "https://api.nuget.org/v3/index.json"); var options = new OptionsWrapper <ScriptJobHostOptions>(new ScriptJobHostOptions { RootScriptPath = _copiedRootPath }); var manager = new ExtensionsManager(options, NullLogger <ExtensionsManager> .Instance); await manager.AddExtensions(extensionsToInstall); } string logPath = Path.Combine(Path.GetTempPath(), @"Functions"); Host = new TestFunctionHost(_copiedRootPath, logPath, ConfigureJobHost); string connectionString = Host.JobHostServices.GetService <IConfiguration>().GetWebJobsConnectionString(ConnectionStringNames.Storage); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); QueueClient = storageAccount.CreateCloudQueueClient(); BlobClient = storageAccount.CreateCloudBlobClient(); TableClient = storageAccount.CreateCloudTableClient(); await CreateTestStorageEntities(); }
public async Task InitializeAsync() { _copiedRootPath = Path.Combine(Path.GetTempPath(), "FunctionsE2E", DateTime.UtcNow.ToString("yyMMdd-HHmmss")); FileUtility.CopyDirectory(_rootPath, _copiedRootPath); var extensionsToInstall = GetExtensionsToInstall(); if (extensionsToInstall != null && extensionsToInstall.Length > 0) { TestFunctionHost.WriteNugetPackageSources(_copiedRootPath, "http://www.myget.org/F/azure-appservice/api/v2", "https://www.myget.org/F/azure-appservice-staging/api/v2", "https://api.nuget.org/v3/index.json"); var options = new OptionsWrapper <ScriptJobHostOptions>(new ScriptJobHostOptions { RootScriptPath = _copiedRootPath }); var manager = new ExtensionsManager(options, NullLogger <ExtensionsManager> .Instance, new TestExtensionBundleManager()); await manager.AddExtensions(extensionsToInstall); } string logPath = Path.Combine(Path.GetTempPath(), @"Functions"); if (!string.IsNullOrEmpty(_functionsWorkerRuntime)) { Environment.SetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeSettingName, _functionsWorkerRuntime); Environment.SetEnvironmentVariable(RpcWorkerConstants.FunctionsWorkerProcessCountSettingName, _workerProcessCount.ToString()); } if (!string.IsNullOrEmpty(_functionsWorkerRuntimeVersion)) { Environment.SetEnvironmentVariable(RpcWorkerConstants.FunctionWorkerRuntimeVersionSettingName, _functionsWorkerRuntimeVersion); } FunctionsSyncManagerMock = new Mock <IFunctionsSyncManager>(MockBehavior.Strict); FunctionsSyncManagerMock.Setup(p => p.TrySyncTriggersAsync(It.IsAny <bool>())).ReturnsAsync(new SyncTriggersResult { Success = true }); Host = new TestFunctionHost(_copiedRootPath, logPath, configureScriptHostWebJobsBuilder: webJobsBuilder => { ConfigureScriptHost(webJobsBuilder); }, configureScriptHostServices: s => { s.AddSingleton <IFunctionsSyncManager>(_ => FunctionsSyncManagerMock.Object); s.AddSingleton <IMetricsLogger>(_ => MetricsLogger); }, configureWebHostServices: s => { s.AddSingleton <IEventGenerator>(_ => EventGenerator); }); string connectionString = Host.JobHostServices.GetService <IConfiguration>().GetWebJobsConnectionString(ConnectionStringNames.Storage); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); QueueClient = storageAccount.CreateCloudQueueClient(); BlobClient = storageAccount.CreateCloudBlobClient(); TableClient = storageAccount.CreateCloudTableClient(); await CreateTestStorageEntities(); }
public async Task InitializeAsync() { if (!string.IsNullOrEmpty(_functionsWorkerRuntime)) { Environment.SetEnvironmentVariable(LanguageWorkerConstants.FunctionWorkerRuntimeSettingName, _functionsWorkerRuntime); } _copiedRootPath = Path.Combine(Path.GetTempPath(), "FunctionsE2E", DateTime.UtcNow.ToString("yyMMdd-HHmmss")); FileUtility.CopyDirectory(_rootPath, _copiedRootPath); // We can currently only support a single extension. if (_extensionName != null && _extensionVersion != null) { TestFunctionHost.WriteNugetPackageSources(_copiedRootPath, "http://www.myget.org/F/azure-appservice/api/v2", "https://api.nuget.org/v3/index.json"); var options = new OptionsWrapper <ScriptJobHostOptions>(new ScriptJobHostOptions { RootScriptPath = _copiedRootPath }); var manager = new ExtensionsManager(options, NullLogger <ExtensionsManager> .Instance); await manager.AddExtensions(new[] { new ExtensionPackageReference { Id = _extensionName, Version = _extensionVersion } }); } Host = new TestFunctionHost(_copiedRootPath, ConfigureJobHost); string connectionString = Host.JobHostServices.GetService <IConfiguration>().GetWebJobsConnectionString(ConnectionStringNames.Storage); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); QueueClient = storageAccount.CreateCloudQueueClient(); BlobClient = storageAccount.CreateCloudBlobClient(); TableClient = storageAccount.CreateCloudTableClient(); await CreateTestStorageEntities(); }
protected EndToEndTestFixture(string rootPath, string testId, string extensionName = null, string extensionVersion = null) { FixtureId = testId; string connectionString = AmbientConnectionStringProvider.Instance.GetConnectionString(ConnectionStringNames.Storage); CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); QueueClient = storageAccount.CreateCloudQueueClient(); BlobClient = storageAccount.CreateCloudBlobClient(); TableClient = storageAccount.CreateCloudTableClient(); CreateTestStorageEntities().Wait(); _copiedRootPath = Path.Combine(Path.GetTempPath(), "FunctionsE2E", DateTime.UtcNow.ToString("yyMMdd-HHmmss")); FileUtility.CopyDirectory(rootPath, _copiedRootPath); // Allow derived classes to limit functions. We'll update host.json in the copied location // so it only affects this fixture's instance. IEnumerable <string> functions = GetActiveFunctions(); string hostJsonPath = Path.Combine(_copiedRootPath, "host.json"); JObject hostJson = JObject.Parse(File.ReadAllText(hostJsonPath)); if (functions != null && functions.Any()) { hostJson["functions"] = JArray.FromObject(functions); } File.WriteAllText(hostJsonPath, hostJson.ToString()); Host = new TestFunctionHost(_copiedRootPath); // We can currently only support a single extension. if (extensionName != null && extensionVersion != null) { Host.SetNugetPackageSources("http://www.myget.org/F/azure-appservice/api/v2", "https://api.nuget.org/v3/index.json"); Host.InstallBindingExtension(extensionName, extensionVersion).Wait(TimeSpan.FromSeconds(30)); } Host.StartAsync().Wait(TimeSpan.FromSeconds(30)); }