Skip to content

Add gRPC testsuite #1806

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

Merged
merged 33 commits into from
Aug 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
874d2e2
testsuite: Added helper functions to handle test envs
cmaglie Jul 12, 2022
dae3242
testsuite: Added helper functions to run arduino-cli
cmaglie Jul 12, 2022
9679f1c
testsuite: Added colored output to arduino-cli Run helper
cmaglie Jul 12, 2022
46c381e
testsuite: Pass cli config through env variables
cmaglie Jul 12, 2022
9ae6760
testsuite: added env commands to download and extract files
cmaglie Jul 13, 2022
1465a20
testsuite: added commands to start cli daemon and run some gRPC calls
cmaglie Jul 13, 2022
f53c673
testsuite: moved test harness inside 'internal' package
cmaglie Jul 13, 2022
82e98ee
testsuite: added first daemon test for gRPC board watch
cmaglie Jul 13, 2022
b453bca
testsuite: added http server helper
cmaglie Jul 28, 2022
db39fb0
testsuite: added JSON helpers
cmaglie Jul 29, 2022
f2c886e
testsuite: Added possibility to use shared download staging folder
cmaglie Jul 29, 2022
1ab2ef4
testsuite: Converted a core_test.py test (WIP)
cmaglie Jul 29, 2022
eac1356
REMOVEME: Deactivate daemon integration test for now
cmaglie Jul 29, 2022
2631e96
testsuite: force colored output
cmaglie Jul 29, 2022
330b51d
testsuite: moved all generic subroutines into their own library
cmaglie Aug 1, 2022
b886381
testsuite: moved daemon test in his own dir
cmaglie Aug 1, 2022
a9d73c2
fixed typo
cmaglie Aug 1, 2022
f3c1463
testsuite: added some helpers to improve daemon testing
cmaglie Aug 1, 2022
94ba9ac
testsuite: added test for #1614
cmaglie Aug 1, 2022
688f7af
Removed converted test
cmaglie Aug 2, 2022
9fea578
testsuite: perform build before test
cmaglie Aug 2, 2022
0c282cd
Added missing comment
cmaglie Aug 2, 2022
55833f8
Renamed test file
cmaglie Aug 2, 2022
eea3ec9
Skip failing tests
cmaglie Aug 2, 2022
ca557ac
Updated licensed cache
cmaglie Aug 2, 2022
a929ff7
re-enable test for fixed bug
cmaglie Aug 2, 2022
1953902
testsuite: disable postinstall
cmaglie Aug 3, 2022
0896f4c
Removed useless startDaemon
cmaglie Aug 5, 2022
f21e86c
Renamed inst -> grpcInst
cmaglie Aug 5, 2022
d977ffe
Close daemon gRPC connection on test cleanup
cmaglie Aug 5, 2022
82e47d3
Added comment
cmaglie Aug 5, 2022
87561fe
Apply suggestions from code review
cmaglie Aug 8, 2022
757fa06
Update internal/integrationtest/arduino-cli.go
cmaglie Aug 9, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
testsuite: added first daemon test for gRPC board watch
  • Loading branch information
cmaglie committed Aug 5, 2022
commit 82e98ee2e88f42ccba8a1a96fb1ca68c49d64cc1
3 changes: 3 additions & 0 deletions .github/workflows/test-go-task.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ jobs:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Build arduino-cli
run: task go:build

- name: Run tests
run: task go:test

Expand Down
87 changes: 87 additions & 0 deletions internal/integrationtest/arduino-cli_daemon_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// This file is part of arduino-cli.
//
// Copyright 2022 ARDUINO SA (http://www.arduino.cc/)
//
// This software is released under the GNU General Public License version 3,
// which covers the main part of arduino-cli.
// The terms of this license can be found at:
// https://www.gnu.org/licenses/gpl-3.0.en.html
//
// You can be released from the requirements of the above licenses by purchasing
// a commercial license. Buying such a license is mandatory if you want to
// modify or otherwise use the software for commercial activities involving the
// Arduino software without disclosing the source code of your own applications.
// To purchase a commercial license, send an email to license@arduino.cc.

package integrationtest

import (
"context"
"fmt"
"io"
"testing"
"time"

"github.com/arduino/arduino-cli/rpc/cc/arduino/cli/commands/v1"
"github.com/arduino/go-paths-helper"
"github.com/stretchr/testify/require"
)

func TestArduinoCliDaemon(t *testing.T) {
env := NewEnvironment(t)
defer env.CleanUp()

cli := NewArduinoCliWithinEnvironment(t, paths.New("..", "..", "arduino-cli"), env)
defer cli.CleanUp()

_, _, err := cli.Run("core", "update-index")
require.NoError(t, err)

_ = cli.StartDeamon(false)

inst := cli.Create()
require.NoError(t, inst.Init("", "", func(ir *commands.InitResponse) {
fmt.Printf("INIT> %v\n", ir.GetMessage())
}))

// Run a one-shot board list
boardListResp, err := inst.BoardList(time.Second)
require.NoError(t, err)
fmt.Printf("Got boardlist response with %d ports\n", len(boardListResp.GetPorts()))

// Run a one-shot board list again (should not fail)
boardListResp, err = inst.BoardList(time.Second)
require.NoError(t, err)
fmt.Printf("Got boardlist response with %d ports\n", len(boardListResp.GetPorts()))

testWatcher := func() {
// Run watcher
watcher, err := inst.BoardListWatch()
require.NoError(t, err)
ctx, cancel := context.WithCancel(context.Background())
go func() {
defer cancel()
for {
msg, err := watcher.Recv()
if err == io.EOF {
fmt.Println("Watcher EOF")
return
}
require.Empty(t, msg.Error, "Board list watcher returned an error")
require.NoError(t, err, "BoardListWatch grpc call returned an error")
fmt.Printf("WATCH> %v\n", msg)
}
}()
time.Sleep(time.Second)
require.NoError(t, watcher.CloseSend())
select {
case <-ctx.Done():
// all right!
case <-time.After(time.Second):
require.Fail(t, "BoardListWatch didn't close")
}
}

testWatcher()
testWatcher()
}