Skip to content

Commit

Permalink
Merge pull request #1654 from httprunner/feat-ga4
Browse files Browse the repository at this point in the history
release v4.3.5

- refactor: send events to Google Analytics 4, replace GA v1
- fix: failure unittests caused by httpbin.org, replace with docker service
- fix: handle unstable unittests, restore github actions pipeline

**go version**

- feat: report GA4 events for hrp cmd
- change: create python venv with httprunner minimum version v4.3.5
- fix #1603: ensure path suffix '/' exists

**python version**

- fix: upgrade pyyaml from 5.4.1 to 6.0.1, fix installing error
- refactor: update httprunner dependencies
  • Loading branch information
debugtalk committed Jul 23, 2023
2 parents add3fc5 + da0f620 commit 24bc526
Show file tree
Hide file tree
Showing 91 changed files with 1,628 additions and 1,294 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/smoketest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ jobs:

name: smoketest - httprunner - ${{ matrix.python-version }} on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
services:
service-httpbin:
image: kennethreitz/httpbin
ports:
- 80:80
strategy:
fail-fast: false
max-parallel: 6
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest] # FIXME: docker services are not supported on macos-latest, windows-latest

steps:
- uses: actions/checkout@v2
Expand Down
11 changes: 8 additions & 3 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ env:
jobs:
py-httprunner:
runs-on: ${{ matrix.os }}
services:
service-httpbin:
image: kennethreitz/httpbin
ports:
- 80:80
strategy:
fail-fast: false
max-parallel: 12
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
os: [ubuntu-latest, macos-latest, windows-latest]
os: [ubuntu-latest] # FIXME: docker services are not supported on macos-latest, windows-latest

steps:
- uses: actions/checkout@v2
Expand All @@ -45,7 +50,7 @@ jobs:
poetry run coverage xml
poetry run coverage report -m
- name: Codecov
uses: codecov/codecov-action@v1.0.5
uses: codecov/codecov-action@v3
with:
# User defined upload name. Visible in Codecov UI
name: httprunner
Expand Down Expand Up @@ -78,7 +83,7 @@ jobs:
- name: Run coverage
run: go test -coverprofile="cover.out" -covermode=atomic -race ./...
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v2
uses: codecov/codecov-action@v3
with:
name: hrp (HttpRunner+) # User defined upload name. Visible in Codecov UI
token: ${{ secrets.CODECOV_TOKEN }} # Repository upload token
Expand Down
17 changes: 17 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# Release History

## v4.3.5 (2023-07-23)

- refactor: send events to Google Analytics 4, replace GA v1
- fix: failure unittests caused by httpbin.org, replace with docker service
- fix: handle unstable unittests, restore github actions pipeline

**go version**

- feat: report GA4 events for hrp cmd
- change: create python venv with httprunner minimum version v4.3.5
- fix #1603: ensure path suffix '/' exists

**python version**

- fix: upgrade pyyaml from 5.4.1 to 6.0.1, fix installing error
- refactor: update httprunner dependencies

## v4.3.4 (2023-06-01)

**go version**
Expand Down
2 changes: 1 addition & 1 deletion examples/data/a_b_c/T1_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.3.0
# NOTE: Generated By HttpRunner v4.3.5
# FROM: a-b.c/1.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
2 changes: 1 addition & 1 deletion examples/data/a_b_c/T2_3_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.3.0
# NOTE: Generated By HttpRunner v4.3.5
# FROM: a-b.c/2 3.yml
from httprunner import HttpRunner, Config, Step, RunRequest
from httprunner import RunTestCase
Expand Down
4 changes: 2 additions & 2 deletions examples/demo-empty-project/proj.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"project_name": "demo-empty-project",
"create_time": "2023-05-31T20:46:10.736189+08:00",
"hrp_version": "v4.3.4"
"create_time": "2023-07-23T13:54:23.516072+08:00",
"hrp_version": "v4.3.5"
}
4 changes: 2 additions & 2 deletions examples/demo-with-go-plugin/proj.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"project_name": "demo-with-go-plugin",
"create_time": "2023-05-31T20:44:56.120736+08:00",
"hrp_version": "v4.3.4"
"create_time": "2023-07-23T14:30:10.985053+08:00",
"hrp_version": "v4.3.5"
}
4 changes: 2 additions & 2 deletions examples/demo-with-py-plugin/proj.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"project_name": "demo-with-py-plugin",
"create_time": "2023-05-31T20:45:00.44921+08:00",
"hrp_version": "v4.3.4"
"create_time": "2023-07-23T14:30:18.556239+08:00",
"hrp_version": "v4.3.5"
}
4 changes: 2 additions & 2 deletions examples/demo-without-plugin/proj.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"project_name": "demo-without-plugin",
"create_time": "2023-05-31T20:46:10.621009+08:00",
"hrp_version": "v4.3.4"
"create_time": "2023-07-23T13:54:23.368356+08:00",
"hrp_version": "v4.3.5"
}
4 changes: 2 additions & 2 deletions examples/httpbin/basic.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config:
name: basic test with httpbin
base_url: https://httpbin.org/
base_url: ${get_httpbin_server()}

teststeps:
-
Expand All @@ -10,7 +10,7 @@ teststeps:
method: GET
validate:
- eq: ["status_code", 200]
- eq: [body.headers.Host, "httpbin.org"]
- eq: [body.headers.Host, "127.0.0.1"]

-
name: user-agent
Expand Down
6 changes: 3 additions & 3 deletions examples/httpbin/basic_test.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
# NOTE: Generated By HttpRunner v4.1.4
# NOTE: Generated By HttpRunner v4.3.5
# FROM: basic.yml
from httprunner import HttpRunner, Config, Step, RunRequest


class TestCaseBasic(HttpRunner):

config = Config("basic test with httpbin").base_url("https://httpbin.org/")
config = Config("basic test with httpbin").base_url("${get_httpbin_server()}")

teststeps = [
Step(
RunRequest("headers")
.get("/headers")
.validate()
.assert_equal("status_code", 200)
.assert_equal("body.headers.Host", "httpbin.org")
.assert_equal("body.headers.Host", "127.0.0.1")
),
Step(
RunRequest("user-agent")
Expand Down
6 changes: 4 additions & 2 deletions examples/httpbin/debugtalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@

from loguru import logger

from httprunner.utils import HTTP_BIN_URL


def get_httpbin_server():
return "https://httpbin.org"
return HTTP_BIN_URL


def setup_testcase(variables):
Expand All @@ -17,7 +19,7 @@ def setup_testcase(variables):


def teardown_testcase():
logger.info(f"teardown_testcase.")
logger.info("teardown_testcase.")


def setup_teststep(request, variables):
Expand Down
2 changes: 1 addition & 1 deletion examples/httpbin/hooks_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.1.4
# NOTE: Generated By HttpRunner v4.3.5
# FROM: hooks.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
2 changes: 1 addition & 1 deletion examples/httpbin/load_image_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.1.4
# NOTE: Generated By HttpRunner v4.3.5
# FROM: load_image.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
2 changes: 1 addition & 1 deletion examples/httpbin/upload_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.1.4
# NOTE: Generated By HttpRunner v4.3.5
# FROM: upload.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
2 changes: 1 addition & 1 deletion examples/httpbin/validate.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
config:
name: basic test with httpbin
base_url: https://httpbin.org/
base_url: ${get_httpbin_server()}

teststeps:
-
Expand Down
4 changes: 2 additions & 2 deletions examples/httpbin/validate_test.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# NOTE: Generated By HttpRunner v4.1.4
# NOTE: Generated By HttpRunner v4.3.5
# FROM: validate.yml
from httprunner import HttpRunner, Config, Step, RunRequest


class TestCaseValidate(HttpRunner):

config = Config("basic test with httpbin").base_url("https://httpbin.org/")
config = Config("basic test with httpbin").base_url("${get_httpbin_server()}")

teststeps = [
Step(
Expand Down
2 changes: 1 addition & 1 deletion examples/postman_echo/cookie_manipulation/hardcode_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.1.4
# NOTE: Generated By HttpRunner v4.3.5
# FROM: cookie_manipulation/hardcode.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.1.4
# NOTE: Generated By HttpRunner v4.3.5
# FROM: cookie_manipulation/set_delete_cookies.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
2 changes: 1 addition & 1 deletion examples/postman_echo/request_methods/hardcode_test.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.3.0
# NOTE: Generated By HttpRunner v4.3.5
# FROM: request_methods/hardcode.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.3.0
# NOTE: Generated By HttpRunner v4.3.5
# FROM: request_methods/request_with_functions.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.3.0
# NOTE: Generated By HttpRunner v4.3.5
# FROM: request_methods/request_with_parameters.yml
import pytest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.3.0
# NOTE: Generated By HttpRunner v4.3.5
# FROM: request_methods/request_with_testcase_reference.yml
from httprunner import HttpRunner, Config, Step, RunRequest
from httprunner import RunTestCase
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.3.0
# NOTE: Generated By HttpRunner v4.3.5
# FROM: request_methods/request_with_variables.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.3.0
# NOTE: Generated By HttpRunner v4.3.5
# FROM: request_methods/validate_with_functions.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# NOTE: Generated By HttpRunner v4.3.0
# NOTE: Generated By HttpRunner v4.3.5
# FROM: request_methods/validate_with_variables.yml
from httprunner import HttpRunner, Config, Step, RunRequest

Expand Down
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ require (
github.com/maja42/goval v1.2.1
github.com/mitchellh/mapstructure v1.5.0
github.com/olekukonko/tablewriter v0.0.5
github.com/otiai10/gosseract/v2 v2.4.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.13.0
github.com/rs/zerolog v1.29.1
Expand Down Expand Up @@ -53,6 +52,7 @@ require (
github.com/hashicorp/yamux v0.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.18 // indirect
Expand All @@ -67,6 +67,7 @@ require (
github.com/prometheus/common v0.37.0 // indirect
github.com/prometheus/procfs v0.8.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.10.0 // indirect
github.com/russross/blackfriday/v2 v2.1.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/tklauser/go-sysconf v0.3.10 // indirect
Expand Down
15 changes: 6 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxv
github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pretty v0.3.0 h1:WgNl7dwNpEZ6jJ9k1snq4pZsg7DOEN8hP9Xw0Tsjwk0=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
Expand Down Expand Up @@ -249,15 +250,9 @@ github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA=
github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU=
github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec=
github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY=
github.com/otiai10/curr v0.0.0-20150429015615-9b4961190c95/go.mod h1:9qAhocn7zKJG+0mI8eUu6xqkFDYS2kb2saOteoSB3cE=
github.com/otiai10/curr v1.0.0/go.mod h1:LskTG5wDwr8Rs+nNQ+1LlxRjAtTZZjtJW4rMXl6j4vs=
github.com/otiai10/gosseract/v2 v2.4.0 h1:gYd3mx6FuMtIlxL4sYb9JLCFEDzg09VgNSZRNbqpiGM=
github.com/otiai10/gosseract/v2 v2.4.0/go.mod h1:fhbIDRh29bj13vni6RT3gtWKjKCAeqDYI4C1dxeJuek=
github.com/otiai10/mint v1.3.0/go.mod h1:F5AjcsTsWUqX+Na9fpHb52P8pcRX2CI6A3ctIT91xUo=
github.com/otiai10/mint v1.3.3 h1:7JgpsBaN0uMkyju4tbYHu0mnM55hNKVYLsXmwr15NQI=
github.com/otiai10/mint v1.3.3/go.mod h1:/yxELlJQ0ufhjUwhshSj+wFjZ78CnZ48/1wtmBH1OTc=
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
github.com/pingcap/errors v0.11.4 h1:lFuQV/oaUMGcD2tqt+01ROSmJs75VG1ToEOkZIZ4nE4=
github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
Expand Down Expand Up @@ -292,7 +287,9 @@ github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0ua
github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY=
github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc=
github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.29.1 h1:cO+d60CHkknCbvzEWxP0S9K6KqyTjrCNUy1LdQLCGPc=
github.com/rs/zerolog v1.29.1/go.mod h1:Le6ESbR7hc+DP6Lt1THiV8CQSdkkNrd3R0XbEgp3ZBU=
Expand Down
17 changes: 7 additions & 10 deletions hrp/boomer.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,14 @@ func (b *HRPBoomer) SetPython3Venv(venv string) *HRPBoomer {

// Run starts to run load test for one or multiple testcases.
func (b *HRPBoomer) Run(testcases ...ITestCase) {
event := sdk.EventTracking{
Category: "RunLoadTests",
Action: "hrp boom",
}
// report start event
go sdk.SendEvent(event)
// report execution timing event
defer sdk.SendEvent(event.StartTiming("execution"))

// quit all plugins
startTime := time.Now()
defer func() {
// report boom event
sdk.SendGA4Event("hrp_boomer_run", map[string]interface{}{
"engagement_time_msec": time.Since(startTime).Milliseconds(),
})

// quit all plugins
pluginMap.Range(func(key, value interface{}) bool {
if plugin, ok := value.(funplugin.IPlugin); ok {
plugin.Quit()
Expand Down
2 changes: 1 addition & 1 deletion hrp/boomer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func TestBoomerStandaloneRun(t *testing.T) {
defer removeHashicorpGoPlugin()

testcase1 := &TestCase{
Config: NewConfig("TestCase1").SetBaseURL("https://httpbin.org"),
Config: NewConfig("TestCase1").SetBaseURL("https://postman-echo.com"),
TestSteps: []IStep{
NewStep("headers").
GET("/headers").
Expand Down

0 comments on commit 24bc526

Please sign in to comment.