@@ -2,6 +2,7 @@ package e2e
22
33import (
44 "os"
5+ "os/exec"
56 "testing"
67 "time"
78
@@ -10,7 +11,6 @@ import (
1011 . "github.com/argoproj/argo-cd/v3/pkg/apis/application/v1alpha1"
1112 "github.com/argoproj/argo-cd/v3/test/e2e/fixture"
1213 . "github.com/argoproj/argo-cd/v3/test/e2e/fixture/app"
13- "github.com/argoproj/argo-cd/v3/util/errors"
1414
1515 . "github.com/argoproj/gitops-engine/pkg/sync/common"
1616)
@@ -204,7 +204,7 @@ func TestHydratorWithPlugin(t *testing.T) {
204204 Given (t ).
205205 Path ("hydrator-plugin" ).
206206 And (func () {
207- go startCMPServerForHydrator (t , "./testdata/hydrator-plugin" )
207+ startCMPServerForHydrator (t , "./testdata/hydrator-plugin" )
208208 time .Sleep (100 * time .Millisecond )
209209 }).
210210 When ().
@@ -288,36 +288,26 @@ func TestHydratorWithMixedSources(t *testing.T) {
288288 Expect (DoesNotExist ())
289289}
290290
291- func TestHydratorErrorHandling (t * testing.T ) {
292- Given (t ).
293- Name ("test-invalid-hydrator" ).
294- Path ("hydrator-invalid" ).
295- When ().
296- CreateFromFile (func (app * Application ) {
297- app .Spec .SourceHydrator = & SourceHydrator {
298- DrySource : DrySource {
299- RepoURL : fixture .RepoURL (fixture .RepoURLTypeFile ),
300- Path : "invalid-path" ,
301- TargetRevision : "HEAD" ,
302- },
303- SyncSource : SyncSource {
304- TargetBranch : "env/test" ,
305- Path : "hydrator-invalid" ,
306- },
307- }
308- }).
309- Then ().
310- Expect (Error ("" , "app path does not exist" ))
311- }
312-
313291func startCMPServerForHydrator (t * testing.T , configFile string ) {
314292 t .Helper ()
315293 pluginSockFilePath := fixture .TmpDir + fixture .PluginSockFilePath
316- t .Setenv ("ARGOCD_BINARY_NAME" , "argocd-cmp-server" )
317- t .Setenv ("ARGOCD_PLUGINSOCKFILEPATH" , pluginSockFilePath )
318294 if _ , err := os .Stat (pluginSockFilePath ); os .IsNotExist (err ) {
319295 err := os .Mkdir (pluginSockFilePath , 0o700 )
320296 require .NoError (t , err )
321297 }
322- errors .NewHandler (t ).FailOnErr (fixture .RunWithStdin ("" , "" , "../../dist/argocd-cmp-server" , "--config-dir-path" , configFile ))
298+
299+ cmd := exec .Command ("../../dist/argocd" , "--config-dir-path" , configFile )
300+ cmd .Env = append (os .Environ (),
301+ "ARGOCD_BINARY_NAME=argocd-cmp-server" ,
302+ "ARGOCD_PLUGINSOCKFILEPATH=" + pluginSockFilePath )
303+
304+ if err := cmd .Start (); err != nil {
305+ require .NoError (t , err , "Failed to start CMP server" )
306+ }
307+
308+ t .Cleanup (func () {
309+ if cmd .Process != nil {
310+ _ = cmd .Process .Kill ()
311+ }
312+ })
323313}
0 commit comments