5minioUpdateCest.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/');
  23. for ($i = 0; $i < 4; $i++)
  24. {
  25. $dir = $directorioA[$i];
  26. $directorio = opendir("./tests/_output/debug/" . $head . "/" . $dir);
  27. while ($archivo = readdir($directorio))
  28. {
  29. if (is_dir($archivo))
  30. {
  31. }
  32. else
  33. {
  34. $result = $s3->putObject(array(
  35. 'Bucket' => 'testbucket',
  36. 'Key' => $head.'/'.$dir . $archivo,
  37. 'SourceFile' => './tests/_output/debug/'. $head . "/" . $dir . $archivo
  38. ));
  39. // We can poll the object until it is accessible
  40. $s3->waitUntil('ObjectExists', array(
  41. 'Bucket' => 'testbucket',
  42. 'Key' => $head.'/'.$dir . $archivo
  43. ));
  44. }
  45. }
  46. echo "Directorio '" . $dir . "' actualizado. Commit: " . $head . "\n" ;
  47. }
  48. //descargar HEAD~1
  49. $s3 = new Aws\S3\S3Client([
  50. 'version' => 'latest',
  51. 'region' => 'sa-east-1',
  52. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  53. 'use_path_style_endpoint' => true,
  54. 'credentials' => [
  55. 'key' => 'iksop',
  56. 'secret' => '8htoiwn44g204th',
  57. ],
  58. ]);
  59. $head1 = shell_exec('git rev-parse HEAD~1');
  60. $head1 = substr($head1,0,-1);
  61. for ($i = 0; $i < 4; $i++)
  62. {
  63. $dir = $directorioA[$i];
  64. shell_exec('mkdir -p ./tests/to_compare/' . $head1 . "/" . $dir);
  65. }
  66. $iterator = $s3->getIterator('ListObjects', array('Bucket'=> "testbucket",'Prefix'=> $head1));
  67. foreach ($iterator as $object)
  68. {
  69. //     echo $object['Key'];
  70. $retrive = $s3->getObject([
  71. 'Bucket' => 'testbucket',
  72. 'Key' => $object['Key'],
  73. 'SaveAs' => './tests/to_compare/' . $object['Key']
  74. ]);
  75. echo "Se descargó el archivo " . $object['Key'] . "\n";
  76. }
  77. }
  78. }