Skip to content
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

fix(ci): resolve systest failures on arm #8503

Merged
merged 17 commits into from
Dec 13, 2022
Merged

fix(ci): resolve systest failures on arm #8503

merged 17 commits into from
Dec 13, 2022

Conversation

joshua-goldstein
Copy link
Contributor

@joshua-goldstein joshua-goldstein commented Dec 11, 2022

Problem

Systest/export backup to minio was failing on arm64.

Solution

The minio image that we require was published before multi-architecture docker images were introduced. As such, there are two tags, namely RELEASE.2020-11-13T20-10-18Z (which we currently use for systest/export) and RELEASE.2020-11-13T20-10-18Z-arm64 (which is required for arm64). See the Dockerhub page here.

Unfortunately docker-compose files do not offer some sort of conditional logic. As such the easiest way to use this image is to create a new docker-compose-arm64.yml file and a flag that specifies when it should be uses at the t.go level. This is not so elegant but is the easiest solution currently since we lack a way to dynamically generate docker-compose files.

This PR also improves some testing functionality. In brief, all that is required to run tests now is to run make test from the root dgraph directory. If one wants to run specific package tests (e.g. systest/export) one can use make test args="--pkg=systest/export". What this does is pass the --pkg=systest/export flag to the t.go binary when it is run. This has the benefit that any number of arguments can be passed to t.go. E.g., in the process of testing this PR, I ran

make test args="--pkg=systest/export --arch=arm64"

which (after building the dgraph binary and making a dgraph docker image with local tag) builds t.go and executes ./t --pkg=systest/export --arch-arm64

Finally, we fix a logic error that was introduced recently in t.go. Coverage files should only be copied over when t.go is run in coverage mode.

@github-actions github-actions bot added area/integrations Related to integrations with other projects. area/testing Testing related issues labels Dec 11, 2022
@joshua-goldstein joshua-goldstein marked this pull request as ready for review December 11, 2022 20:36
@joshua-goldstein joshua-goldstein changed the title fix(ci): resolve systest failure on arm + improve testing experience fix(ci): resolve systest failure on arm Dec 11, 2022
@joshua-goldstein joshua-goldstein self-assigned this Dec 11, 2022
@coveralls
Copy link

coveralls commented Dec 11, 2022

Coverage Status

Coverage increased (+0.2%) to 64.089% when pulling 9c9efed on joshua/arm-fix into eae3c3a on main.

@joshua-goldstein joshua-goldstein changed the title fix(ci): resolve systest failure on arm fix(ci): resolve systest failures on arm Dec 12, 2022
@skrdgraph
Copy link
Contributor

This looks good 👍 - ill merge it tomorrow! I want a review by @anurags92 here as well ...

Copy link
Contributor

@all-seeing-code all-seeing-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have added my observations on the pull request. Let me know if you find them useful.

@@ -0,0 +1,97 @@
# Auto-generated with: [./compose -a 3 -z 1 -r 1 --minio --minio_port=9001 --minio_env_file=../../backup.env -w --port_offset=0 --expose_ports=false --mem= --names=false -O ../systest/backup/minio-large/docker-compose.yml]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is true anymore unless the compose.go produces ${COVERAGE_OUTPUT} as well in the command, which I doubt it would. Hence this should be removed to avoid misleading someone.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed - it would be nice to eventually use compose.go but for now I modify this line

--security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;"
--tls "ca-cert=/dgraph-tls/ca.crt; server-cert=/dgraph-tls/node.crt; server-key=/dgraph-tls/node.key; internal-port=true; client-cert=/dgraph-tls/client.alpha3.crt; client-key=/dgraph-tls/client.alpha3.key;"
minio:
image: minio/minio:RELEASE.2020-11-13T20-10-18Z-arm64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about passing in the image as an environment variable?

docker-compose.yml:

// Minio has two different images for arm and amd etc.. (descriptive comment in the docker yml)
minio:
    image: ${MINIO_IMAGE_FOR_PLATFORM}

And in the t.go you can set the environment variable. Probably here:

dgraph/t/t.go

Line 100 in 035f9fc

func commandWithContext(ctx context.Context, args ...string) *exec.Cmd {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very nice solution... I wasn't sure if this was possible, so thank you for confirming it in your PR! I just updated this PR.

@@ -0,0 +1,97 @@
# Auto-generated with: [./compose -a 3 -z 1 -r 1 --minio --minio_port=9001 --minio_env_file=../../backup.env -w --port_offset=0 --expose_ports=false --mem= --names=false -O ../systest/backup/minio/docker-compose.yml]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

command: /gobin/dgraph ${COVERAGE_OUTPUT} zero --raft "idx=1;" --my=zero1:5080 --replicas=1 --logtostderr -v=2 --bindall
--tls "ca-cert=/dgraph-tls/ca.crt; server-cert=/dgraph-tls/node.crt; server-key=/dgraph-tls/node.key; internal-port=true; client-cert=/dgraph-tls/client.zero1.crt; client-key=/dgraph-tls/client.zero1.key;"
minio:
image: minio/minio:RELEASE.2020-11-13T20-10-18Z-arm64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -0,0 +1,94 @@
# Auto-generated with: [./compose -l -a 3 -z 1 -r 1 --alpha_volume data:/data --minio --minio_port=9001 --minio_env_file=export.env --port_offset=0 --expose_ports=false --alpha_env_file=export.env --mem= --names=false -O ../systest/export/docker-compose.yml]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

-v=2
--security "whitelist=10.0.0.0/8,172.16.0.0/12,192.168.0.0/16;"
minio:
image: minio/minio:RELEASE.2020-11-13T20-10-18Z-arm64
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

t/Makefile Show resolved Hide resolved
t/t.go Outdated
@@ -95,6 +95,7 @@ var (
"comma separated list of packages that needs to be skipped. "+
"Package Check uses string.Contains(). Please check the flag carefully")
runCoverage = pflag.Bool("coverage", false, "Set true to calculate test coverage")
arch = pflag.String("arch", "x86", "Machine architecture (required for systest/export test)")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment on which values it accepts. eg. Valid values: [arm, x86 etc.]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

t/t.go Show resolved Hide resolved
t/t.go Outdated Show resolved Hide resolved
@all-seeing-code
Copy link
Contributor

Wanted to test if the changes I proposed would work: #8508. cc: @joshua-goldstein @skrdgraph

@joshua-goldstein
Copy link
Contributor Author

Wanted to test if the changes I proposed would work: #8508. cc: @joshua-goldstein @skrdgraph

I was also wondering if the environment variable would get substituted at the appropriate time... Looks like it works fine. Thanks for the idea and testing it! I've updated this PR.

@all-seeing-code
Copy link
Contributor

@joshua-goldstein we can remove architecture flag and let the t.go figure it out itself. Much cleaner. Also can we log somewhere which architecture we are running tests on, so that we are sure that our changes flow through?

@joshua-goldstein
Copy link
Contributor Author

@joshua-goldstein we can remove architecture flag and let the t.go figure it out itself. Much cleaner. Also can we log somewhere which architecture we are running tests on, so that we are sure that our changes flow through?

So sometime like a runtime.GOARCH check? We can also do that easily.

@all-seeing-code
Copy link
Contributor

Another small comment which came up during the code review call, we can define default values for docker variables used in yml files. See: https://stackoverflow.com/questions/70772517/docker-compose-env-default-with-fallback

Should we use that and insert a different value only for ARM?

(Apologies for a separate comment, should have added this earlier but forgot).

@joshua-goldstein
Copy link
Contributor Author

joshua-goldstein commented Dec 12, 2022

Another small comment which came up during the code review call, we can define default values for docker variables used in yml files. See: https://stackoverflow.com/questions/70772517/docker-compose-env-default-with-fallback

Should we use that and insert a different value only for ARM?

(Apologies for a separate comment, should have added this earlier but forgot).

Also a good catch - what I did was add a default value now, so if the environment variable is not set it will use the previously used tag (see docs here).

Copy link
Contributor

@all-seeing-code all-seeing-code left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Joshua! Looks good to me.

@skrdgraph skrdgraph merged commit bc71dc3 into main Dec 13, 2022
@skrdgraph skrdgraph deleted the joshua/arm-fix branch December 13, 2022 00:49
all-seeing-code pushed a commit that referenced this pull request Dec 14, 2022
## Problem

Systest/export backup to minio was failing on arm64.

## Solution

The minio image that we require was published before multi-architecture
docker images were introduced. As such, there are two tags, namely
`RELEASE.2020-11-13T20-10-18Z` (which we currently use for
systest/export) and `RELEASE.2020-11-13T20-10-18Z-arm64` (which is
required for arm64). See the Dockerhub page
[here](https://hub.docker.com/r/minio/minio/tags?page=1&name=RELEASE.2020-11-13T20-10-18Z).

Unfortunately docker-compose files do not offer some sort of conditional
logic. As such the easiest way to use this image is to create a new
docker-compose-arm64.yml file and a flag that specifies when it should
be uses at the t.go level. This is not so elegant but is the easiest
solution currently since we lack a way to dynamically generate
docker-compose files.

This PR also improves some testing functionality. In brief, all that is
required to run tests now is to run `make test` from the root dgraph
directory. If one wants to run specific package tests (e.g.
systest/export) one can use `make test args="--pkg=systest/export"`.
What this does is pass the `--pkg=systest/export` flag to the t.go
binary when it is run. This has the benefit that any number of arguments
can be passed to t.go. E.g., in the process of testing this PR, I ran
```
make test args="--pkg=systest/export --arch=arm64"
```

which (after building the dgraph binary and making a dgraph docker image
with local tag) builds t.go and executes `./t --pkg=systest/export
--arch-arm64`

Finally, we fix a logic error that was introduced recently in t.go.
Coverage files should only be copied over when t.go is run in coverage
mode.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/integrations Related to integrations with other projects. area/testing Testing related issues
Development

Successfully merging this pull request may close these issues.

4 participants