Skip to content

Commit

Permalink
add e2e test for PHP language-detection (#33639)
Browse files Browse the repository at this point in the history
  • Loading branch information
stanistan authored Feb 4, 2025
1 parent 7eafe83 commit 041d1d8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
32 changes: 32 additions & 0 deletions test/new-e2e/tests/language-detection/php_test.go
Original file line number Diff line number Diff line change
@@ -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 '<?php sleep(60);' > prog.php")
s.Env().RemoteHost.MustExecute("nohup php prog.php >myscript.log 2>&1 </dev/null &")
}

0 comments on commit 041d1d8

Please sign in to comment.