add goc run e2e test
This commit is contained in:
parent
a6dbc7b094
commit
5abdbe2faf
43
tests/gocrun.bats
Executable file
43
tests/gocrun.bats
Executable file
@ -0,0 +1,43 @@
|
||||
#!/usr/bin/env bats
|
||||
# Copyright 2020 Qiniu Cloud (七牛云)
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
setup_file() {
|
||||
# run centered server
|
||||
goc server 3>&- &
|
||||
GOC_PID=$!
|
||||
sleep 2
|
||||
goc init
|
||||
|
||||
# run covered goc run
|
||||
WORKDIR=$PWD
|
||||
cd samples/run_for_several_seconds
|
||||
ls -al
|
||||
gocc run --debug . 3>&- &
|
||||
GOCC_PID=$!
|
||||
sleep 2
|
||||
echo "goc gocc server started"
|
||||
}
|
||||
|
||||
teardown_file() {
|
||||
cd $WORKDIR
|
||||
# collect from center
|
||||
goc profile --debug -o filtered2.cov
|
||||
kill -9 $GOC_PID
|
||||
kill -9 $GOCC_PID
|
||||
}
|
||||
|
||||
@test "test basic goc run" {
|
||||
|
||||
}
|
@ -19,4 +19,6 @@ echo "test start"
|
||||
|
||||
bats server.bats
|
||||
|
||||
bash <(curl -s https://codecov.io/bash) -f filtered.cov -F e2e
|
||||
bats gocrun.bats
|
||||
|
||||
bash <(curl -s https://codecov.io/bash) -f 'filtered*' -F e2e
|
4
tests/samples/run_for_several_seconds/go.mod
Normal file
4
tests/samples/run_for_several_seconds/go.mod
Normal file
@ -0,0 +1,4 @@
|
||||
module example.com/simple-project
|
||||
|
||||
go 1.11
|
||||
|
11
tests/samples/run_for_several_seconds/main.go
Normal file
11
tests/samples/run_for_several_seconds/main.go
Normal file
@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("hello")
|
||||
time.Sleep(time.Second * 15)
|
||||
}
|
@ -18,9 +18,11 @@ setup_file() {
|
||||
goc server 3>&- &
|
||||
GOC_PID=$!
|
||||
sleep 2
|
||||
goc init
|
||||
# run covered goc
|
||||
gocc server --port=:60001 3>&- &
|
||||
gocc server --port=:60001 --debug 3>&- &
|
||||
GOCC_PID=$!
|
||||
sleep 2
|
||||
echo "goc gocc server started"
|
||||
}
|
||||
|
||||
@ -39,3 +41,16 @@ teardown_file() {
|
||||
run goc profile --center=http://127.0.0.1:60001
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
||||
|
||||
@test "register a covered service" {
|
||||
WORKDIR=$PWD
|
||||
cd $WORKDIR/samples/run_for_several_seconds
|
||||
|
||||
run goc build --debug --center=http://127.0.0.1:60001
|
||||
[ "$status" -eq 0 ]
|
||||
./simple-project 3>&- &
|
||||
sleep 1
|
||||
# connect to covered goc
|
||||
run goc profile --center=http://127.0.0.1:60001
|
||||
[ "$status" -eq 0 ]
|
||||
}
|
Loading…
Reference in New Issue
Block a user