6minioUpdateCest.php 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. use Symfony\Component\Finder\Finder;
  3. include ('variables.php');
  4. // Include the SDK using the Composer autoloader
  5. date_default_timezone_set('America/Argentina/Buenos_Aires');
  6. require 'vendor/autoload.php';
  7. class minioUpdateCest
  8. {
  9. public function minioUpdate()
  10. {
  11. $cliente=$_GET['CLIENTE'];
  12. $s3 = new Aws\S3\S3Client([
  13. 'version' => 'latest',
  14. 'region' => 'sa-east-1',
  15. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  16. 'use_path_style_endpoint' => true,
  17. 'credentials' => [
  18. 'key' => 'iksop',
  19. 'secret' => '8htoiwn44g204th',
  20. ],
  21. ]);
  22. # subo últimas screen
  23. $head = shell_exec('git rev-parse HEAD');
  24. $head = substr($head,0,-1);
  25. $directorioA = array('01_login/','02_base/','03_ftth/','04_map/','05_stats/');
  26. $cantdir= count($directorioA);
  27. for ($i = 0; $i < $cantdir; $i++)
  28. {
  29. $dir = $directorioA[$i];
  30. $directorio = opendir("./tests/_output/debug/". $cliente. "/" . $head ."/" . $dir);
  31. while ($archivo = readdir($directorio))
  32. {
  33. if (is_dir($archivo))
  34. {
  35. }
  36. else
  37. {
  38. $result = $s3->putObject(array(
  39. 'Bucket' => 'testbucket',
  40. 'Key' => $cliente . "/" . $head. '/'.$dir . $archivo,
  41. 'SourceFile' => './tests/_output/debug/'.$cliente . "/" . $head . "/" . $dir . $archivo
  42. ));
  43. // We can poll the object until it is accessible
  44. $s3->waitUntil('ObjectExists', array(
  45. 'Bucket' => 'testbucket',
  46. 'Key' => $cliente . "/" . $head. '/'.$dir . $archivo
  47. ));
  48. }
  49. }
  50. echo "Directorio '" . $dir . "' actualizado. Commit: " . $head . " Cliente: " . $cliente ."\n" ;
  51. }
  52. //descargar imagenes Source
  53. $s3 = new Aws\S3\S3Client([
  54. 'version' => 'latest',
  55. 'region' => 'sa-east-1',
  56. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  57. 'use_path_style_endpoint' => true,
  58. 'credentials' => [
  59. 'key' => 'iksop',
  60. 'secret' => '8htoiwn44g204th',
  61. ],
  62. ]);
  63. for ($i = 0; $i < $cantdir; $i++)
  64. {
  65. $dir = $directorioA[$i];
  66. shell_exec('mkdir -p ./tests/screenSRC/'. $cliente . "/" . $dir);
  67. }
  68. $iterator = $s3->getIterator('ListObjects', array('Bucket'=> "screen-source",'Prefix'=> $cliente));
  69. foreach ($iterator as $object)
  70. {
  71. //     echo $object['Key'];
  72. $retrive = $s3->getObject([
  73. 'Bucket' => 'screen-source',
  74. 'Key' => $object['Key'],
  75. 'SaveAs' => './tests/screenSRC/' . $object['Key']
  76. ]);
  77. echo "Se descargó el archivo " . $object['Key'] . "\n";
  78. }
  79. }
  80. }