def test_read_write_fan_speed_rack2_board1(self): """SNMP read of fan speed. Happy case. Read, write, set back to the original. This is a lot like test_read_write_fan_speed_rack1_board0, but verifies that command routing is going to the correct emulator. NOTE: If a write fails or the write back to original fails, this test may be non-reentrant. To avoid reentrancy issues, no other tests should run against this device at /rack_2/60000001/0004. """ logger.debug('test_read_write_fan_speed_rack2_board1') base_uri = Uri.create(_S.URI_FAN, RACK_2, BOARD_60000001, '0004') response = http.get(base_uri).json() logger.debug(json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))) self._verify_read_fan_response(response, _S.OK, [], 21) response = http.get(Uri.append(base_uri, '300')).json() logger.debug(json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))) self._verify_read_fan_response(response, _S.OK, [], 300) logger.debug('second read') response = http.get(base_uri).json() self._verify_read_fan_response(response, _S.OK, [], 300) logger.debug('second write (to initial)') response = http.get(Uri.append(base_uri, '21')).json() self._verify_read_fan_response(response, _S.OK, [], 21) logger.debug('third read') response = http.get(base_uri).json() self._verify_read_fan_response(response, _S.OK, [], 21)
def test_read_write_power_rack2_board1(self): """SNMP read/write of power. Happy case. Simulates an SNMP PDU. Read, off, read, on, read, cycle, read, off, read. This is a lot like test_read_write_power_rack2_board1, but verifies that command routing is going to the correct emulator. Also here the initial power state is off. NOTE: If a write fails or the write back to original fails, this test may be non-reentrant. To avoid reentrancy issues, no other tests should run against this device at /rack_2/60000001/0012. """ logger.debug('test_read_write_power_rack2_board1') base_uri = Uri.create(_S.URI_POWER, RACK_2, BOARD_60000000, '0012') response = http.get(base_uri).json() logger.debug( json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))) self._verify_power_response(response, 26, False, True, _S.OFF) logger.debug('set power off') response = http.get(Uri.append(base_uri, _S.OFF)).json() logger.debug( json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))) self._verify_power_response(response, 26, False, True, _S.OFF) logger.debug('second read') response = http.get(base_uri).json() self._verify_power_response(response, 26, False, True, _S.OFF) logger.debug('set power on') response = http.get(Uri.append(base_uri, _S.ON)).json() self._verify_power_response(response, 26, False, True, _S.ON) logger.debug('third read') response = http.get(base_uri).json() self._verify_power_response(response, 26, False, True, _S.ON) logger.debug('set power cycle') response = http.get(Uri.append(base_uri, _S.CYCLE)).json() self._verify_power_response(response, 26, False, True, _S.ON) logger.debug('fourth read') response = http.get(base_uri).json() self._verify_power_response(response, 26, False, True, _S.ON) logger.debug('set power off') response = http.get(Uri.append(base_uri, _S.OFF)).json() self._verify_power_response(response, 26, False, True, _S.OFF) logger.debug('fifth read') response = http.get(base_uri).json() self._verify_power_response(response, 26, False, True, _S.OFF)
def test_led_set_invalid_states_rack2_board2(self): """SNMP write of LED. Sad casee. NOTE: If a write fails or the write back to original fails, this test may be non-reentrant. """ # Make sure the device is there. logger.debug('test_led_set_color_without_blink_rack2_board2') base_uri = Uri.create(_S.URI_LED, RACK_2, BOARD_60000001, '000c') response = http.get(base_uri).json() logger.debug( json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))) self._verify_led_response(response, _S.ON, 'ff0000', _S.BLINK_OFF) logger.debug('set onn') try: http.get(Uri.append(base_uri, 'onn')) self.fail(EXPECTED_VAPOR_HTTP_ERROR) except VaporHTTPError as e: # You'll get a 404 here because the blueprint does not exist. self._verify_vapor_http_error(e, 500, _S.ERROR_INVALID_STATE_LED) logger.debug('set color out of range') try: http.get(Uri.append(base_uri, _S.ON, '1000000', _S.BLINK_OFF)) self.fail(EXPECTED_VAPOR_HTTP_ERROR) except VaporHTTPError as e: # You'll get a 404 here because the blueprint does not exist. self._verify_vapor_http_error(e, 500, _S.ERROR_INVALID_COLOR_LED) logger.debug('set invalid blink') try: http.get(Uri.append(base_uri, _S.ON, '000000', 'blank')) self.fail('Should have raised VaporHTTPError.') except VaporHTTPError as e: # You'll get a 404 here because the blueprint does not exist. self._verify_vapor_http_error(e, 500, _S.ERROR_INVALID_BLINK_LED) logger.debug('empty check') try: http.get(Uri.append(base_uri, '', '', '')) self.fail('Should have raised VaporHTTPError.') except VaporHTTPError as e: # You'll get a 404 here because the blueprint does not exist. self._verify_vapor_http_error(e, 404, _S.ERROR_FLASK_404) logger.debug('empty check two') try: http.get(Uri.append(base_uri, '', 'F', _S.BLINK_OFF)) self.fail('Should have raised VaporHTTPError.') except VaporHTTPError as e: # You'll get a 404 here because the blueprint does not exist. self._verify_vapor_http_error(e, 404, _S.ERROR_FLASK_404)
def test_led_set_color_without_blink_rack2_board1(self): """SNMP read/write of LED. Sad case. NOTE: If a write fails or the write back to original fails, this test may be non-reentrant. """ # Make sure the device is there. logger.debug('test_led_set_color_without_blink_rack2_board1') base_uri = Uri.create(_S.URI_LED, RACK_2, BOARD_60000001, '000c') response = http.get(base_uri).json() logger.debug(json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))) self._verify_led_response(response, _S.ON, 'ff0000', _S.BLINK_OFF) logger.debug('set color without blink') try: http.get(Uri.append(base_uri, _S.ON, '0000FF')) self.fail(EXPECTED_VAPOR_HTTP_ERROR) except VaporHTTPError as e: # You'll get a 404 here because the blueprint does not exist. self._verify_vapor_http_error(e, 404, _S.ERROR_FLASK_404)
def test_read_write_led_rack2_board1(self): """SNMP read/write of LED. Happy case. Read, off, read, on, read, cycle, read, off, read. This is a lot like test_read_write_led_rack1_board0, but verifies that command routing is going to the correct emulator. (Initial read is different.) NOTE: If a write fails or the write back to original fails, this test may be non-reentrant. To avoid reentrancy issues, no other tests should run against this device at /rack_1/60000000/000d. """ logger.debug('test_read_write_led_rack2_board1') base_uri = Uri.create(_S.URI_LED, RACK_2, BOARD_60000001, '000d') response = http.get(base_uri).json() logger.debug(json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))) self._verify_led_response(response, _S.ON, 'ffffff', _S.BLINK_ON) logger.debug('set led off') response = http.get(Uri.append(base_uri, _S.OFF)).json() logger.debug(json.dumps(response, sort_keys=True, indent=4, separators=(',', ': '))) self._verify_led_response(response, _S.OFF, 'ffffff', _S.BLINK_ON) logger.debug('second read') response = http.get(base_uri).json() self._verify_led_response(response, _S.OFF, 'ffffff', _S.BLINK_ON) logger.debug('set led on') response = http.get(Uri.append(base_uri, _S.ON)).json() self._verify_led_response(response, _S.ON, 'ffffff', _S.BLINK_ON) logger.debug('third read') response = http.get(base_uri).json() self._verify_led_response(response, _S.ON, 'ffffff', _S.BLINK_ON) logger.debug('set led on, color blue, blink on') response = http.get(Uri.append(base_uri, _S.ON, 'FF', _S.BLINK_ON)).json() self._verify_led_response(response, _S.ON, '0000ff', _S.BLINK_ON) logger.debug('fourth read') response = http.get(base_uri).json() self._verify_led_response(response, _S.ON, '0000ff', _S.BLINK_ON) logger.debug('set led on, color different, blink off') response = http.get(Uri.append(base_uri, _S.ON, 'f0f0f0', _S.BLINK_OFF)).json() self._verify_led_response(response, _S.ON, 'f0f0f0', _S.BLINK_OFF) logger.debug('fifth read') response = http.get(base_uri).json() self._verify_led_response(response, _S.ON, 'f0f0f0', _S.BLINK_OFF) logger.debug('set led on, color as above, blink on') response = http.get(Uri.append(base_uri, _S.ON, 'f0f0f0', _S.BLINK_ON)).json() self._verify_led_response(response, _S.ON, 'f0f0f0', _S.BLINK_ON) logger.debug('sixth read') response = http.get(base_uri).json() self._verify_led_response(response, _S.ON, 'f0f0f0', _S.BLINK_ON) logger.debug('set led on, color back to original, blink on') response = http.get(Uri.append(base_uri, _S.ON, 'ffffff', _S.BLINK_ON)).json() self._verify_led_response(response, _S.ON, 'ffffff', _S.BLINK_ON) logger.debug('seventh read') response = http.get(base_uri).json() self._verify_led_response(response, _S.ON, 'ffffff', _S.BLINK_ON)