Пример #1
0
 public function testPingReturnsPong()
 {
     $stub = $this->getClientStub();
     $stub->expects($this->once())->method('request')->with($this->equalTo('GET'), $this->equalTo('/ping'))->willReturn('pong');
     $provider = new Ping($stub);
     $data = $provider->ping();
     $this->assertEquals('pong', $data);
 }
Пример #2
0
 public function setUp()
 {
     parent::setUp();
     $journal = $this->references->getReference('journal');
     $this->prePing['contacted'] = $journal->getContacted();
     $this->prePing['status'] = $journal->getstatus();
     $this->prePing['ojsVersion'] = $journal->getOjsVersion();
     $this->prePing['title'] = $journal->getTitle();
     $this->prePing['url'] = $journal->getUrl();
     $this->ping = $this->getContainer()->get('ping');
     $client = new Client();
     $this->history = new History();
     $client->getEmitter()->attach($this->history);
     $mock = new Mock([new Response(500, array('Location' => 'http://example.com'))]);
     $client->getEmitter()->attach($mock);
     $this->ping->setClient($client);
     $this->response = $this->ping->ping($journal);
 }
 public function boot($classes)
 {
     $res = $this->client->request('POST', self::API_URL . '/servers', ['http_errors' => false, 'json' => ['organization' => $this->organization, 'name' => uniqid() . '-' . getmypid(), 'image' => $this->image, 'tags' => ['gearman']]]);
     $raw = json_decode($res->getBody(), true);
     $server = $raw['server'];
     $res = $this->client->request('POST', self::API_URL . '/servers/' . $server['id'] . '/action', ['http_errors' => false, 'json' => ['action' => 'poweron']]);
     $raw = json_decode($res->getBody(), true);
     $host = new Ping($server['public_ip']);
     do {
         $latency = $host->ping();
         sleep(1);
     } while (!$latency);
     $consoleAsync = new ConsoleAsync($this->console);
     $bootstrap = tempnam();
     file_put_contents($bootstrap, json_encode($this->getBootstrap()));
     $connection = ssh2_connect($server['public_ip'], 22);
     ssh2_auth_pubkey_file($connection, self::DEFAULT_USER, $this->keys['public'], $this->keys['private']);
     ssh2_spc_send($connection, $tmp, $this->bootstrap);
     ssh2_exec($session, $consoleAsync->getCommandString(new HireWorkerCommand(), ['classes' => $classes], ['type' => Worker::LOCAL]));
 }