public async Task DeleteMetadataBadRequest(string badID) { string url = ApiPaths.ALGO_STORE_METADATA; CreateAlgoDTO metadata = new CreateAlgoDTO() { Name = Helpers.RandomString(8), Description = Helpers.RandomString(8) }; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST); Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK)); AlgoDataDTO responseMetaData = JsonUtils.DeserializeJson <AlgoDataDTO>(response.ResponseJson); CascadeDeleteDTO editMetaData = new CascadeDeleteDTO() { AlgoId = badID, InstanceId = responseMetaData.Name }; url = ApiPaths.ALGO_STORE_CASCADE_DELETE; var responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); Assert.That(responceCascadeDelete.Status, Is.EqualTo(HttpStatusCode.BadRequest)); }
public async Task DeleteAlgoInstance(InstanceDataDTO instanceData) { CascadeDeleteDTO deleteInstanceDTO = new CascadeDeleteDTO() { AlgoId = instanceData.AlgoId, AlgoClientId = instanceData.AlgoClientId, InstanceId = instanceData.InstanceId }; var deleteInstanceRequest = await Consumer.ExecuteRequest(ApiPaths.ALGO_STORE_DELETE_INSTANCE, Helpers.EmptyDictionary, JsonUtils.SerializeObject(deleteInstanceDTO), Method.DELETE); Assert.That(deleteInstanceRequest.Status, Is.AnyOf(HttpStatusCode.NoContent, HttpStatusCode.NotFound)); }
public async Task DeleteMetadataBadRequest(string badID) { MetaDataResponseDTO temporaryResponseDTO = DataManager.getMetadataForEdit(); CascadeDeleteDTO editMetaData = new CascadeDeleteDTO() { Id = badID, Name = temporaryResponseDTO.Name }; string url = ApiPaths.ALGO_STORE_CASCADE_DELETE; var responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); Assert.That(responceCascadeDelete.Status, Is.EqualTo(HttpStatusCode.BadRequest)); }
public async Task DeleteMetadataWithDeployedAlgo() { MetaDataResponseDTO temporaryResponseDTO = DataManager.getMetadataForDelete(); CascadeDeleteDTO editMetaData = new CascadeDeleteDTO() { Id = temporaryResponseDTO.Id, Name = temporaryResponseDTO.Name }; string url = ApiPaths.ALGO_STORE_UPLOAD_BINARY; string AlgoId = editMetaData.Id; Dictionary <string, string> quaryParam = new Dictionary <string, string>() { { "AlgoId", AlgoId } }; var responceAllClientMetadata = await this.Consumer.ExecuteRequestFileUpload(url, quaryParam, null, Method.POST, pathFile); Assert.That(responceAllClientMetadata.Status, Is.EqualTo(HttpStatusCode.NoContent)); bool blobExists = await this.BlobRepository.CheckIfBlobExists(AlgoId, BinaryAlgoFileType.JAR); Assert.That(blobExists, Is.EqualTo(true)); DeployBinaryDTO algo = new DeployBinaryDTO() { AlgoId = AlgoId }; url = ApiPaths.ALGO_STORE_DEPLOY_BINARY; var uploadBinaryresponce = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(algo), Method.POST); Assert.That(uploadBinaryresponce.Status, Is.EqualTo(HttpStatusCode.OK)); RuntimeDataEntity runtimeDataEntity = await RuntimeDataRepository.TryGetAsync(t => t.Id == AlgoId) as RuntimeDataEntity; Assert.NotNull(runtimeDataEntity); url = ApiPaths.ALGO_STORE_CASCADE_DELETE; var responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); Assert.That(responceCascadeDelete.Status, Is.EqualTo(HttpStatusCode.NoContent)); MetaDataEntity metaDataEntityDeleted = await MetaDataRepository.TryGetAsync(t => t.Id == editMetaData.Id) as MetaDataEntity; Assert.Null(metaDataEntityDeleted); }
public async Task DeleteMetadataOnlyWithIdParam() { MetaDataResponseDTO temporaryResponseDTO = DataManager.getMetadataForDelete(); CascadeDeleteDTO editMetaData = new CascadeDeleteDTO() { Id = temporaryResponseDTO.Id, Name = "This Name Is Invalid" }; string url = ApiPaths.ALGO_STORE_CASCADE_DELETE; var responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); Assert.That(responceCascadeDelete.Status, Is.EqualTo(HttpStatusCode.NoContent)); MetaDataEntity metaDataEntityDeleted = await MetaDataRepository.TryGetAsync(t => t.Id == editMetaData.Id) as MetaDataEntity; Assert.Null(metaDataEntityDeleted); }
public async Task DeleteMetadataWithUpoadAlgoString() { MetaDataResponseDTO temporaryResponseDTO = DataManager.getMetadataForDelete(); CascadeDeleteDTO editMetaData = new CascadeDeleteDTO() { Id = temporaryResponseDTO.Id, Name = temporaryResponseDTO.Name }; string url = ApiPaths.ALGO_STORE_UPLOAD_STRING; string Algoid = editMetaData.Id; PostUploadStringAlgoDTO uploadedStringDTO = new PostUploadStringAlgoDTO() { AlgoId = Algoid, Data = Helpers.RandomString(300) }; var responceUploadString = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(uploadedStringDTO), Method.POST); Assert.That(responceUploadString.Status, Is.EqualTo(HttpStatusCode.NoContent)); Dictionary <string, string> quaryParamGetString = new Dictionary <string, string>() { { "AlgoId", Algoid } }; var responceGetUploadString = await this.Consumer.ExecuteRequest(url, quaryParamGetString, null, Method.GET); Assert.That(responceGetUploadString.Status, Is.EqualTo(HttpStatusCode.OK)); UploadStringDTO uploadedStringContent = JsonUtils.DeserializeJson <UploadStringDTO>(responceGetUploadString.ResponseJson); Assert.That(uploadedStringDTO.Data, Is.EqualTo(uploadedStringContent.Data)); url = ApiPaths.ALGO_STORE_CASCADE_DELETE; var responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); Assert.That(responceCascadeDelete.Status, Is.EqualTo(HttpStatusCode.NoContent)); MetaDataEntity metaDataEntityDeleted = await MetaDataRepository.TryGetAsync(t => t.Id == editMetaData.Id) as MetaDataEntity; Assert.Null(metaDataEntityDeleted); }
public async Task <List <Response> > ClearAllCascadeDelete(List <MetaDataResponseDTO> listDtoToBeDeleted) { List <Response> responces = new List <Response>(); string url = ApiPaths.ALGO_STORE_CASCADE_DELETE; foreach (var deleteMetadata in listDtoToBeDeleted) { CascadeDeleteDTO editMetaData = new CascadeDeleteDTO() { Id = deleteMetadata.Id, Name = deleteMetadata.Name }; var responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); responces.Add(responceCascadeDelete); } return(responces); }
public async Task <List <Response> > ClearAllCascadeDelete(List <BuilInitialDataObjectDTO> listDtoToBeDeleted) { List <Response> responces = new List <Response>(); string url = ApiPaths.ALGO_STORE_CASCADE_DELETE; int retryCounter = 0; foreach (var deleteMetadata in listDtoToBeDeleted) { CascadeDeleteDTO editMetaData = new CascadeDeleteDTO() { AlgoId = deleteMetadata.AlgoId, InstanceId = deleteMetadata.InstanceId }; var responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); // Currently we can not send cascade delete to kubernatees if he has not build the algo before that thorus not found and we leave data bool isPodMissing = !responceCascadeDelete.ResponseJson.Contains($"Code:504-PodNotFound Message:Pod is not found for {deleteMetadata.InstanceId}"); while (responceCascadeDelete.Status.Equals(HttpStatusCode.NotFound) && isPodMissing && retryCounter <= 30) { System.Threading.Thread.Sleep(10000); responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); isPodMissing = !responceCascadeDelete.ResponseJson.Contains($"Code:504-PodNotFound Message:Pod is not found for {deleteMetadata.InstanceId}"); retryCounter++; } if (isPodMissing) { Assert.That(responceCascadeDelete.Status, Is.EqualTo(HttpStatusCode.NoContent)); } else { Assert.That(responceCascadeDelete.Status, Is.EqualTo(HttpStatusCode.NotFound)); } responces.Add(responceCascadeDelete); } return(responces); }
public async Task DeployStringAlgo() { string url = ApiPaths.ALGO_STORE_METADATA; MetaDataDTO metadata = new MetaDataDTO() { Name = Helpers.RandomString(13), Description = Helpers.RandomString(13) }; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST); MetaDataResponseDTO responceMetaData = JsonUtils.DeserializeJson <MetaDataResponseDTO>(response.ResponseJson); url = ApiPaths.ALGO_STORE_UPLOAD_STRING; UploadStringDTO stringDTO = new UploadStringDTO() { AlgoId = responceMetaData.Id, Data = this.CSharpAlgoString }; var responsetemp = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(stringDTO), Method.POST); Assert.True(responsetemp.Status == System.Net.HttpStatusCode.NoContent); GetPopulatedInstanceDataDTO getinstanceAlgo = new GetPopulatedInstanceDataDTO(); InstanceDataDTO instanceForAlgo = getinstanceAlgo.returnInstanceDataDTO(stringDTO.AlgoId); url = ApiPaths.ALGO_STORE_ALGO_INSTANCE_DATA; var postInstanceDataResponse = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(instanceForAlgo), Method.POST); Assert.That(postInstanceDataResponse.Status == System.Net.HttpStatusCode.OK); InstanceDataDTO postInstanceData = JsonUtils.DeserializeJson <InstanceDataDTO>(postInstanceDataResponse.ResponseJson); url = ApiPaths.ALGO_STORE_DEPLOY_BINARY; DeployBinaryDTO deploy = new DeployBinaryDTO() { AlgoId = stringDTO.AlgoId, InstanceId = postInstanceData.InstanceId, }; var deployBynaryResponse = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(deploy), Method.POST); Assert.That(postInstanceDataResponse.Status == System.Net.HttpStatusCode.OK); url = ApiPaths.ALGO_STORE_CASCADE_DELETE; int retryCounter = 0; CascadeDeleteDTO editMetaData = new CascadeDeleteDTO() { AlgoId = postInstanceData.AlgoId, InstanceId = postInstanceData.InstanceId }; var responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); // Currently we can not send cascade delete to kubernatees if he has not build the algo before that thorus not found and we leave data while (responceCascadeDelete.Status.Equals(System.Net.HttpStatusCode.NotFound) && retryCounter <= 30) { System.Threading.Thread.Sleep(10000); responceCascadeDelete = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(editMetaData), Method.POST); retryCounter++; } Assert.That(responceCascadeDelete.Status == System.Net.HttpStatusCode.NoContent); }