public async Task Test_Upsert_Get_Drop_Functions() { await SetupTests(); var funcName = "randomFunctionName"; var function = new EventingFunction { Name = funcName, Code = "function OnUpdate(doc, meta) {}", SourceKeySpace = new EventingFunctionKeyspace(_bucketName, ScopeName, _sourceCollection.Name), MetaDataKeySpace = new EventingFunctionKeyspace(_bucketName, ScopeName, _metaCollection.Name), }; await _eventingFunctionManager.UpsertFunctionAsync(function); var read = await _eventingFunctionManager.GetFunctionAsync(funcName); Assert.Equal("function OnUpdate(doc, meta) {}", read.Code); var results = await _eventingFunctionManager.GetAllFunctionsAsync(); Assert.Contains(funcName, results.Select(func => func.Name)); await _eventingFunctionManager.DropFunctionAsync(funcName); results = await _eventingFunctionManager.GetAllFunctionsAsync(); Assert.DoesNotContain(funcName, results.Select(func => func.Name)); }
public async Task Test_Pauses_And_Resumes_Function() { await SetupTests(); var funcName = "deployPauseResumeTestFunc"; var function = new EventingFunction { Name = funcName, Code = "function OnUpdate(doc, meta) {}", SourceKeySpace = new EventingFunctionKeyspace(_bucketName, ScopeName, _sourceCollection.Name), MetaDataKeySpace = new EventingFunctionKeyspace(_bucketName, ScopeName, _metaCollection.Name), }; await _eventingFunctionManager.UpsertFunctionAsync(function); var read = await _eventingFunctionManager.GetFunctionAsync(funcName); Assert.Equal(EventingFunctionProcessingStatus.Paused, read.Settings.ProcessingStatus); await Assert.ThrowsAsync <EventingFunctionNotBootstrappedException>(async() => await _eventingFunctionManager.PauseFunctionAsync(funcName)); await Assert.ThrowsAsync <EventingFunctionNotDeployedException>(async() => await _eventingFunctionManager.ResumeFunctionAsync(funcName)); await _eventingFunctionManager.DeployFunctionAsync(funcName); //Wait until deployed await Retry.DoUntilAsync(() => IsState(funcName, EventingFunctionStatus.Deployed)); read = await _eventingFunctionManager.GetFunctionAsync(funcName); Assert.Equal(EventingFunctionProcessingStatus.Running, read.Settings.ProcessingStatus); await _eventingFunctionManager.PauseFunctionAsync(funcName); await Retry.DoUntilAsync(() => IsState(funcName, EventingFunctionStatus.Paused)); read = await _eventingFunctionManager.GetFunctionAsync(funcName); Assert.Equal(EventingFunctionProcessingStatus.Paused, read.Settings.ProcessingStatus); await _eventingFunctionManager.UndeployFunctionAsync(funcName); //Wait until undeployed await Retry.DoUntilAsync(() => IsState(funcName, EventingFunctionStatus.Undeployed)); await _eventingFunctionManager.DropFunctionAsync(funcName); }
public async Task Test_Deploys_And_Undeploys_Function() { await SetupTests(); var funcName = "deployUndeployTestFunc"; var function = new EventingFunction { Name = funcName, Code = "function OnUpdate(doc, meta) {}", SourceKeySpace = new EventingFunctionKeyspace(_bucketName, ScopeName, _sourceCollection.Name), MetaDataKeySpace = new EventingFunctionKeyspace(_bucketName, ScopeName, _metaCollection.Name), }; await _eventingFunctionManager.UpsertFunctionAsync(function); var read = await _eventingFunctionManager.GetFunctionAsync(funcName); Assert.Equal(EventingFunctionDeploymentStatus.Undeployed, read.Settings.DeploymentStatus); await Assert.ThrowsAsync <EventingFunctionNotDeployedException>(async() => await _eventingFunctionManager.UndeployFunctionAsync(funcName)); await _eventingFunctionManager.DeployFunctionAsync(funcName); //Wait until status is deployed await Retry.DoUntilAsync(() => IsState(funcName, EventingFunctionStatus.Deployed)); read = await _eventingFunctionManager.GetFunctionAsync(funcName); Assert.Equal(EventingFunctionDeploymentStatus.Deployed, read.Settings.DeploymentStatus); await _eventingFunctionManager.UndeployFunctionAsync(funcName); //Wait until status is undeployed await Retry.DoUntilAsync(() => IsState(funcName, EventingFunctionStatus.Undeployed)); read = await _eventingFunctionManager.GetFunctionAsync(funcName); Assert.Equal(EventingFunctionDeploymentStatus.Undeployed, read.Settings.DeploymentStatus); await _eventingFunctionManager.DropFunctionAsync(funcName); }