-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: golang engine start should await healthcheck.
- Loading branch information
1 parent
a384e8f
commit 54e9348
Showing
8 changed files
with
187 additions
and
44 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ resources: | |
method: get | ||
response: | ||
statusCode: 200 | ||
staticData: "Hello world" | ||
content: "Hello world" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
/* | ||
Copyright © 2021 Pete Cornish <outofcoffee@gmail.com> | ||
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. | ||
*/ | ||
|
||
package golang | ||
|
||
import ( | ||
"gatehill.io/imposter/engine" | ||
"gatehill.io/imposter/engine/enginetests" | ||
"github.com/sirupsen/logrus" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
) | ||
|
||
var engineBuilder = func(tt enginetests.EngineTestScenario) engine.MockEngine { | ||
return engine.BuildEngine("golang", tt.Fields.ConfigDir, tt.Fields.Options) | ||
} | ||
|
||
func init() { | ||
logger.SetLevel(logrus.TraceLevel) | ||
EnableEngine() | ||
} | ||
|
||
func TestEngine_StartStop(t *testing.T) { | ||
workingDir, err := os.Getwd() | ||
if err != nil { | ||
panic(err) | ||
} | ||
testConfigPath := filepath.Join(workingDir, "../enginetests/testdata") | ||
|
||
tests := []enginetests.EngineTestScenario{ | ||
{ | ||
Name: "start golang engine", | ||
Fields: enginetests.EngineTestFields{ | ||
ConfigDir: testConfigPath, | ||
Options: engine.StartOptions{ | ||
Port: enginetests.GetFreePort(), | ||
Version: "0.16.0", | ||
PullPolicy: engine.PullIfNotPresent, | ||
LogLevel: "DEBUG", | ||
}, | ||
}, | ||
}, | ||
} | ||
enginetests.StartStop(t, tests, engineBuilder) | ||
} | ||
|
||
func TestEngine_Restart(t *testing.T) { | ||
logger.SetLevel(logrus.TraceLevel) | ||
workingDir, err := os.Getwd() | ||
if err != nil { | ||
panic(err) | ||
} | ||
testConfigPath := filepath.Join(workingDir, "../enginetests/testdata") | ||
|
||
tests := []enginetests.EngineTestScenario{ | ||
{ | ||
Name: "restart golang engine", | ||
Fields: enginetests.EngineTestFields{ | ||
ConfigDir: testConfigPath, | ||
Options: engine.StartOptions{ | ||
Port: enginetests.GetFreePort(), | ||
Version: "0.16.0", | ||
PullPolicy: engine.PullIfNotPresent, | ||
LogLevel: "DEBUG", | ||
}, | ||
}, | ||
}, | ||
} | ||
enginetests.Restart(t, tests, engineBuilder) | ||
} | ||
|
||
func TestEngine_List(t *testing.T) { | ||
logger.SetLevel(logrus.TraceLevel) | ||
workingDir, err := os.Getwd() | ||
if err != nil { | ||
panic(err) | ||
} | ||
testConfigPath := filepath.Join(workingDir, "../enginetests/testdata") | ||
|
||
tests := []enginetests.EngineTestScenario{ | ||
{ | ||
Name: "list golang engine", | ||
Fields: enginetests.EngineTestFields{ | ||
ConfigDir: testConfigPath, | ||
Options: engine.StartOptions{ | ||
Port: enginetests.GetFreePort(), | ||
Version: "0.16.0", | ||
PullPolicy: engine.PullIfNotPresent, | ||
LogLevel: "DEBUG", | ||
}, | ||
// skip port check as port can't be determined from environment variables | ||
SkipCheckPort: true, | ||
}, | ||
}, | ||
} | ||
enginetests.List(t, tests, engineBuilder) | ||
} |
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
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