Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for Matter plugin #3

Merged
merged 33 commits into from
Jan 25, 2024
Merged

Add tests for Matter plugin #3

merged 33 commits into from
Jan 25, 2024

Conversation

MonicaisHer
Copy link
Owner

@MonicaisHer MonicaisHer commented Jan 3, 2024

This PR

  • add unit test
  • add spread test to build a hello world matter snap
  • add craft parts plugin test to check storage path replacement and app initialization

Testing

Unit test

setting up a development environment, then run only the unit tests for the plugins:

$ ./tools/environment-setup.sh
$ lxc exec snapcraft-dev -- sudo -iu ubuntu bash
ubuntu@snapcraft-dev:~$ cd snapcraft
ubuntu@snapcraft-dev:~$ pip install pytest-cov pytest-mock pytest-subprocess
ubuntu@snapcraft-dev:~$ pip install -r requirements.txt
ubuntu@snapcraft-dev:~$ pytest tests/unit/parts/plugins
...
collected 99 items
...
99 passed in 1.02s

tox test

$ lxc exec snapcraft-dev -- sudo -iu ubuntu bash
ubuntu@snapcraft-dev:~$ cd snapcraft
ubuntu@snapcraft-dev:~$ pip install -U pyopenssl cryptography
ubuntu@snapcraft-dev:~$ pytest --cov=snapcraft_legacy --cov-report=xml:results/coverage-test-legacy-py310.xml --junit-xml=results/test-results-test-legacy-py310.xml tests/legacy

Spread test for plugins integration (with matter-lighting snap)

Please note this spread test has not been executed on the local machine. The matter-lighting app, based on the Matter plugin, can be built and manually tested by runing:

cd snapcraft/tests/spread/plugins/craft-parts/matter
snapcraft clean
snapcraft -v --debug

sudo snap install ./matter-lighting_1.0_amd64.snap --dangerous
start_time=$(date +"%Y-%m-%d %H:%M:%S")
snap start matter-lighting

# Check if storage path replacement from /tmp to SNAP_COMMON/mnt works
for file in /tmp/chip_*; do
  if [ -e "$file" ]; then
    echo "Error: $file should not exist."
    exit 1
  fi
done

if [ ! -e "${SNAP_COMMON/mnt/chip_*}" ]; then
  echo "Error: ${SNAP_COMMON}/mnt/chip_* does not exist."
  exit 1
fi

# Check if server initialization is complete for matter-lighting
if ! journalctl --since "$start_time" | grep matter-lighting | grep "CHIP:SVR: Server initialization complete"; then
  echo "Error: matter-lighting initialization failed."
  exit 1
fi

@MonicaisHer MonicaisHer marked this pull request as ready for review January 10, 2024 12:55
@MonicaisHer
Copy link
Owner Author

Could you please review @farshidtz

Copy link

@farshidtz farshidtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Please see my comments.

Have you also tried running the spread tests?

@MonicaisHer
Copy link
Owner Author

Thanks. Please see my comments.

Have you also tried running the spread tests?

As mentioned in this PR description, the spread test has not been executed on the local machine. The hello world snap, using the Matter plugin, has been manually tested to verify that the output is equal to 'hello world.'

The spread test is integrated into the GitHub Action process.

@MonicaisHer
Copy link
Owner Author

The linter check error is unrelated to this PR and has already been fixed upstream. It will be solved once this branch has been rebased on the upstream main.

@MonicaisHer MonicaisHer requested a review from farshidtz January 17, 2024 09:15
Copy link

@farshidtz farshidtz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please find my latest round of review addressing the changes and some of the original plugin code.

@MonicaisHer MonicaisHer merged commit da14ed1 into IENG-860 Jan 25, 2024
4 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants