public async Task GetTailLog() { List <BuilInitialDataObjectDTO> metadataForUploadedBinaryList = await UploadSomeBaseMetaData(1); BuilInitialDataObjectDTO metadataForUploadedBinary = metadataForUploadedBinaryList[metadataForUploadedBinaryList.Count - 1]; string AlgoID = metadataForUploadedBinary.AlgoId; string url = ApiPaths.ALGO_STORE_ALGO_TAIL_LOG; Dictionary <string, string> algoIDTailLog = new Dictionary <string, string>() { { "AlgoId", AlgoID }, { "InstanceId", metadataForUploadedBinary.InstanceId }, { "AlgoClientId", "e658abfc-1779-427c-8316-041a2deb1db8" }, { "Tail", "60" } }; int retryCounter = 0; var algoIDTailLogResponse = await this.Consumer.ExecuteRequest(url, algoIDTailLog, null, Method.GET); while ((algoIDTailLogResponse.Status.Equals(System.Net.HttpStatusCode.InternalServerError) || algoIDTailLogResponse.Status.Equals(System.Net.HttpStatusCode.NotFound)) && retryCounter <= 30) { System.Threading.Thread.Sleep(100000); algoIDTailLogResponse = await this.Consumer.ExecuteRequest(url, algoIDTailLog, null, Method.GET); retryCounter++; } Assert.That(algoIDTailLogResponse.Status, Is.EqualTo(HttpStatusCode.OK)); LogResponseDTO LogObject = JsonUtils.DeserializeJson <LogResponseDTO>(algoIDTailLogResponse.ResponseJson); Assert.NotNull(LogObject); }
public static BuilInitialDataObjectDTO getMetadataForDelete() { lock (PreStoredMetadata) { int r = rnd.Next(PreStoredMetadata.Count); BuilInitialDataObjectDTO editMetadataResponceDTO = PreStoredMetadata[r]; PreStoredMetadata.RemoveAt(r); return(editMetadataResponceDTO); } }
public async Task GetAlgoMetaData(string clientIdTemp) { List <BuilInitialDataObjectDTO> metadataForUploadedBinaryList = await UploadSomeBaseMetaData(1); BuilInitialDataObjectDTO metadataForUploadedBinary = metadataForUploadedBinaryList[metadataForUploadedBinaryList.Count - 1]; MetaDataEntity metaDataEntity = await MetaDataRepository.TryGetAsync(t => t.Id == metadataForUploadedBinary.AlgoId) as MetaDataEntity; if (clientIdTemp.Equals("getFromData")) { clientIdTemp = metaDataEntity.PartitionKey; } string url = ApiPaths.ALGO_STORE_GET_ALGO_METADATA; Dictionary <string, string> quaryParamAlgoData = new Dictionary <string, string>() { { "AlgoId", metadataForUploadedBinary.AlgoId }, { "clientId", clientIdTemp } }; var responceAlgoMetadata = await this.Consumer.ExecuteRequest(url, quaryParamAlgoData, null, Method.GET); Assert.That(responceAlgoMetadata.Status, Is.EqualTo(HttpStatusCode.OK)); GetAlgoMetaDataDTO postInstanceData = JsonUtils.DeserializeJson <GetAlgoMetaDataDTO>(responceAlgoMetadata.ResponseJson); Assert.That(postInstanceData.AlgoId, Is.EqualTo(metadataForUploadedBinary.AlgoId)); Assert.That(postInstanceData.Name, Is.EqualTo(metadataForUploadedBinary.Name)); Assert.That(postInstanceData.Description, Is.EqualTo(metadataForUploadedBinary.Description)); Assert.That(postInstanceData.Date, Is.Not.Null); Assert.That(postInstanceData.Author, Is.Not.Null); Assert.That(postInstanceData.Rating, Is.Zero); Assert.That(postInstanceData.UsersCount, Is.Not.Zero); Assert.That(postInstanceData.AlgoMetaDataInformation, Is.Null); }
public async Task <List <BuilInitialDataObjectDTO> > UploadSomeBaseMetaData(int nuberDto) { string url = ApiPaths.ALGO_STORE_METADATA; string message; List <MetaDataDTO> metadataList = new List <MetaDataDTO>(); List <MetaDataResponseDTO> responceMetadataList = new List <MetaDataResponseDTO>(); for (int i = 0; i < nuberDto; i++) { MetaDataDTO metadata = new MetaDataDTO() { Name = Helpers.RandomString(13), Description = Helpers.RandomString(13) }; metadataList.Add(metadata); } foreach (var metadata in metadataList) { var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(metadata), Method.POST); message = $"{url} returned status: {response.Status} and response: {response.ResponseJson}. Expected: {HttpStatusCode.OK}"; Assert.That(response.Status, Is.EqualTo(HttpStatusCode.OK), message); MetaDataResponseDTO responceMetaData = JsonUtils.DeserializeJson <MetaDataResponseDTO>(response.ResponseJson); responceMetadataList.Add(responceMetaData); } for (int i = 0; i < nuberDto; i++) { url = ApiPaths.ALGO_STORE_UPLOAD_STRING; UploadStringDTO stringDTO = new UploadStringDTO() { AlgoId = responceMetadataList[i].Id, Data = this.CSharpAlgoString }; var response = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(stringDTO), Method.POST); Assert.That(response.Status, Is.EqualTo(HttpStatusCode.NoContent)); instanceForAlgo = GetPopulatedInstanceDataDTO.returnInstanceDataDTO(stringDTO.AlgoId); url = ApiPaths.ALGO_STORE_ALGO_INSTANCE_DATA; var postInstanceDataResponse = await this.Consumer.ExecuteRequest(url, Helpers.EmptyDictionary, JsonUtils.SerializeObject(instanceForAlgo), Method.POST); message = $"{url} returned status: {postInstanceDataResponse.Status} and response: {postInstanceDataResponse.ResponseJson}. Expected: {HttpStatusCode.OK}"; Assert.That(postInstanceDataResponse.Status, Is.EqualTo(HttpStatusCode.OK), message); 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); message = $"{url} returned status: {deployBynaryResponse.Status} and response: {deployBynaryResponse.ResponseJson}. Expected: {HttpStatusCode.OK}"; Assert.That(postInstanceDataResponse.Status, Is.EqualTo(HttpStatusCode.OK)); BuilInitialDataObjectDTO tempDataDTO = new BuilInitialDataObjectDTO() { AlgoId = stringDTO.AlgoId, InstanceId = postInstanceData.InstanceId, Name = responceMetadataList[i].Name, Description = responceMetadataList[i].Description }; initialDTOObjectsList.Add(tempDataDTO); } return(initialDTOObjectsList); }