From 041d1d8a1c5f08111b953a81382cdf6a2ea7cf1f Mon Sep 17 00:00:00 2001 From: Stan Rozenraukh Date: Tue, 4 Feb 2025 06:11:34 -0500 Subject: [PATCH] add e2e test for PHP language-detection (#33639) --- .../language_detection_test.go | 1 + .../tests/language-detection/php_test.go | 32 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 test/new-e2e/tests/language-detection/php_test.go diff --git a/test/new-e2e/tests/language-detection/language_detection_test.go b/test/new-e2e/tests/language-detection/language_detection_test.go index 52d06d382ec5a..f9f7db10d1971 100644 --- a/test/new-e2e/tests/language-detection/language_detection_test.go +++ b/test/new-e2e/tests/language-detection/language_detection_test.go @@ -56,6 +56,7 @@ func (s *languageDetectionSuite) SetupSuite() { s.BaseSuite.SetupSuite() s.installPython() + s.installPHP() } func (s *languageDetectionSuite) checkDetectedLanguage(command string, language string, source string) { diff --git a/test/new-e2e/tests/language-detection/php_test.go b/test/new-e2e/tests/language-detection/php_test.go new file mode 100644 index 0000000000000..79535dfe60329 --- /dev/null +++ b/test/new-e2e/tests/language-detection/php_test.go @@ -0,0 +1,32 @@ +// Unless explicitly stated otherwise all files in this repository are licensed +// under the Apache License Version 2.0. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2016-present Datadog, Inc. + +package languagedetection + +import ( + "strings" + + "github.com/DataDog/test-infra-definitions/components/datadog/agentparams" + "github.com/stretchr/testify/require" + + awshost "github.com/DataDog/datadog-agent/test/new-e2e/pkg/provisioners/aws/host" +) + +func (s *languageDetectionSuite) installPHP() { + s.Env().RemoteHost.MustExecute("sudo apt-get -y install php") + phpVersion := s.Env().RemoteHost.MustExecute("php -v") + require.True(s.T(), strings.HasPrefix(phpVersion, "PHP")) +} + +func (s *languageDetectionSuite) TestPHPDetectionCoreAgent() { + s.UpdateEnv(awshost.ProvisionerNoFakeIntake(awshost.WithAgentOptions(agentparams.WithAgentConfig(coreConfigStr)))) + s.runPHP() + s.checkDetectedLanguage("php", "php", "local_process_collector") +} + +func (s *languageDetectionSuite) runPHP() { + s.Env().RemoteHost.MustExecute("echo -e ' prog.php") + s.Env().RemoteHost.MustExecute("nohup php prog.php >myscript.log 2>&1