-
Notifications
You must be signed in to change notification settings - Fork 11
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
CE2E fixes, support MacOS #475
Conversation
@@ -5,10 +5,11 @@ MM_DEBUG ?= | |||
GOPATH ?= $(shell go env GOPATH) | |||
GO_TEST_FLAGS ?= -race | |||
GO_BUILD_FLAGS ?= | |||
GO_BUILD_TAGS ?= |
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.
We now apply clientMock
from the make dist
invocation within ce2e/
.
DEFAULT_GOOS ?= $(shell go env GOOS) | ||
DEFAULT_GOARCH ?= $(shell go env GOARCH) |
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.
Allow ce2e/
to override the "default" GOOS so we can explicitly build for linux
and amd64
, matching the Docker containers.
endif | ||
endif | ||
|
||
## Builds the server, if it exists, for all supported architectures, unless MM_SERVICESETTINGS_ENABLEDEVELOPER is set. |
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.
No need for special targets anymore.
// Don't use runtime.* directly, as we may target a different archtiecture for testing. | ||
defaultGoOs := os.Getenv("DEFAULT_GOOS") | ||
defaultGoArch := os.Getenv("DEFAULT_GOARCH") |
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.
Copy whatever the Makefile
is doing.
@@ -14,7 +17,25 @@ import ( | |||
"github.com/stretchr/testify/require" | |||
) | |||
|
|||
var buildPluginOnce sync.Once | |||
|
|||
func buildPlugin(t *testing.T) { |
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.
Build the plugin especially for these tests, and only do it once.
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 like this.
mattermost, err := mmcontainer.RunContainer(ctx, | ||
mmcontainer.WithPlugin(filename, "com.mattermost.msteams-sync", pluginConfig), | ||
mmcontainer.WithEnv("MM_MSTEAMSSYNC_MOCK_CLIENT", "true"), | ||
mmcontainer.WithTestingLogConsumer(t), |
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.
Forward logs from Mattermost to enable debugging.
) | ||
require.NoError(t, err) | ||
|
||
// TODO: This won't be required after jespino gets https://github.com/testcontainers/testcontainers-go/pull/2073 merged. |
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 saw your PR, @jespino! This should help us now before we can more easily configure as you have above.
"MM_SERVICESETTINGS_ENABLELOCALMODE": "true", | ||
"MM_PASSWORDSETTINGS_MINIMUMLENGTH": "5", | ||
"MM_PLUGINSETTINGS_ENABLEUPLOADS": "true", | ||
"MM_PLUGINSETTINGS_AUTOMATICPREPACKAGEDPLUGINS": "false", |
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.
Most prepackaged plugins don't do anything until configured, so speed things up.
cmd := exec.Command("make", "-C", "../../", "dist") | ||
cmd.Env = os.Environ() | ||
cmd.Env = append(cmd.Env, "DEFAULT_GOOS=linux") | ||
cmd.Env = append(cmd.Env, "DEFAULT_GOARCH=amd64") |
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.
Are we sure that the test runners are going to be amd64
? I guess it can end up being arm64
too.
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.
You mention about the docker containers, but I guess docker containers in arm processors should use arm architecture, I think we should be building for the current runner architecture and the GOOS linux, but I'm not 100% sure how it works in Mac.
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'm thinking now that maybe, we can do the plugin compilation here, already inside a testcontainer. Build the container for go, share the filesystem of the current directory, execute the build, and copy over the file outside the container, tear down the container, and use the compiled version. Not needed in this PR, I think we can merge this and think about adding that 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.
For context, the issue here is matching the architecture of the Mattermost enterprise docker containers -- otherwise the plugin won't run.
Once we start building and supporting Mattermost for arm, we'll probably need to revisit this.
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.
Good point, you are 100% right.
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.
LGTM, some concerns about the specificity of the Architecture, but if the CI is working, and the local tests for mac and linux are working, I think we are good.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #475 +/- ##
=======================================
Coverage 43.45% 43.45%
=======================================
Files 21 21
Lines 6289 6289
=======================================
Hits 2733 2733
Misses 3331 3331
Partials 225 225 ☔ View full report in Codecov by Sentry. |
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.
LGTM 👍
Summary
Support MacOS in the CE2E tests, forward logs from the Mattermost container, and fix a handful of issues.
Ticket Link
None.