Diferencia entre revisiones de «Usuario:ManuelRomero/proyecto/proyectoIternova/borrador»

De WikiEducator
Saltar a: navegación, buscar
 
(7 revisiones intermedias por el mismo usuario no mostrado)
Línea 1: Línea 1:
 
<source lang=php>
 
<source lang=php>
   
+
  /**
    /** SSH - PLUGIN_OUTPUT Y PERFORMANCE DATA */
+
    * @covers Monitorizacion_Controller_Servoces::get_value_of_performance_data
 +
    * @group production
 +
    * @runInSeparateProcess
 +
    */
 +
    public function testGet_value_of_performance_data() {
 +
 
 +
        $array = array(
 +
            array( 'expected' => 0.013585, 'input' => "time=0.013585s;;;0.000000;10.000000", 'type' => 'float' ),
 +
            array( 'expected' => null, 'input' => "time=;;;0.000000;10.000000", 'type' => 'null' ),
 +
        );
 +
        foreach ( $array as $index => $data ) {
 +
//            echo PHP_EOL;
 +
            $value_returned = Monitorizacion_Controller_Services::get_value_of_performance_data( $data[ 'input' ] );
 +
//            echo ">>>" . $data['input'] . PHP_EOL;
 +
//            echo ">>>" . $data['expected'] . PHP_EOL;
 +
//            echo ">>>" . $value_returned . PHP_EOL;
 +
            $this->assertEquals( $data[ 'expected' ], $value_returned, "ERROR: " . $data[ 'expected' ] . " != " . $value_returned, 0.001 );
 +
            $this->assertInternalType( $data[ 'type' ], $value_returned );
 +
        }
 +
 
 +
    }
  
 
     /**
 
     /**
     * * @return array el listado de índice
+
     * @covers Monitorizacion_Controller::service_host_to_string
     * A continuación El listado del array que retorna el nagios
+
     * @group production
     * Se trata de seleccionar qué indices nos interesan
+
     * @runInSeparateProcess
      ["SSH"] =>    object(stdClass)#98 (54) {
+
      ["host_name"] =>      string(12) "5c43117b78e8"
+
      ["service_description"] =>      string(3) "SSH"
+
      ["modified_attributes"] =>      string(1) "0"
+
      ["check_command"] =>      string(9) "check_ssh"
+
      ["check_period"] =>      string(4) "24x7"
+
      ["notification_period"] =>      string(4) "24x7"
+
      ["check_interval"] =>      string(8) "5.000000"
+
      ["retry_interval"] =>      string(8) "1.000000"
+
      ["event_handler"] =>      string(0) ""
+
      ["has_been_checked"] =>      string(1) "1"
+
      ["should_be_scheduled"] =>      string(1) "1"
+
      ["check_execution_time"] =>      string(5) "0.004"
+
      ["check_latency"] =>      string(5) "0.100"
+
      ["check_type"] =>      string(1) "0"
+
      ["current_state"] =>      string(1) "2"
+
      ["last_hard_state"] =>      string(1) "2"
+
      ["last_event_id"] =>      string(2) "14"
+
      ["current_event_id"] =>      string(2) "40"
+
      ["current_problem_id"] =>      string(2) "20"
+
      ["last_problem_id"] =>      string(1) "3"
+
      ["current_attempt"] =>      string(1) "4"
+
      ["max_attempts"] =>      string(1) "4"
+
      ["state_type"] =>      string(1) "1"
+
      ["last_state_change"] =>      string(10) "1479666559"
+
      ["last_hard_state_change"] =>      string(10) "1479666739"
+
      ["last_time_ok"] =>      string(10) "1479592202"
+
      ["last_time_warning"] =>      string(1) "0"
+
      ["last_time_unknown"] =>      string(1) "0"
+
      ["last_time_critical"] =>      string(10) "1480498807"
+
      ["plugin_output"] =>      string(18) "Connection refused"
+
      ["long_plugin_output"] =>      string(0) ""
+
      ["performance_data"] =>      string(0) ""
+
      ["last_check"] =>      string(10) "1480498807"
+
      ["next_check"] =>      string(10) "1480499107"
+
      ["check_options"] =>      scurrent_problem_idtring(1) "0"
+
      ["current_notification_number"] =>      string(1) "0"
+
      ["current_notification_id"] =>      string(1) "0"
+
      ["last_notification"] =>      string(1) "0"
+
      ["next_notification"] =>      string(1) "0"
+
      ["no_more_notifications"] =>      string(1) "0"
+
      ["notifications_enabled"] =>      string(1) "0"
+
      ["active_checks_enabled"] =>      string(1) "1"
+
      ["passive_checks_enabled"] =>      string(1) "1"
+
      ["event_handler_enabled"] =>      string(1) "1"
+
      ["problem_has_been_acknowledged"] =>      string(1) "0"
+
      ["acknowledgement_type"] =>      string(1) "0"
+
      ["flap_detection_enabled"] =>      string(1) "1"
+
      ["failure_prediction_enabled"] =>      string(1) "1"
+
      ["process_performance_data"] =>      string(1) "1"
+
      ["obsess_over_service"] =>      string(1) "1"
+
      ["last_update"] =>      string(10) "1480498887"
+
      ["is_flapping"] =>      string(1) "0"
+
      ["percent_state_change"] =>      string(4) "0.00"
+
      ["scheduled_downtime_depth"] =>      string(1) "0"
+
      }
+
      }
+
 
     */
 
     */
     public static function getIndexSsh() {
+
     public function testService_host_to_string() {
         $index = [
+
// Comparacion de fechas
             "plugin_output",
+
         $array = array(
             "performance_data"
+
             Monitorizacion_Constants::SERVICIO_SSH => 'SSH',
         ];
+
             Monitorizacion_Constants::SERVICIO_HTTP => 'HTTP',
 +
            Monitorizacion_Constants::SERVICIO_MYSQL => 'MYSQL',
 +
            Monitorizacion_Constants::SERVICIO_DISCOS => 'DISK',
 +
            Monitorizacion_Constants::SERVICIO_CPU => 'CPU',
 +
            Monitorizacion_Constants::SERVICIO_PING => 'PING',
 +
            -1 => null
 +
        );
 +
        foreach ( $array as $servicio => $value_expected ) {
 +
            $this->assertEquals( $value_expected, Monitorizacion_Controller::service_host_to_string( $servicio ), "ERROR: $value_expected != " . Monitorizacion_Controller::service_host_to_string( $servicio ) );
 +
         }
  
        return $index;
 
 
     }
 
     }
 
</source>
 
</source>

Última revisión de 11:21 8 sep 2017

 /**
     * @covers Monitorizacion_Controller_Servoces::get_value_of_performance_data
     * @group production
     * @runInSeparateProcess
     */
    public function testGet_value_of_performance_data() {
 
        $array = array(
            array( 'expected' => 0.013585, 'input' => "time=0.013585s;;;0.000000;10.000000", 'type' => 'float' ),
            array( 'expected' => null, 'input' => "time=;;;0.000000;10.000000", 'type' => 'null' ),
        );
        foreach ( $array as $index => $data ) {
//            echo PHP_EOL;
            $value_returned = Monitorizacion_Controller_Services::get_value_of_performance_data( $data[ 'input' ] );
//            echo ">>>" . $data['input'] . PHP_EOL;
//            echo ">>>" . $data['expected'] . PHP_EOL;
//            echo ">>>" . $value_returned . PHP_EOL;
            $this->assertEquals( $data[ 'expected' ], $value_returned, "ERROR: " . $data[ 'expected' ] . " != " . $value_returned, 0.001 );
            $this->assertInternalType( $data[ 'type' ], $value_returned );
        }
 
    }
 
    /**
     * @covers Monitorizacion_Controller::service_host_to_string
     * @group production
     * @runInSeparateProcess
     */
    public function testService_host_to_string() {
// Comparacion de fechas
        $array = array(
            Monitorizacion_Constants::SERVICIO_SSH => 'SSH',
            Monitorizacion_Constants::SERVICIO_HTTP => 'HTTP',
            Monitorizacion_Constants::SERVICIO_MYSQL => 'MYSQL',
            Monitorizacion_Constants::SERVICIO_DISCOS => 'DISK',
            Monitorizacion_Constants::SERVICIO_CPU => 'CPU',
            Monitorizacion_Constants::SERVICIO_PING => 'PING',
            -1 => null
        );
        foreach ( $array as $servicio => $value_expected ) {
            $this->assertEquals( $value_expected, Monitorizacion_Controller::service_host_to_string( $servicio ), "ERROR: $value_expected != " . Monitorizacion_Controller::service_host_to_string( $servicio ) );
        }
 
    }