java-tests.yaml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. # Copyright (c) 2023 Project CHIP Authors
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. name: Java Tests
  15. on:
  16. push:
  17. pull_request:
  18. merge_group:
  19. workflow_dispatch:
  20. concurrency:
  21. group: ${{ github.ref }}-${{ github.workflow }}-${{ (github.event_name ==
  22. 'pull_request' && github.event.number) || (github.event_name ==
  23. 'workflow_dispatch' && github.run_number) || github.sha }}
  24. cancel-in-progress: true
  25. env:
  26. CHIP_NO_LOG_TIMESTAMPS: true
  27. jobs:
  28. java_tests_linux:
  29. name: Linux
  30. env:
  31. TSAN_OPTIONS: "halt_on_error=1 suppressions=scripts/tests/chiptest/tsan-linux-suppressions.txt"
  32. if: github.actor != 'restyled-io[bot]'
  33. runs-on: ubuntu-latest
  34. container:
  35. image: ghcr.io/project-chip/chip-build-java:1
  36. options: --privileged --sysctl "net.ipv6.conf.all.disable_ipv6=0
  37. net.ipv4.conf.all.forwarding=0 net.ipv6.conf.all.forwarding=0"
  38. steps:
  39. - name: Checkout
  40. uses: actions/checkout@v4
  41. - name: Checkout submodules & Bootstrap
  42. uses: ./.github/actions/checkout-submodules-and-bootstrap
  43. with:
  44. platform: linux
  45. bootstrap-log-name: bootstrap-logs-linux-${{ matrix.build_variant }}${{ matrix.chip_tool }}
  46. - name: Try to ensure the directories for core dumping exist and we
  47. can write them.
  48. run: |
  49. mkdir /tmp/cores || true
  50. sysctl -w kernel.core_pattern=/tmp/cores/core.%u.%p.%t || true
  51. mkdir objdir-clone || true
  52. - name: Generate unit tests
  53. run: |
  54. scripts/run_in_build_env.sh \
  55. './scripts/build/build_examples.py \
  56. --target linux-x64-tests \
  57. gen \
  58. '
  59. - name: Build unit tests
  60. run: scripts/run_in_build_env.sh 'ninja -C out/linux-x64-tests src:java_controller_tests'
  61. - name: Run unit tests
  62. # TODO: this direct path loading is not maintainable. Our build system should define and
  63. # support test classes.
  64. run: |
  65. $JAVA_PATH/bin/java \
  66. -cp 'third_party/java_deps/artifacts/*:out/linux-x64-tests/lib/src/controller/java/*' \
  67. org.junit.runner.JUnitCore \
  68. chip.tlv.TlvWriterTest \
  69. chip.tlv.TlvReadWriteTest \
  70. chip.tlv.TlvReaderTest \
  71. chip.jsontlv.JsonToTlvToJsonTest \
  72. chip.onboardingpayload.ManualCodeTest \
  73. chip.onboardingpayload.QRCodeTest
  74. - name: Build Java Matter Controller and all clusters app
  75. run: |
  76. scripts/run_in_build_env.sh './scripts/build_python.sh --install_virtual_env out/venv'
  77. scripts/run_in_python_env.sh out/venv 'pip install -r scripts/setup/requirements.build.txt'
  78. scripts/run_in_python_env.sh out/venv 'pip install colorama'
  79. ./scripts/run_in_build_env.sh \
  80. "./scripts/build/build_examples.py \
  81. --target linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test \
  82. --target linux-x64-java-matter-controller \
  83. build \
  84. "
  85. - name: Run Discover Commissionables Test
  86. run: |
  87. scripts/run_in_python_env.sh out/venv \
  88. './scripts/tests/run_java_test.py \
  89. --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  90. --app-args "--discriminator 3840 --interface-id -1" \
  91. --tool-path out/linux-x64-java-matter-controller \
  92. --tool-cluster "discover" \
  93. --tool-args "commissionables" \
  94. --factoryreset \
  95. '
  96. - name: Run Pairing Onnetwork Test
  97. run: |
  98. scripts/run_in_python_env.sh out/venv \
  99. './scripts/tests/run_java_test.py \
  100. --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  101. --app-args "--discriminator 3840 --interface-id -1" \
  102. --tool-path out/linux-x64-java-matter-controller \
  103. --tool-cluster "pairing" \
  104. --tool-args "onnetwork-long --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
  105. --factoryreset \
  106. '
  107. - name: Run IM Invoke Test
  108. run: |
  109. scripts/run_in_python_env.sh out/venv \
  110. './scripts/tests/run_java_test.py \
  111. --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  112. --app-args "--discriminator 3840 --interface-id -1" \
  113. --tool-path out/linux-x64-java-matter-controller \
  114. --tool-cluster "im" \
  115. --tool-args "onnetwork-long-im-invoke --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
  116. --factoryreset \
  117. '
  118. - name: Run IM Read Test
  119. run: |
  120. scripts/run_in_python_env.sh out/venv \
  121. './scripts/tests/run_java_test.py \
  122. --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  123. --app-args "--discriminator 3840 --interface-id -1" \
  124. --tool-path out/linux-x64-java-matter-controller \
  125. --tool-cluster "im" \
  126. --tool-args "onnetwork-long-im-read --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
  127. --factoryreset \
  128. '
  129. - name: Run IM Write Test
  130. run: |
  131. scripts/run_in_python_env.sh out/venv \
  132. './scripts/tests/run_java_test.py \
  133. --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  134. --app-args "--discriminator 3840 --interface-id -1" \
  135. --tool-path out/linux-x64-java-matter-controller \
  136. --tool-cluster "im" \
  137. --tool-args "onnetwork-long-im-write --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
  138. --factoryreset \
  139. '
  140. - name: Run IM Subscribe Test
  141. run: |
  142. scripts/run_in_python_env.sh out/venv \
  143. './scripts/tests/run_java_test.py \
  144. --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  145. --app-args "--discriminator 3840 --interface-id -1" \
  146. --tool-path out/linux-x64-java-matter-controller \
  147. --tool-cluster "im" \
  148. --tool-args "onnetwork-long-im-subscribe --nodeid 1 --setup-pin-code 20202021 --discriminator 3840 -t 1000" \
  149. --factoryreset \
  150. '
  151. - name: Run Pairing AlreadyDiscovered Test
  152. run: |
  153. scripts/run_in_python_env.sh out/venv \
  154. './scripts/tests/run_java_test.py \
  155. --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  156. --app-args "--discriminator 3840 --interface-id -1" \
  157. --tool-path out/linux-x64-java-matter-controller \
  158. --tool-cluster "pairing" \
  159. --tool-args "already-discovered --nodeid 1 --setup-pin-code 20202021 --address ::1 --port 5540 -t 1000" \
  160. --factoryreset \
  161. '
  162. # Disabled due to failure: https://github.com/project-chip/connectedhomeip/issues/27361
  163. # - name: Run Pairing Address-PaseOnly Test
  164. # run: |
  165. # scripts/run_in_python_env.sh out/venv \
  166. # './scripts/tests/run_java_test.py \
  167. # --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  168. # --app-args "--discriminator 3840 --interface-id -1" \
  169. # --tool-path out/linux-x64-java-matter-controller \
  170. # --tool-cluster "pairing" \
  171. # --tool-args "address-paseonly --nodeid 1 --setup-pin-code 20202021 --address ::1 --port 5540 -t 1000" \
  172. # --factoryreset \
  173. # '
  174. - name: Run Pairing SetupQRCode Test
  175. run: |
  176. scripts/run_in_python_env.sh out/venv \
  177. './scripts/tests/run_java_test.py \
  178. --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  179. --app-args "--discriminator 3840 --interface-id -1" \
  180. --tool-path out/linux-x64-java-matter-controller \
  181. --tool-cluster "pairing" \
  182. --tool-args "code --nodeid 1 --setup-payload MT:-24J0AFN00KA0648G00 --discover-once 1 --use-only-onnetwork-discovery 0 -t 1000" \
  183. --factoryreset \
  184. '
  185. - name: Run Pairing ManualCode Test
  186. run: |
  187. scripts/run_in_python_env.sh out/venv \
  188. './scripts/tests/run_java_test.py \
  189. --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app \
  190. --app-args "--discriminator 3840 --interface-id -1" \
  191. --tool-path out/linux-x64-java-matter-controller \
  192. --tool-cluster "pairing" \
  193. --tool-args "code --nodeid 1 --setup-payload 34970112332 --discover-once 1 --use-only-onnetwork-discovery 0 -t 1000" \
  194. --factoryreset \
  195. '
  196. - name: Uploading core files
  197. uses: actions/upload-artifact@v3
  198. if: ${{ failure() && !env.ACT }}
  199. with:
  200. name: crash-core-linux-java-controller
  201. path: /tmp/cores/
  202. # Cores are big; don't hold on to them too long.
  203. retention-days: 5
  204. - name: Uploading objdir for debugging
  205. uses: actions/upload-artifact@v3
  206. if: ${{ failure() && !env.ACT }}
  207. with:
  208. name: crash-objdir-linux-java-controller
  209. path: objdir-clone/
  210. # objdirs are big; don't hold on to them too long.
  211. retention-days: 5