Copilot commented on code in PR #105:
URL: 
https://github.com/apache/cloudstack-kubernetes-provider/pull/105#discussion_r3988763339


##########
Makefile:
##########
@@ -53,6 +64,38 @@ ifneq (${GIT_IS_TAG},NOT_A_TAG)
        docker tag apache/cloudstack-kubernetes-provider:${GIT_COMMIT_SHORT} 
apache/cloudstack-kubernetes-provider:${GIT_TAG}
 endif
 
+# Simulator-based e2e environment; see docs/development.md
+e2e-up:
+       hack/e2e/up.sh
+
+e2e-down:
+       hack/e2e/99-down.sh
+
+# go test runs with the package directory as its working directory, so
+# KUBECONFIG must be absolute.
+test-e2e:
+       @test -f hack/e2e/_out/keys.env || (echo "environment not up; run 'make 
e2e-up' first" && exit 1)
+       . hack/e2e/_out/keys.env && \
+       KUBECONFIG=${CURDIR}/hack/e2e/_out/kubeconfig \
+       CS_API_URL=$(CS_API_URL) \
+       go test -tags e2e -v -timeout 30m ./test/e2e/... -run 
'TestLB|TestNode|TestAnnot'

Review Comment:
   These are external-state tests, but this command is cacheable by `go test`. 
Re-running the suite against the same checkout, kubeconfig, and credentials can 
return a cached successful result without making any CloudStack/Kubernetes 
calls, so a changed environment can be reported as passing. Disable the Go test 
cache for the e2e target with `-count=1`.



##########
Makefile:
##########
@@ -53,6 +64,38 @@ ifneq (${GIT_IS_TAG},NOT_A_TAG)
        docker tag apache/cloudstack-kubernetes-provider:${GIT_COMMIT_SHORT} 
apache/cloudstack-kubernetes-provider:${GIT_TAG}
 endif
 
+# Simulator-based e2e environment; see docs/development.md
+e2e-up:
+       hack/e2e/up.sh
+
+e2e-down:
+       hack/e2e/99-down.sh
+
+# go test runs with the package directory as its working directory, so
+# KUBECONFIG must be absolute.
+test-e2e:
+       @test -f hack/e2e/_out/keys.env || (echo "environment not up; run 'make 
e2e-up' first" && exit 1)
+       . hack/e2e/_out/keys.env && \
+       KUBECONFIG=${CURDIR}/hack/e2e/_out/kubeconfig \
+       CS_API_URL=$(CS_API_URL) \
+       go test -tags e2e -v -timeout 30m ./test/e2e/... -run 
'TestLB|TestNode|TestAnnot'
+
+# Phase 2. Run hack/e2e/50-topology-vpc.sh first: it creates the project, VPC
+# and tier, and re-points the CCM at the project. These tests only exercise
+# anything with CS_PROJECT_ID set, and skip otherwise.
+e2e-vpc:
+       hack/e2e/50-topology-vpc.sh
+
+test-e2e-vpc:
+       @test -f hack/e2e/_out/ids.env || (echo "VPC topology not created; run 
'make e2e-vpc' first" && exit 1)
+       @grep -q E2E_PROJECT_ID hack/e2e/_out/ids.env || (echo "VPC topology 
not created; run 'make e2e-vpc' first" && exit 1)
+       . hack/e2e/_out/keys.env && . hack/e2e/_out/ids.env && \
+       KUBECONFIG=${CURDIR}/hack/e2e/_out/kubeconfig \
+       CS_API_URL=$(CS_API_URL) \
+       CS_PROJECT_ID="$$E2E_PROJECT_ID" \
+       E2E_ACL_ID="$$E2E_ACL_ID" E2E_VPC_ID="$$E2E_VPC_ID" \
+       go test -tags e2e -v -timeout 30m ./test/e2e/... -run 'TestVPC'

Review Comment:
   The VPC phase has the same external-state test-cache problem: without 
`-count=1`, a prior successful `TestVPC` run with the same environment inputs 
can be reused even if the VPC/ACL state has changed. Disable the cache for this 
target as well.



##########
test/e2e/vpc_test.go:
##########
@@ -0,0 +1,261 @@
+//go:build e2e
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package e2e
+
+import (
+       "context"
+       "os"
+       "strings"
+       "testing"
+
+       corev1 "k8s.io/api/core/v1"
+       metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
+)
+
+// vpcFramework skips unless the harness is in the VPC phase.
+//
+// 50-topology-vpc.sh appends E2E_ACL_ID, E2E_VPC_ID and E2E_PROJECT_ID to
+// hack/e2e/_out/ids.env. Note that the project is read from CS_PROJECT_ID, not
+// E2E_PROJECT_ID, because it also configures the CloudStack client in
+// NewFramework; the test runner maps one to the other. To run this phase by
+// hand:
+//
+//     . hack/e2e/_out/ids.env
+//     CS_PROJECT_ID="$E2E_PROJECT_ID" go test -tags e2e ./test/e2e/... -run 
TestVPC

Review Comment:
   This hand-run command only sources `ids.env` and sets `CS_PROJECT_ID`. In a 
fresh shell, `NewFramework` also requires `CS_API_URL`, `CS_API_KEY`, 
`CS_SECRET_KEY`, and `KUBECONFIG`, so following these instructions causes every 
test to skip and `go test` to exit successfully without running the VPC phase. 
Source the generated environment and key files (or direct users to the make 
target) before invoking `go test`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to