6minioUpdateCest.php 2.4 KB

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