diff --git a/.github/workflows/python-integration-test.yml b/.github/workflows/python-integration-test.yml index da45fa8..45f0fbe 100644 --- a/.github/workflows/python-integration-test.yml +++ b/.github/workflows/python-integration-test.yml @@ -3,15 +3,6 @@ name: Python Integration Test on: push: branches: - - dev - - staging - - main - paths-ignore: - - version - pull_request: - branches: - - dev - - staging - main paths-ignore: - version @@ -19,30 +10,40 @@ on: jobs: test: name: Integration Tests - runs-on: ubuntu-latest + runs-on: [self-hosted, linux, ARM64] strategy: fail-fast: false matrix: python-version: ["3.9"] steps: - - name: Checkout + - name: Checkout (PR) if: ${{ github.event_name == 'pull_request'}} uses: actions/checkout@v3 with: ref: ${{ github.head_ref }} - - name: Checkout + + - name: Checkout (Push) if: ${{ github.event_name == 'push'}} uses: actions/checkout@v3 with: ref: ${{ github.ref_name }} + - name: Install Dependencies run: | - python -m pip install --upgrade pip python -m venv venv_test source venv_test/bin/activate python -m pip install -r requirements_test.txt + + - name: Check edgepi-rpc-server installation + run: | + if ! dpkg -s edgepi-rpc-server >/dev/null 2>&1 + then + echo "edgepi-rpc-server is not installed. Exiting..." + exit 1 + fi + - name: Test with pytest run: | source venv_test/bin/activate - pytest ./tests/integration/test_module.py -vvs # change this back to all integration tests once server issue is fixed + pytest ./tests/integration -vvs diff --git a/edgepi_rpc_client/client_rpc_channel.py b/edgepi_rpc_client/client_rpc_channel.py index 6200229..4f3f814 100644 --- a/edgepi_rpc_client/client_rpc_channel.py +++ b/edgepi_rpc_client/client_rpc_channel.py @@ -3,7 +3,7 @@ import logging from google.protobuf import service import zmq -from edgepirpc.protos import rpc_pb2 as rpc_pb +from rpc_generated_protobufs import rpc_pb2 as rpc_pb _logger = logging.getLogger(__name__) logging.basicConfig( diff --git a/edgepi_rpc_client/services/adc/adc_pb_enums.py b/edgepi_rpc_client/services/adc/adc_pb_enums.py index 6abeeb7..5bc4e61 100644 --- a/edgepi_rpc_client/services/adc/adc_pb_enums.py +++ b/edgepi_rpc_client/services/adc/adc_pb_enums.py @@ -1,6 +1,6 @@ """Client enums to protobuf adc enums""" from enum import Enum -from edgepirpc.protos import adc_pb2 as adc_pb +from rpc_generated_protobufs import adc_pb2 as adc_pb # pylint: disable=no-member class AnalogIn(Enum): diff --git a/edgepi_rpc_client/services/adc/client_adc_service.py b/edgepi_rpc_client/services/adc/client_adc_service.py index 22e24d7..87d8dda 100644 --- a/edgepi_rpc_client/services/adc/client_adc_service.py +++ b/edgepi_rpc_client/services/adc/client_adc_service.py @@ -2,7 +2,7 @@ Client for adc service """ import logging -from edgepirpc.protos import adc_pb2 as adc_pb +from rpc_generated_protobufs import adc_pb2 as adc_pb from edgepi_rpc_client.client_rpc_channel import ClientRpcChannel from edgepi_rpc_client.util.helpers import ( filter_arg_values, create_config_request_from_args, get_server_response diff --git a/edgepi_rpc_client/services/dac/client_dac_service.py b/edgepi_rpc_client/services/dac/client_dac_service.py index aa1aafd..4fdb167 100644 --- a/edgepi_rpc_client/services/dac/client_dac_service.py +++ b/edgepi_rpc_client/services/dac/client_dac_service.py @@ -2,7 +2,7 @@ Client for Dac service. Utilizes ClientRpcChannel to send/receive and serialize/deserialize messages """ -from edgepirpc.protos import dac_pb2 as dac_pb +from rpc_generated_protobufs import dac_pb2 as dac_pb from edgepi_rpc_client.client_rpc_channel import ClientRpcChannel from edgepi_rpc_client.services.dac.dac_pb_enums import DACChannel from edgepi_rpc_client.util.helpers import get_server_response diff --git a/edgepi_rpc_client/services/dac/dac_pb_enums.py b/edgepi_rpc_client/services/dac/dac_pb_enums.py index 40628b1..908956d 100644 --- a/edgepi_rpc_client/services/dac/dac_pb_enums.py +++ b/edgepi_rpc_client/services/dac/dac_pb_enums.py @@ -1,6 +1,6 @@ """Client Enum to Protobuf Enum mapping""" from enum import Enum, unique -from edgepirpc.protos import dac_pb2 as dac_pb +from rpc_generated_protobufs import dac_pb2 as dac_pb # pylint: disable=no-member @unique diff --git a/edgepi_rpc_client/services/din/client_din_service.py b/edgepi_rpc_client/services/din/client_din_service.py index 2bb740b..fb0747e 100644 --- a/edgepi_rpc_client/services/din/client_din_service.py +++ b/edgepi_rpc_client/services/din/client_din_service.py @@ -2,7 +2,7 @@ Client for Din service. Utilizes ClientRpcChannel to send/receive and serialize/deserialize messages """ -from edgepirpc.protos import din_pb2 as din_pb +from rpc_generated_protobufs import din_pb2 as din_pb from edgepi_rpc_client.client_rpc_channel import ClientRpcChannel from edgepi_rpc_client.services.din.din_pb_enums import DinPins from edgepi_rpc_client.util.helpers import get_server_response diff --git a/edgepi_rpc_client/services/din/din_pb_enums.py b/edgepi_rpc_client/services/din/din_pb_enums.py index 616df61..d99655f 100644 --- a/edgepi_rpc_client/services/din/din_pb_enums.py +++ b/edgepi_rpc_client/services/din/din_pb_enums.py @@ -1,6 +1,6 @@ """Client Enum to Protobuf Enum mapping""" from enum import Enum, unique -from edgepirpc.protos import din_pb2 as din_pb +from rpc_generated_protobufs import din_pb2 as din_pb # pylint: disable=no-member @unique diff --git a/edgepi_rpc_client/services/dout/client_dout_service.py b/edgepi_rpc_client/services/dout/client_dout_service.py index adb994d..fccabaf 100644 --- a/edgepi_rpc_client/services/dout/client_dout_service.py +++ b/edgepi_rpc_client/services/dout/client_dout_service.py @@ -2,7 +2,7 @@ Client for Dout service. Utilizes ClientRpcChannel to send/receive and serialize/deserialize messages """ -from edgepirpc.protos import dout_pb2 as dout_pb +from rpc_generated_protobufs import dout_pb2 as dout_pb from edgepi_rpc_client.client_rpc_channel import ClientRpcChannel from edgepi_rpc_client.services.dout.dout_pb_enums import DoutPins, DoutTriState from edgepi_rpc_client.util.helpers import get_server_response diff --git a/edgepi_rpc_client/services/dout/dout_pb_enums.py b/edgepi_rpc_client/services/dout/dout_pb_enums.py index 7f6fdfa..5be3ec9 100644 --- a/edgepi_rpc_client/services/dout/dout_pb_enums.py +++ b/edgepi_rpc_client/services/dout/dout_pb_enums.py @@ -1,7 +1,7 @@ """Client enums to protobuf led enums""" # pylint: disable=no-member from enum import Enum, unique -from edgepirpc.protos import dout_pb2 as dout_pb +from rpc_generated_protobufs import dout_pb2 as dout_pb @unique class DoutPins(Enum): diff --git a/edgepi_rpc_client/services/led/client_led_service.py b/edgepi_rpc_client/services/led/client_led_service.py index fd3f237..95cb22f 100644 --- a/edgepi_rpc_client/services/led/client_led_service.py +++ b/edgepi_rpc_client/services/led/client_led_service.py @@ -2,7 +2,7 @@ Client for led service. Utilizes ClientRpcChannel to send/receive and serialize/deserialize messages """ -from edgepirpc.protos import led_pb2 as led_pb +from rpc_generated_protobufs import led_pb2 as led_pb from edgepi_rpc_client.client_rpc_channel import ClientRpcChannel from edgepi_rpc_client.services.led.led_pb_enums import LEDPins from edgepi_rpc_client.util.helpers import get_server_response diff --git a/edgepi_rpc_client/services/led/led_pb_enums.py b/edgepi_rpc_client/services/led/led_pb_enums.py index 1562d74..7f64031 100644 --- a/edgepi_rpc_client/services/led/led_pb_enums.py +++ b/edgepi_rpc_client/services/led/led_pb_enums.py @@ -1,7 +1,7 @@ """Client enums to protobuf led enums""" # pylint: disable=no-member from enum import Enum, unique -from edgepirpc.protos import led_pb2 as led_pb +from rpc_generated_protobufs import led_pb2 as led_pb @unique class LEDPins(Enum): diff --git a/edgepi_rpc_client/services/pwm/client_pwm_service.py b/edgepi_rpc_client/services/pwm/client_pwm_service.py index c205545..af96ac7 100644 --- a/edgepi_rpc_client/services/pwm/client_pwm_service.py +++ b/edgepi_rpc_client/services/pwm/client_pwm_service.py @@ -1,6 +1,6 @@ """Client for PWM service""" import logging -from edgepirpc.protos import pwm_pb2 as pwm_pb +from rpc_generated_protobufs import pwm_pb2 as pwm_pb from edgepi_rpc_client.client_rpc_channel import ClientRpcChannel from edgepi_rpc_client.util.helpers import ( filter_arg_values, diff --git a/edgepi_rpc_client/services/pwm/pwm_pb_enums.py b/edgepi_rpc_client/services/pwm/pwm_pb_enums.py index 4b442e0..0d7fc34 100644 --- a/edgepi_rpc_client/services/pwm/pwm_pb_enums.py +++ b/edgepi_rpc_client/services/pwm/pwm_pb_enums.py @@ -1,7 +1,8 @@ """Client enums to protobuf PWM enums""" from enum import Enum -from edgepirpc.protos import pwm_pb2 as pwm_pb +from rpc_generated_protobufs import pwm_pb2 as pwm_pb +# pylint: disable=no-member class PWMPins(Enum): """PWMPins Enum""" PWM1 = pwm_pb.PWMPins.PWM1 diff --git a/edgepi_rpc_client/services/relay/client_relay_service.py b/edgepi_rpc_client/services/relay/client_relay_service.py index 74cba15..724c144 100644 --- a/edgepi_rpc_client/services/relay/client_relay_service.py +++ b/edgepi_rpc_client/services/relay/client_relay_service.py @@ -1,7 +1,7 @@ """ Client for Relay Service """ -from edgepirpc.protos import relay_pb2 as relay_pb +from rpc_generated_protobufs import relay_pb2 as relay_pb from edgepi_rpc_client.client_rpc_channel import ClientRpcChannel from edgepi_rpc_client.util.helpers import get_server_response diff --git a/edgepi_rpc_client/services/tc/client_tc_service.py b/edgepi_rpc_client/services/tc/client_tc_service.py index ffdadad..c9d36e6 100644 --- a/edgepi_rpc_client/services/tc/client_tc_service.py +++ b/edgepi_rpc_client/services/tc/client_tc_service.py @@ -3,7 +3,7 @@ and serialize/deserialize messages. """ import logging -from edgepirpc.protos import tc_pb2 as tc_pb +from rpc_generated_protobufs import tc_pb2 as tc_pb from edgepi_rpc_client.util.helpers import ( create_config_request_from_args, filter_arg_values, get_server_response ) diff --git a/edgepi_rpc_client/services/tc/tc_pb_enums.py b/edgepi_rpc_client/services/tc/tc_pb_enums.py index d74a8cc..f5f9a34 100644 --- a/edgepi_rpc_client/services/tc/tc_pb_enums.py +++ b/edgepi_rpc_client/services/tc/tc_pb_enums.py @@ -1,7 +1,7 @@ """Client enums to protobuf tc enums""" #pylint: disable=no-member from enum import Enum, unique -from edgepirpc.protos import tc_pb2 as tc_pb +from rpc_generated_protobufs import tc_pb2 as tc_pb @unique class ConvMode(Enum): diff --git a/requirements.txt b/requirements.txt index a263fa4..3ba8a84 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ protobuf==3.20.3 pyzmq==25.1.0 -edgepi-python-sdk==1.2.13 -edgepi-rpc-protobuf==1.0.15 +edgepi-python-sdk==1.2.15 +edgepi-rpc-protobuf==1.0.24 diff --git a/setup.cfg b/setup.cfg index 5011c7c..ad1008d 100644 --- a/setup.cfg +++ b/setup.cfg @@ -17,6 +17,6 @@ packages = install_requires = protobuf>=3.20.3 - edgepi-rpc-protobuf>=1.0.15 + edgepi-rpc-protobuf>=1.0.24 pyzmq>=25.1.0 edgepi-python-sdk>=1.2.13 diff --git a/start_server.sh b/start_server.sh deleted file mode 100644 index 850b23c..0000000 --- a/start_server.sh +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -wget -qO - https://deb.edgepi.com/edgepi-release.gpg | sudo gpg --dearmor -o /usr/share/keyrings/edgepi-release.gpg - -sudo tee /etc/apt/sources.list.d/edgepi.list >/dev/null <<'EOF' -deb [signed-by=/usr/share/keyrings/edgepi-release.gpg] https://deb.edgepi.com/main bullseye main -deb [signed-by=/usr/share/keyrings/edgepi-release.gpg] https://deb.edgepi.com/test bullseye test -deb [signed-by=/usr/share/keyrings/edgepi-release.gpg] https://deb.edgepi.com/nightly bullseye nightly -EOF - -sudo apt-get update - -apt-cache pkgnames | grep '^edge' - -sudo apt-get install edgepi-rpc-server diff --git a/tests/integration/README.md b/tests/integration/README.md new file mode 100644 index 0000000..77a04fb --- /dev/null +++ b/tests/integration/README.md @@ -0,0 +1,27 @@ +## Necessary environment for running the integration tests: + +The EdgePi RPC server must be installed on the EdgePi for the integration tests to run. + +Check if the server is installed: + +``` +sudo systemctl status edgepi-rpc-server +``` + +If not already installed, install the server through the following commands: + +``` +wget -qO - https://deb.edgepi.com/edgepi-release.gpg | sudo gpg --dearmor -o /usr/share/keyrings/edgepi-release.gpg + +sudo tee /etc/apt/sources.list.d/edgepi.list >/dev/null <<'EOF' +deb [arch=arm64, signed-by=/usr/share/keyrings/edgepi-release.gpg] https://deb.edgepi.com/main bullseye main +#deb [arch=arm64, signed-by=/usr/share/keyrings/edgepi-release.gpg] https://deb.edgepi.com/test bullseye test +#deb [arch=arm64, signed-by=/usr/share/keyrings/edgepi-release.gpg] https://deb.edgepi.com/nightly bullseye nightly +EOF + +sudo apt update + +sudo apt install edgepi-rpc-server + +sudo reboot +``` \ No newline at end of file diff --git a/tests/integration/conftest.py b/tests/integration/conftest.py deleted file mode 100644 index 8d41861..0000000 --- a/tests/integration/conftest.py +++ /dev/null @@ -1,11 +0,0 @@ -# """Integration test setup for RPC Server""" -# import subprocess -# import pytest - -# @pytest.fixture(scope="session", autouse=True) -# def setup_server(): -# """Server Setup""" -# subprocess.run(["bash", "./start_server.sh"], check=True) - - -# TODO: Enable this once the server issue is fixed for integration tests diff --git a/tests/integration/test_error_handling.py b/tests/integration/test_error_handling.py index 01dcd58..bd02a05 100644 --- a/tests/integration/test_error_handling.py +++ b/tests/integration/test_error_handling.py @@ -2,7 +2,7 @@ import logging import zmq from pytest import fixture -from edgepirpc.protos import rpc_pb2 as rpc_pb, tc_pb2 as tc_pb +from rpc_generated_protobufs import rpc_pb2 as rpc_pb, tc_pb2 as tc_pb _logger = logging.getLogger(__name__) diff --git a/tests/integration/test_pwm_service.py b/tests/integration/test_pwm_service.py index e37a927..33c9572 100644 --- a/tests/integration/test_pwm_service.py +++ b/tests/integration/test_pwm_service.py @@ -1,6 +1,6 @@ """PWMService integration test""" -import pytest import time +import pytest from edgepi_rpc_client.services.pwm.client_pwm_service import ClientPWMService from edgepi_rpc_client.services.pwm.pwm_pb_enums import PWMPins, Polarity @@ -8,7 +8,7 @@ @pytest.fixture(name="pwm_service") def fixture_test_pwm_service(): """Inits new PWM service client for testing""" - return ClientPWMService('tcp://localhost:4444') + return ClientPWMService('tcp://localhost:5555') @pytest.mark.parametrize( "args", @@ -119,12 +119,12 @@ def test_get_enabled(pwm_service, pwm_num): assert isinstance(enabled, bool) def test_with_edgepi(pwm_service): - """Manual testing of PWM functionality.""" - pwm_service.init_pwm(pwm_num=PWMPins.PWM1) - pwm_service.set_config(pwm_num=PWMPins.PWM1, duty_cycle=0) - pwm_service.enable(PWMPins.PWM1) + """Used for manual testing of PWM functionality.""" + pwm_service.init_pwm(pwm_num=PWMPins.PWM2) + pwm_service.set_config(pwm_num=PWMPins.PWM2, polarity=Polarity.NORMAL) + pwm_service.enable(PWMPins.PWM2) time.sleep(3) - pwm_service.set_config(pwm_num=PWMPins.PWM1, duty_cycle=0.5) + pwm_service.set_config(pwm_num=PWMPins.PWM2, polarity=Polarity.INVERSED) time.sleep(3) - pwm_service.set_config(pwm_num=PWMPins.PWM1, duty_cycle=1) + pwm_service.set_config(pwm_num=PWMPins.PWM2, polarity=Polarity.NORMAL) \ No newline at end of file