Skip to content

Commit

Permalink
Remove serverless dependencies test. (#31149)
Browse files Browse the repository at this point in the history
  • Loading branch information
purple4reina authored Nov 25, 2024
1 parent df19dfb commit 30d51b5
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 2,443 deletions.
1 change: 0 additions & 1 deletion .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@
/cmd/otel-agent/ @DataDog/opentelemetry
/cmd/process-agent/ @DataDog/processes
/cmd/serverless/ @DataDog/serverless @Datadog/serverless-aws
/cmd/serverless/dependencies*.txt @DataDog/serverless @DataDog/agent-shared-components
/cmd/serverless-init/ @DataDog/serverless
/cmd/system-probe/ @DataDog/ebpf-platform
/cmd/system-probe/config/adjust_npm.go @DataDog/ebpf-platform @DataDog/Networks
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/serverless-binary-size.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ name: "Serverless Binary Size"

on:
pull_request:
paths:
- 'cmd/serverless/**'
- 'cmd/serverless-init/**'
- 'pkg/serverless/**'

env:
SIZE_ALLOWANCE: fromJSON(1000000) # 1 MB
Expand Down
2 changes: 0 additions & 2 deletions .gitlab/JOBOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ prepare_secagent_ebpf_functional_tests* @DataDog/agent-security

# Send count metrics about Golang dependencies
golang_deps_send_count_metrics @DataDog/agent-shared-components
# Golang test dependecies diff
golang_deps_test @DataDog/agent-shared-components
# Golang dependency diff generation
golang_deps_diff @DataDog/ebpf-platform
golang_deps_commenter @DataDog/ebpf-platform
Expand Down
12 changes: 0 additions & 12 deletions .gitlab/source_test/golang_deps_diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,3 @@ golang_deps_send_count_metrics:
# Get API key to send metrics
- DD_API_KEY=$($CI_PROJECT_DIR/tools/ci/fetch_secret.sh $AGENT_API_KEY_ORG2 token) || exit $?; export DD_API_KEY
- inv -e go-deps.send-count-metrics --git-sha "${CI_COMMIT_SHA}" --git-ref "${CI_COMMIT_REF_NAME}"

golang_deps_test:
stage: source_test
image: registry.ddbuild.io/ci/datadog-agent-buildimages/deb_x64$DATADOG_AGENT_BUILDIMAGES_SUFFIX:$DATADOG_AGENT_BUILDIMAGES
tags: ["arch:amd64"]
rules:
- when: on_success
needs: ["go_deps"]
before_script:
- !reference [.retrieve_linux_go_deps]
script:
- inv -e go-deps.test-list
1,161 changes: 0 additions & 1,161 deletions cmd/serverless/dependencies_linux_amd64.txt

This file was deleted.

1,159 changes: 0 additions & 1,159 deletions cmd/serverless/dependencies_linux_arm64.txt

This file was deleted.

108 changes: 0 additions & 108 deletions tasks/go_deps.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import datetime
import io
import os
from collections import namedtuple
from collections.abc import Iterable

from invoke.context import Context
Expand Down Expand Up @@ -150,112 +148,6 @@ def send_count_metrics(
print(color_message("Done", "green"))


BINARY_TO_TEST = ["serverless"]
MisMatchBinary = namedtuple('MisMatchBinary', ['binary', 'os', 'arch', 'differences'])


@task
def test_list(
ctx: Context,
):
"""
Compare the dependencies list for the binaries in BINARY_TO_TEST with the actual dependencies of the binaries.
If the lists do not match, the task will raise an error.
"""
mismatch_binaries = set()

for binary in BINARY_TO_TEST:
binary_info = BINARIES[binary]
entrypoint = binary_info["entrypoint"]
platforms = binary_info["platforms"]
flavor = binary_info.get("flavor", AgentFlavor.base)
build = binary_info.get("build", binary)

with ctx.cd(entrypoint):
for platform in platforms:
platform, arch = platform.split("/")

goos, goarch = GOOS_MAPPING[platform], GOARCH_MAPPING[arch]

filename = os.path.join(ctx.cwd, f"dependencies_{goos}_{goarch}.txt")
if not os.path.isfile(filename):
print(
f"File {filename} does not exist. To execute the dependencies list check for the {binary} binary, please run the task `inv -e go-deps.generate"
)
continue

deps_file = open(filename)
deps = deps_file.read().strip().splitlines()
deps_file.close()

list = compute_binary_dependencies_list(ctx, build, flavor, platform, arch)

if list != deps:
new_dependencies_lines = len(list)
recorded_dependencies_lines = len(deps)

mismatch_binaries.add(
MisMatchBinary(binary, goos, goarch, new_dependencies_lines - recorded_dependencies_lines)
)

if len(mismatch_binaries) > 0:
message = io.StringIO()

for mismatch_binary in mismatch_binaries:
if mismatch_binary.differences > 0:
message.write(
color_message(
f"You added some dependencies to {mismatch_binary.binary} ({mismatch_binary.os}/{mismatch_binary.arch}). Adding new dependencies to the binary increases its size. Do we really need to add this dependency?\n",
"red",
)
)
else:
message.write(
color_message(
f"You removed some dependencies from {mismatch_binary.binary} ({mismatch_binary.os}/{mismatch_binary.arch}). Congratulations!\n",
"green",
)
)

message.write(
color_message(
"To fix this check, please run `inv -e go-deps.generate`",
"orange",
)
)

raise Exit(
code=1,
message=message.getvalue(),
)


@task
def generate(
ctx: Context,
):
for binary in BINARY_TO_TEST:
binary_info = BINARIES[binary]
entrypoint = binary_info["entrypoint"]
platforms = binary_info["platforms"]
flavor = binary_info.get("flavor", AgentFlavor.base)
build = binary_info.get("build", binary)

with ctx.cd(entrypoint):
for platform in platforms:
platform, arch = platform.split("/")

goos, goarch = GOOS_MAPPING[platform], GOARCH_MAPPING[arch]

filename = os.path.join(ctx.cwd, f"dependencies_{goos}_{goarch}.txt")

list = compute_binary_dependencies_list(ctx, build, flavor, platform, arch)

f = open(filename, "w")
f.write('\n'.join(list))
f.close()


def key_for_value(map: dict[str, str], value: str) -> str:
"""Return the key from a value in a dictionary."""
for k, v in map.items():
Expand Down

0 comments on commit 30d51b5

Please sign in to comment.