-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
TEST/MEDIUM: e2e: tests to check parallel reads on runtime work
- Loading branch information
Showing
5 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
global | ||
maxconn 1000 | ||
stats socket "$SOCK_PATH" level admin | ||
|
||
defaults | ||
mode http | ||
|
||
frontend test | ||
bind localhost:32000 | ||
default_backend test_bck | ||
|
||
backend test_bck | ||
balance roundrobin | ||
server test1 127.0.0.1:5000 | ||
server test2 127.0.0.1:5001 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
// Copyright 2021 HAProxy Technologies | ||
// | ||
// 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. | ||
// | ||
//go:build integration | ||
// +build integration | ||
|
||
package parallel_test | ||
|
||
import ( | ||
"sync" | ||
) | ||
|
||
func (s *ParallelRuntime) TestParallel() { | ||
runtime, err := s.client.Runtime() | ||
if err != nil { | ||
s.FailNow(err.Error()) | ||
} | ||
var wg sync.WaitGroup | ||
for range 3000 { | ||
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
info, err := runtime.GetInfo() | ||
s.Assert().Greater(len(info), 0, "info is empty") | ||
s.Assert().NotNil(info[0].Info, "information is nil", info[0].Error) | ||
s.Assert().Equal(info[0].RuntimeAPI, s.socketPath, "runtime not correct, runtime is ", info[0].RuntimeAPI) | ||
s.Assert().Contains(info[0].Info.Version, s.haproxyVersion, "version not correct, version is ", info[0].Info.Version) | ||
if err != nil { | ||
s.FailNow(err.Error()) | ||
} | ||
}() | ||
} | ||
wg.Wait() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// Copyright 2021 HAProxy Technologies | ||
// | ||
// 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. | ||
// | ||
//go:build integration | ||
// +build integration | ||
|
||
package parallel_test | ||
|
||
import ( | ||
"os" | ||
"os/exec" | ||
"testing" | ||
|
||
client_native "github.com/haproxytech/client-native/v5" | ||
|
||
"github.com/haproxytech/client-native/v5/e2e" | ||
"github.com/stretchr/testify/suite" | ||
) | ||
|
||
type ParallelRuntime struct { | ||
suite.Suite | ||
cmd *exec.Cmd | ||
client client_native.HAProxyClient | ||
tmpDir string | ||
haproxyVersion string | ||
socketPath string | ||
} | ||
|
||
func (s *ParallelRuntime) SetupTest() { | ||
result, err := e2e.GetClient(s.T()) | ||
if err != nil { | ||
s.FailNow(err.Error()) | ||
} | ||
s.haproxyVersion = result.HAProxyVersion | ||
s.cmd = result.Cmd | ||
s.client = result.Client | ||
s.tmpDir = result.TmpDir | ||
s.socketPath = result.SocketPath | ||
} | ||
|
||
func (s *ParallelRuntime) TearDownSuite() { | ||
if err := s.cmd.Process.Kill(); err != nil { | ||
s.FailNow(err.Error()) | ||
} | ||
if s.tmpDir != "" { | ||
err := os.RemoveAll(s.tmpDir) | ||
if err != nil { | ||
s.FailNow(err.Error()) | ||
} | ||
} | ||
} | ||
|
||
func TestParallelRuntimes(t *testing.T) { | ||
suite.Run(t, new(ParallelRuntime)) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters