7compareCest.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. <?php
  2. include ('variables.php');
  3. class compareCest
  4. {
  5. public function compare(AcceptanceTester $I)
  6. {
  7. $cliente=$_GET['CLIENTE'];
  8. $hora = date("H:i");
  9. $fecha = date("Y-n-j");
  10. $head = shell_exec('git rev-parse HEAD');
  11. $head = substr($head,0,-1);
  12. $directorioA = array('01_login/','02_base/','03_ftth/','04_map/','05_stats/');
  13. $cantdir= count($directorioA);
  14. for ($i = 0; $i < $cantdir; $i++)
  15. {
  16. $directorio = $directorioA[$i];
  17. shell_exec('mkdir -p ./tests/comp/'. $cliente . "/" . $fecha . "_" . $hora . "_" . $head ."/" . $directorio);
  18. $dir = opendir("tests/_output/debug/" . $cliente . "/" . $head . "/" . $directorio);
  19. while ($archivo = readdir($dir))
  20. {
  21. if (is_dir($archivo))
  22. {
  23. }
  24. else
  25. {
  26. shell_exec('compare tests/_output/debug/'. $cliente . "/" . $head . "/". $directorio . $archivo . ' tests/screenSRC/'. $cliente . "/". $directorio . $archivo . ' tests/comp/'. $cliente . "/" . $fecha . "_" . $hora . "_" . $head . "/" . $directorio .'comp'. $archivo . "\n");
  27. }
  28. }
  29. }
  30. echo "Comparación hecha con éxito";
  31. //subo comparaciones
  32. date_default_timezone_set('America/Argentina/Buenos_Aires');
  33. require 'vendor/autoload.php';
  34. $s3 = new Aws\S3\S3Client([
  35. 'version' => 'latest',
  36. 'region' => 'sa-east-1',
  37. 'endpoint' => 'https://s3.infra.flowdat.com/minio/login',
  38. 'use_path_style_endpoint' => true,
  39. 'credentials' => [
  40. 'key' => 'iksop',
  41. 'secret' => '8htoiwn44g204th',
  42. ],
  43. ]);
  44. //subo al HipChat
  45. $ROOM_ID="drone-ci";
  46. $AUTH_TOKEN="umxTgNpdzUS4egXqpZvGmmYrpLWApANHBKUcciMk";
  47. $MESSAGE1="Inicio Commit ID: " . $head;
  48. $MESSAGE2="Fin Commit ID: " . $head;
  49. shell_exec('curl -H "Content-Type: application/json" -X POST -d "{\"color\": \"purple\", \"message_format\": \"text\", \"message\": \"' . $MESSAGE1 . '\" }" https://api.hipchat.com/v2/room/' . $ROOM_ID . '/notification?auth_token=' . $AUTH_TOKEN);
  50. $directorioA = array('01_login/','02_base/','03_ftth/','04_map/','05_stats/');
  51. for ($i = 0; $i < $cantdir; $i++)
  52. {
  53. $dir = $directorioA[$i];
  54. $directorio = opendir("./tests/comp/" . $cliente . "/" . $fecha . "_" . $hora . "_" . $head . "/" . $dir);
  55. while ($archivo = readdir($directorio))
  56. {
  57. if (is_dir($archivo))
  58. {
  59. }
  60. else
  61. {
  62. $result = $s3->putObject(array(
  63. 'Bucket' => 'comparaciones',
  64. 'Key' => $cliente . "/" . $fecha . "_" . $hora . "_" . $head . '/' . $dir . $archivo,
  65. 'SourceFile' => './tests/comp/'.$cliente . "/" . $fecha . "_" . $hora . "_" . $head ."/" . $dir . $archivo
  66. ));
  67. // We can poll the object until it is accessible
  68. $s3->waitUntil('ObjectExists', array(
  69. 'Bucket' => 'comparaciones',
  70. 'Key' => $cliente . "/" .$fecha . "_" . $hora . "_" . $head . '/' . $dir . $archivo
  71. ));
  72. shell_exec('curl -H "Content-Type: multipart/related; boundary=boundary123456" -F "file=@tests/comp/'.$cliente."/" . $fecha . '_' . $hora . '_' . $head .'/' . $dir . $archivo.'" -X POST https://api.hipchat.com/v2/room/'.$ROOM_ID.'/share/file?auth_token='.$AUTH_TOKEN);
  73. }
  74. }
  75. echo "Directorio de comparación '" . $dir . "' actualizado. Fecha: " . $fecha . "_" . $hora . " Commit: " . $head . " Cliente: " . $cliente ."\n" ;
  76. }
  77. shell_exec('curl -H "Content-Type: application/json" -X POST -d "{\"color\": \"purple\", \"message_format\": \"text\", \"message\": \"' . $MESSAGE2 . '\" }" https://api.hipchat.com/v2/room/' . $ROOM_ID . '/notification?auth_token=' . $AUTH_TOKEN);
  78. }
  79. }