Skip to content

Conversation

wallrj-cyberark
Copy link
Member

@wallrj-cyberark wallrj-cyberark commented Aug 21, 2025

The test in cmd/ was not being run in CI so we didn't notice that it was failing.
It has been failing since we merged #670, because there we added the clusteruid detection to the agent startup code, and it unconditionally attempts to connect to a Kubernetes cluster, even when the agent is being run with --input-file and --output-file.
The --input-file option is used for testing the pushing of data to TLSPK or Jetstack Secure, in isolation.
The --output-file option is used for testing the collection of data, in isolation.
And theoretically, a user might choose to collect data from "air-gapped" (non-Internet-connected) clusters, using --output-file,
then use another instance of the agent to push the data to TLSPK from an Internet connected server.

I intend to move the clusteruid detection to be part of the data gathering process, in another PR: #687.

Here's the test failing, after I added the test to make test-unit:

=== FAIL: cmd TestAgentRunOneShot (3.00s)
    agent_test.go:41: Running child process
    agent_test.go:59: STDOUT
        I0820 15:46:20.507633    2589 run.go:59] "Starting" logger="Run" version="development" commit=""
        I0820 15:46:20.507840    2589 config.go:491] "Configured to push to Venafi" logger="Run" mode="Jetstack Secure API Token" reason="--api-token was specified"
        I0820 15:46:20.508298    2589 loader.go:402] Config loaded from file:  testdata/agent/one-shot/success/kubeconfig.yaml
        I0820 15:46:20.508483    2589 envvar.go:172] "Feature gate default state" feature="InOrderInformers" enabled=true
        I0820 15:46:20.508534    2589 envvar.go:172] "Feature gate default state" feature="WatchListClient" enabled=false
        I0820 15:46:20.508556    2589 envvar.go:172] "Feature gate default state" feature="ClientsAllowCBOR" enabled=false
        I0820 15:46:20.508579    2589 envvar.go:172] "Feature gate default state" feature="ClientsPreferCBOR" enabled=false
        I0820 15:46:20.508612    2589 envvar.go:172] "Feature gate default state" feature="InformerResourceVersion" enabled=false
        I0820 15:46:20.508963    2589 type.go:168] "Request Body" body=""
        I0820 15:46:20.509047    2589 round_trippers.go:527] "Request" curlCommand=<
        	curl -v -XGET  -H "Accept: application/vnd.kubernetes.protobuf,application/json" -H "User-Agent: preflight/v0.0.0 (linux/amd64) kubernetes/$Format" 'https://192.0.2.1:8443/api/v1/namespaces/kube-system'
         >
        
    agent_test.go:60: STDERR
        
    agent_test.go:61: 
        	Error Trace:	/home/runner/work/jetstack-secure/jetstack-secure/cmd/agent_test.go:61
        	Error:      	Received unexpected error:
        	            	signal: killed
        	Test:       	TestAgentRunOneShot
        	Messages:   	context deadline exceeded

@wallrj-cyberark wallrj-cyberark marked this pull request as ready for review August 21, 2025 06:14
@@ -7,7 +7,7 @@ test-unit: | $(NEEDS_GO) $(NEEDS_GOTESTSUM) $(ARTIFACTS) $(NEEDS_ETCD) $(NEEDS_K
--junitfile=$(ARTIFACTS)/junit-go-e2e.xml \
-- \
-coverprofile=$(ARTIFACTS)/filtered.cov \
./api/... ./pkg/... \
./cmd/... ./api/... ./pkg/... \
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tests in cmd are now being run
image

@wallrj-cyberark wallrj-cyberark merged commit c4bad68 into master Aug 21, 2025
2 checks passed
@wallrj-cyberark wallrj-cyberark deleted the VC-43403-fix-cmd-tests branch August 21, 2025 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants