-
Notifications
You must be signed in to change notification settings - Fork 68
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
Add transformation test make target and docs #1722
base: master
Are you sure you want to change the base?
Conversation
This PR adds make targets for transformation tests, as well as usage docs. Some other things were fixed incidentally: * Running the `precommit_update` target yielded numerous files missing license headers * Fixed warnings in `transformation_test.go` Signed-off-by: braydonk <[email protected]>
|
||
`tasks.mak` is provided without any guarantees or warranty on its targets. It is meant purely for developer convenience, and it is advised not to make any dependency on the targets since they are subject to change at any time. |
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.
[Optional] I wonder if we should be calling it developer_tasks.mak
or something…
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 originally chose tasks.mak
just cause it was shorter, and at first it seemed like we'd need to always type in -f tasks.mak
so making it longer would have been a pain. We could change it now, though it really only exists to then be immediately symlinked to when you set up your environment.
I think this makes more sense, and also fixes a typo I had here previously that caused the tests to fail.
This reverts commit dbb99ab.
builds/fluent_bit.sh
Outdated
-DFLB_CONFIG_YAML=OFF | ||
make -j8 | ||
make DESTDIR="$DESTDIR" install | ||
if [[ "$DESTDIR" = *"dist" ]]; then |
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 wonder — is there any harm in actually doing a full install into ${DESTDIR}
and pointing the tests to the installation path within that? That way we can fully reuse the existing build script, right?
As-is, using a DESTDIR
pattern to indicate local builds seems fragile to me. I'd almost rather add a new variable (e.g., LOCAL_BUILD
, or BINARY_ONLY
, or some such) and use that…
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.
Honestly we could do the install, the main reason I didn't is because it's super annoying how many folders it creates when we could just copy the binary
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.
Added LOCAL_ONLY
variable in f1d154e
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.
IMO, those additional folders are a small price to pay for removing the additional complexity in the build scripts. But let's see how non-invasive we can make this with LOCAL_ONLY
first…
builds/fluent_bit.sh
Outdated
-DFLB_CONFIG_YAML=OFF | ||
END | ||
CMAKE_ARGS=( | ||
"-DCMAKE_BUILD_TYPE=RelWithDebInfo" |
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.
[Optional] These quotes are also superfluous (but harmless).
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.
On second thought, these flags didn't use to have quotes on the command line, so it may make sense to not use quotes in the array as well… Except, maybe, for CMAKE_INSTALL_PREFIX
, which could become -DCMAKE_INSTALL_PREFIX="$fluent_bit_dir"
… WDYT?
builds/fluent_bit.sh
Outdated
-DFLB_CONFIG_YAML=OFF | ||
make -j8 | ||
make DESTDIR="$DESTDIR" install | ||
if [[ "$DESTDIR" = *"dist" ]]; then |
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.
IMO, those additional folders are a small price to pay for removing the additional complexity in the build scripts. But let's see how non-invasive we can make this with LOCAL_ONLY
first…
builds/fluent_bit.sh
Outdated
|
||
cd submodules/fluent-bit | ||
mkdir -p build | ||
cd build | ||
if [[ "$DESTDIR" = *"dist" ]]; then | ||
cmake .. $CMAKE_ARGS | ||
|
||
if [ "$LOCAL_ONLY" = "true" ]; then | ||
# If this is a local build, we can just build and copy the binary. | ||
cmake .. ${CMAKE_ARGS[@]} | ||
make -j8 | ||
mv ./bin/fluent-bit $DESTDIR | ||
cp ./bin/fluent-bit $DESTDIR | ||
|
||
# Otherwise, we do a full install. | ||
else | ||
fluent_bit_dir=/opt/google-cloud-ops-agent/subagents/fluent-bit | ||
# CMAKE_INSTALL_PREFIX here will cause the binary to be put at | ||
# /usr/lib/google-cloud-ops-agent/bin/fluent-bit | ||
# Additionally, -DFLB_SHARED_LIB=OFF skips building libfluent-bit.so | ||
cmake .. -DCMAKE_INSTALL_PREFIX=$fluent_bit_dir $CMAKE_ARGS | ||
cmake .. -DCMAKE_INSTALL_PREFIX=$fluent_bit_dir ${CMAKE_ARGS[@]} | ||
make -j8 |
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 can factor out the additional CMAKE_ARGS
and the install step into the non-local case…
if ! [ "$LOCAL_ONLY" = "true" ]; then
fluent_bit_dir=/opt/google-cloud-ops-agent/subagents/fluent-bit
CMAKE_ARGS=(
# CMAKE_INSTALL_PREFIX here will cause the binary to be put at
# /usr/lib/google-cloud-ops-agent/bin/fluent-bit
"-DCMAKE_INSTALL_PREFIX=$fluent_bit_dir"
"${CMAKE_ARGS[@]}"
)
fi
cd submodules/fluent-bit
mkdir -p build
cd build
cmake .. "${CMAKE_ARGS[@]}"
make -j8
# If this is a local build, we can just build and copy the binary.
if [ "$LOCAL_ONLY" = "true" ]; then
cp ./bin/fluent-bit "$DESTDIR"
# Otherwise, we do a full install.
else
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.
Obsoleted by 78fbf64 which changes the script to always function with a full install.
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.
[Optional] Heh, we could now revert back to the original inline args, unless you want to keep the array…
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.
There's actually no reason for this script to change at all anymore. Reverted it to its state in the main branch in 4ed4297 (left the license header added though)
tasks.mak
Outdated
test_confgenerator: | ||
go test ./confgenerator $(if $(UPDATE),-update,) | ||
|
||
.PHONY: test_confgenerator_update | ||
test_confgenerator_update: |
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.
[Optional] Would target-specific variables work in this case, e.g.:
test_confgenerator_update: UPDATE=true test_confgenerator
test_metadata_update: UPDATE=true test_metadata
…
transformation_test_update: UPDATE=true transformation_test
? We might need :=
instead of =
, but it ought to work…
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 couldn't get this to work. The only way UPDATE=true
was properly passed to the next target is the way I have it right now.
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.
Ah, I see what I did wrong — the variable assignment has to be a separate dependency. This works:
test_confgenerator_update: UPDATE=true
test_confgenerator_update: test_confgenerator
test_metadata_update: UPDATE=true
test_metadata_update: test_metadata
…
transformation_test_update: UPDATE=true
transformation_test_update: transformation_test
$ cat Makefile
t:
echo "[$(UPDATE)]"
u: UPDATE=true
u: t
v: UPDATE=false
v: t
$ make t
echo "[]"
[]
$ make u
echo "[true]"
[true]
$ make v
echo "[false]"
[false]
$
But up to you…
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.
Done in d0194ea
builds/otel.sh
Outdated
@@ -15,17 +15,17 @@ | |||
|
|||
set -x -e | |||
|
|||
ROOTDIR="$1" | |||
DESTDIR="$1" |
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.
The quotes around $1
are superfluous (and didn't use to be there) — want to remove them for symmetry with fluent_bit.sh
?
builds/otel.sh
Outdated
DESTDIR="$1" | ||
otel_dir=/opt/google-cloud-ops-agent/subagents/opentelemetry-collector | ||
DESTDIR="${ROOTDIR}${otel_dir}" | ||
DESTDIR="${DESTDIR}${otel_dir}" | ||
|
||
mkdir -p $DESTDIR |
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.
Might be a good idea to have a separate name for the otel binary directory, and create the original $DESTDIR
separately, i.e.:
DESTDIR=$1
mkdir -p "$DESTDIR"
OTELDIR="${DESTDIR}${otel_dir}"
mkdir -p "$OTELDIR"
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 changed it anyway in 0800d03. The first assignment of DESTDIR was completely redundant. The DESTDIR is never used separately. The mkdir -p $DESTDIR
that's in there now should work fine.
builds/fluent_bit.sh
Outdated
CMAKE_ARGS=( | ||
# CMAKE_INSTALL_PREFIX here will cause the binary to be put at | ||
# /usr/lib/google-cloud-ops-agent/bin/fluent-bit |
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.
Just realized that this value is no longer accurate, is it?
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.
Obsoleted by 4ed4297
builds/fluent_bit.sh
Outdated
-DFLB_CONFIG_YAML=OFF | ||
END | ||
CMAKE_ARGS=( | ||
"-DCMAKE_BUILD_TYPE=RelWithDebInfo" |
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.
On second thought, these flags didn't use to have quotes on the command line, so it may make sense to not use quotes in the array as well… Except, maybe, for CMAKE_INSTALL_PREFIX
, which could become -DCMAKE_INSTALL_PREFIX="$fluent_bit_dir"
… WDYT?
builds/fluent_bit.sh
Outdated
|
||
cd submodules/fluent-bit | ||
mkdir -p build | ||
cd build | ||
if [[ "$DESTDIR" = *"dist" ]]; then | ||
cmake .. $CMAKE_ARGS | ||
|
||
if [ "$LOCAL_ONLY" = "true" ]; then | ||
# If this is a local build, we can just build and copy the binary. | ||
cmake .. ${CMAKE_ARGS[@]} | ||
make -j8 | ||
mv ./bin/fluent-bit $DESTDIR | ||
cp ./bin/fluent-bit $DESTDIR | ||
|
||
# Otherwise, we do a full install. | ||
else | ||
fluent_bit_dir=/opt/google-cloud-ops-agent/subagents/fluent-bit | ||
# CMAKE_INSTALL_PREFIX here will cause the binary to be put at | ||
# /usr/lib/google-cloud-ops-agent/bin/fluent-bit | ||
# Additionally, -DFLB_SHARED_LIB=OFF skips building libfluent-bit.so | ||
cmake .. -DCMAKE_INSTALL_PREFIX=$fluent_bit_dir $CMAKE_ARGS | ||
cmake .. -DCMAKE_INSTALL_PREFIX=$fluent_bit_dir ${CMAKE_ARGS[@]} | ||
make -j8 |
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.
[Optional] Heh, we could now revert back to the original inline args, unless you want to keep the array…
FLB=$(PWD)/dist/opt/google-cloud-ops-agent/subagents/fluent-bit/bin/fluent-bit \ | ||
OTELOPSCOL=$(PWD)/dist/opt/google-cloud-ops-agent/subagents/opentelemetry-collector/otelopscol \ |
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.
[Optional] Let's use $${PWD}
(bash variable quoting) instead of $(PWD)
(makefile quoting)?
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.
Why wouldn't we want to use makefile quoting in the makefile?
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.
Depends on whether you want the directory the make
command was invoked from ($(PWD)
, which is a make variable), or the current directory of the shell that make is running the current set of commands in ($${PWD}
, which is a shell variable). They might be the same in this case, I suppose…
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.
In this case, I do want the working directory of make and not the working directory of the shell, although I do not change the working directory of the shell during this target.
tasks.mak
Outdated
test_confgenerator: | ||
go test ./confgenerator $(if $(UPDATE),-update,) | ||
|
||
.PHONY: test_confgenerator_update | ||
test_confgenerator_update: |
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.
Ah, I see what I did wrong — the variable assignment has to be a separate dependency. This works:
test_confgenerator_update: UPDATE=true
test_confgenerator_update: test_confgenerator
test_metadata_update: UPDATE=true
test_metadata_update: test_metadata
…
transformation_test_update: UPDATE=true
transformation_test_update: transformation_test
$ cat Makefile
t:
echo "[$(UPDATE)]"
u: UPDATE=true
u: t
v: UPDATE=false
v: t
$ make t
echo "[]"
[]
$ make u
echo "[true]"
[true]
$ make v
echo "[false]"
[false]
$
But up to you…
FLB=$(PWD)/dist/opt/google-cloud-ops-agent/subagents/fluent-bit/bin/fluent-bit \ | ||
OTELOPSCOL=$(PWD)/dist/opt/google-cloud-ops-agent/subagents/opentelemetry-collector/otelopscol \ |
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.
Depends on whether you want the directory the make
command was invoked from ($(PWD)
, which is a make variable), or the current directory of the shell that make is running the current set of commands in ($${PWD}
, which is a shell variable). They might be the same in this case, I suppose…
Something that I want to do over FixIt is to clean up the Makefile and make it better since I'm much better at writing make than I was when I first made the Makefile. Also, our update to |
Description
This PR adds make targets for transformation tests, as well as usage docs.
Some other things were fixed incidentally:
precommit_update
target yielded numerous files missing license headerstransformation_test.go
Related issue
These updates will feed into updating the otelopscol version.
How has this been tested?
All make targets have been run.
Checklist: