-
Notifications
You must be signed in to change notification settings - Fork 43
Fixes broken local macOS build and completes migration to GH actions #160
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
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |
---|---|---|
|
@@ -16,14 +16,13 @@ package controlplane | |
|
||
import ( | ||
"context" | ||
"fmt" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/assert" | ||
"github.com/stretchr/testify/require" | ||
"istio.io/istio/pilot/pkg/bootstrap" | ||
"istio.io/istio/tests/util" | ||
|
||
|
@@ -32,42 +31,44 @@ import ( | |
"github.com/tetratelabs/getenvoy/pkg/binary/envoytest" | ||
) | ||
|
||
func TestMain(m *testing.M) { | ||
if err := envoytest.Fetch(); err != nil { | ||
fmt.Println(err) | ||
os.Exit(1) | ||
} | ||
os.Exit(m.Run()) | ||
} | ||
func TestConnectsToMockPilotAsAGateway(t *testing.T) { | ||
err := envoytest.Fetch() | ||
require.NoError(t, err, "error running envoytest.Fetch()") | ||
_, teardown := setupMockPilot() | ||
defer teardown() | ||
|
||
// NOTE: This test will fail on macOS due to an issue with Envoy, the same issue as debug logging | ||
func Test_IstioGateway(t *testing.T) { | ||
t.Run("connects to mock Pilot as a gateway", func(t *testing.T) { | ||
_, teardown := setupMockPilot() | ||
defer teardown() | ||
cfg := envoy.NewConfig( | ||
func(c *envoy.Config) { | ||
c.Mode = envoy.ParseMode("loadbalancer") | ||
c.XDSAddress = util.MockPilotGrpcAddr | ||
c.IPAddresses = []string{"1.1.1.1"} | ||
}, | ||
) | ||
runtime, _ := envoy.NewRuntime( | ||
func(r *envoy.Runtime) { r.Config = cfg }, | ||
debug.EnableEnvoyAdminDataCollection, | ||
Istio, | ||
) | ||
defer os.RemoveAll(runtime.DebugStore() + ".tar.gz") | ||
defer os.RemoveAll(runtime.DebugStore()) | ||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) | ||
defer cancel() | ||
assert.NoError(t, envoytest.Run(ctx, runtime, "")) | ||
time.Sleep(time.Millisecond * 500) // Pilot config propagation | ||
assert.NoError(t, envoytest.Kill(ctx, runtime)) | ||
gotListeners, _ := ioutil.ReadFile(filepath.Join(runtime.DebugStore(), "listeners.txt")) | ||
assert.Contains(t, string(gotListeners), "0.0.0.0_8443::0.0.0.0:8443") | ||
assert.Contains(t, string(gotListeners), "0.0.0.0_8080::0.0.0.0:8080") | ||
}) | ||
cfg := envoy.NewConfig( | ||
func(c *envoy.Config) { | ||
c.Mode = envoy.ParseMode("loadbalancer") | ||
c.XDSAddress = util.MockPilotGrpcAddr | ||
c.IPAddresses = []string{"1.1.1.1"} | ||
}, | ||
) | ||
|
||
runtime, err := envoy.NewRuntime( | ||
func(r *envoy.Runtime) { r.Config = cfg }, | ||
debug.EnableEnvoyAdminDataCollection, | ||
Istio, | ||
) | ||
require.NoError(t, err, "error creating envoy runtime") | ||
defer os.RemoveAll(runtime.DebugStore()) | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), time.Second*5) | ||
defer cancel() | ||
|
||
err = envoytest.Run(ctx, runtime, "") | ||
require.NoError(t, err, "error running envoy") | ||
|
||
time.Sleep(time.Millisecond * 500) // Pilot config propagation | ||
|
||
err = envoytest.Kill(ctx, runtime) | ||
require.NoError(t, err, "error killing envoy") | ||
|
||
gotListeners, err := ioutil.ReadFile(filepath.Join(runtime.DebugStore(), "listeners.txt")) | ||
require.NoError(t, err, "error killing envoy listeners") | ||
|
||
require.Contains(t, string(gotListeners), "0.0.0.0_8443::0.0.0.0:8443") | ||
require.Contains(t, string(gotListeners), "0.0.0.0_8080::0.0.0.0:8080") | ||
} | ||
|
||
func setupMockPilot() (*bootstrap.Server, util.TearDownFunc) { | ||
|
@@ -76,6 +77,10 @@ func setupMockPilot() (*bootstrap.Server, util.TearDownFunc) { | |
args.Config.FileDir = "testdata" | ||
args.Plugins = bootstrap.DefaultPlugins | ||
args.Mesh.MixerAddress = "" | ||
// In a normal macOS setup, you cannot write to /dev/stdout, which is the default path here. | ||
// While not Docker-specific, there are related notes here https://github.com/moby/moby/issues/31243 | ||
// Since this test doesn't read access logs anyway, the easier workaround is to disable access logging. | ||
args.MeshConfig.AccessLogFile = "" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Key fix for darwin is here, and when there's a better solution (than running as root or changing host perms), hopefully this comment explains enough. |
||
args.Service.Registries = []string{} | ||
}) | ||
} |
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I moved this into the test preconditions as it isn't necessary to do this for anything in the package