/** * @covers MicrosoftAzure\Storage\Table\TableRestProxy::batch * @covers MicrosoftAzure\Storage\Table\TableRestProxy::insertEntity */ private function batchPositiveOuter($firstConcurType, $seed) { // The random here is not to generate random values, but to // get a good mix of values in the table entities. mt_srand($seed); $concurTypes = ConcurType::values(); $mutatePivots = MutatePivot::values(); $opTypes = OpType::values(); // Main loop. foreach ($opTypes as $firstOpType) { if (!is_null($this->expectConcurrencyFailure($firstOpType, $firstConcurType))) { // Want to know there is at least one part that does not fail. continue; } if ($this->isEmulated() && ($firstOpType == OpType::INSERT_OR_MERGE_ENTITY || $firstOpType == OpType::INSERT_OR_REPLACE_ENTITY)) { // Emulator does not support these operations. continue; } $simpleEntities = TableServiceFunctionalTestData::getSimpleEntities(6); $configs = array(); $firstConfig = new BatchWorkerConfig(); $firstConfig->concurType = $firstConcurType; $firstConfig->opType = $firstOpType; $firstConfig->ent = $simpleEntities[0]; $firstConfig->mutatePivot = $mutatePivots[mt_rand(0, count($mutatePivots))]; array_push($configs, $firstConfig); for ($i = 1; $i < count($simpleEntities); $i++) { $config = new BatchWorkerConfig(); while (!is_null($this->expectConcurrencyFailure($config->opType, $config->concurType))) { $config->concurType = $concurTypes[mt_rand(0, count($concurTypes))]; $config->opType = $opTypes[mt_rand(0, count($opTypes))]; if ($this->isEmulated()) { if ($config->opType == OpType::INSERT_OR_MERGE_ENTITY) { $config->opType = OpType::MERGE_ENTITY; } if ($config->opType == OpType::INSERT_OR_REPLACE_ENTITY) { $config->opType = OpType::UPDATE_ENTITY; } } } $config->mutatePivot = $mutatePivots[mt_rand(0, count($mutatePivots) - 1)]; $config->ent = $simpleEntities[$i]; array_push($configs, $config); } for ($i = 0; $i <= 1; $i++) { $options = $i == 0 ? null : new TableServiceOptions(); if ($this->isEmulated()) { // The emulator has trouble with some batches. for ($j = 0; $j < count($configs); $j++) { $tmpconfigs = array(); $tmpconfigs[] = $configs[$j]; $this->batchWorker($tmpconfigs, $options); } } else { $this->batchWorker($configs, $options); } } } }