Skip to content

Commit

Permalink
Clean up integration test suite.
Browse files Browse the repository at this point in the history
Use constant variables. Remove unused variables in kind tests.
Consistent yaml formatting. Clarify readme.

Signed-off-by: Humair Khan <HumairAK@users.noreply.github.com>
  • Loading branch information
HumairAK authored and gmfrasca committed Jan 9, 2024
1 parent 0d25289 commit 754004f
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 32 deletions.
3 changes: 0 additions & 3 deletions .github/workflows/kind-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ concurrency:

env:
IMAGE_REPO_DSPO: data-science-pipelines-operator
QUAY_ORG: hukhan
QUAY_ID: ${{ secrets.QUAY_ID }}
QUAY_TOKEN: ${{ secrets.QUAY_TOKEN }}
DSPA_NAMESPACE: test-dspa
DSPA_NAME: test-dspa
DSPA_DEPLOY_WAIT_TIMEOUT: 300
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,8 @@ argoundeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/c

.PHONY: undeploy-kind
undeploy-kind: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
cd config/overlays/kind-tests && kustomize edit set namespace ${OPERATOR_NS}
cd config/overlays/kind-tests \
&& kustomize edit set namespace ${OPERATOR_NS}
kustomize build config/overlays/kind-tests | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

##@ Build Dependencies
Expand Down
14 changes: 7 additions & 7 deletions config/overlays/kind-tests/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: odh-applications
resources:
- ../../base
- ../../base
patchesStrategicMerge:
- img_patch.yaml
- res_patch.yaml
- user_patch.yaml
- img_patch.yaml
- res_patch.yaml
- user_patch.yaml
images:
- name: controller
newName: quay.io/opendatahub/data-science-pipelines-operator
newTag: main
- name: controller
newName: quay.io/opendatahub/data-science-pipelines-operator
newTag: main
5 changes: 3 additions & 2 deletions tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,17 @@ afterwards.
# Adjust the following as needed
KUBECONFIG_PATH=$HOME/.kube/config # this is usually the default
TARGET_CLUSTER=...(e.g. https://api.hukhan.dev.datahub.redhat.com:6443, you can retrieve this via `oc whoami --show-server`)
TARGET_NAMESPACE=dspa
TARGET_NAMESPACE=dspa # Do not use the same namespace as where DSPO is deployed (otherwise you will encounter some failed tests that verify DSPA deployment).

git clone git@github.com:opendatahub-io/data-science-pipelines-operator.git ${DSPO_REPO}

# Make sure DSPO is already deployed, if not then run:
oc new-project odh-applications
make deploy

make integrationtest \
K8SAPISERVERHOST=${TARGET_CLUSTER} \
DSPANAMESPACE=${NAMESPACE} \
DSPANAMESPACE=${TARGET_NAMESPACE} \
KUBECONFIGPATH=${KUBECONFIG_PATH}
```

Expand Down
51 changes: 32 additions & 19 deletions tests/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,22 @@ var (
)

var (
DefaultDeployTimeout time.Duration
DefaultPollInterval time.Duration
DefaultDeleteTimeout time.Duration
DeployTimeout time.Duration
PollInterval time.Duration
DeleteTimeout time.Duration
)

const (
DefaultKubeConfigPath = "~/.kube/config"
Defaultk8sApiServerHost = "localhost:6443"
DefaultDSPANamespace = "default"
DefaultDeployTimeout = 240
DefaultPollInterval = 2
DefaultDeleteTimeout = 120
DefaultPortforwardLocalPort = 8888
DefaultSkipDeploy = false
DefaultSkipCleanup = false
DefaultDSPAPath = ""
)

type ClientManager struct {
Expand All @@ -94,23 +107,23 @@ func TestAPIs(t *testing.T) {

// Register flags in an init function. This ensures they are registered _before_ `go test` calls flag.Parse()
func init() {
flag.StringVar(&kubeconfig, "kubeconfig", "~/.kube/config", "The path to the kubeconfig.")
flag.StringVar(&k8sApiServerHost, "k8sApiServerHost", "localhost:6443", "The k8s cluster api server host.")
flag.StringVar(&DSPAPath, "DSPAPath", "", "The DSP resource file to deploy for testing.")
flag.StringVar(&DSPANamespace, "DSPANamespace", "default", "The namespace to deploy DSPA.")
flag.StringVar(&kubeconfig, "kubeconfig", DefaultKubeConfigPath, "The path to the kubeconfig.")
flag.StringVar(&k8sApiServerHost, "k8sApiServerHost", Defaultk8sApiServerHost, "The k8s cluster api server host.")
flag.StringVar(&DSPAPath, "DSPAPath", DefaultDSPAPath, "The DSP resource file to deploy for testing.")
flag.StringVar(&DSPANamespace, "DSPANamespace", DefaultDSPANamespace, "The namespace to deploy DSPA.")

flag.DurationVar(&DefaultDeployTimeout, "DefaultDeployTimeout", 240, "Seconds to wait for deployments. Consider increasing this on resource starved environments.")
DefaultDeployTimeout *= time.Second
flag.DurationVar(&DefaultPollInterval, "DefaultPollInterval", 2, "Seconds to wait before retrying fetches to the api server.")
DefaultPollInterval *= time.Second
flag.DurationVar(&DefaultDeleteTimeout, "DefaultDeleteTimeout", 120, "Seconds to wait for deployment deletions. Consider increasing this on resource starved environments.")
DefaultDeleteTimeout *= time.Second
flag.DurationVar(&DeployTimeout, "DeployTimeout", DefaultDeployTimeout, "Seconds to wait for deployments. Consider increasing this on resource starved environments.")
DeployTimeout *= time.Second
flag.DurationVar(&PollInterval, "PollInterval", DefaultPollInterval, "Seconds to wait before retrying fetches to the api server.")
PollInterval *= time.Second
flag.DurationVar(&DeleteTimeout, "DeleteTimeout", DefaultDeleteTimeout, "Seconds to wait for deployment deletions. Consider increasing this on resource starved environments.")
DeleteTimeout *= time.Second

flag.IntVar(&PortforwardLocalPort, "PortforwardLocalPort", 8888, "Local port to use for port forwarding dspa server.")
flag.IntVar(&PortforwardLocalPort, "PortforwardLocalPort", DefaultPortforwardLocalPort, "Local port to use for port forwarding dspa server.")

flag.BoolVar(&skipDeploy, "skipDeploy", false, "Skip DSPA deployment. Use this if you have already "+
flag.BoolVar(&skipDeploy, "skipDeploy", DefaultSkipDeploy, "Skip DSPA deployment. Use this if you have already "+
"manually deployed a DSPA, and want to skip this part.")
flag.BoolVar(&skipCleanup, "skipCleanup", false, "Skip DSPA cleanup.")
flag.BoolVar(&skipCleanup, "skipCleanup", DefaultSkipCleanup, "Skip DSPA cleanup.")
}

var _ = BeforeSuite(func() {
Expand Down Expand Up @@ -147,9 +160,9 @@ var _ = BeforeSuite(func() {

if !skipDeploy {
loggr.Info("Deploying DSPA...")
systemsTesttUtil.DeployDSPA(ctx, clientmgr.k8sClient, DSPA, DSPANamespace, DefaultDeployTimeout, DefaultPollInterval)
systemsTesttUtil.DeployDSPA(ctx, clientmgr.k8sClient, DSPA, DSPANamespace, DeployTimeout, PollInterval)
loggr.Info("Waiting for DSPA pods to ready...")
systemsTesttUtil.WaitForDSPAReady(ctx, clientmgr.k8sClient, DSPA.Name, DSPANamespace, DefaultDeployTimeout, DefaultPollInterval)
systemsTesttUtil.WaitForDSPAReady(ctx, clientmgr.k8sClient, DSPA.Name, DSPANamespace, DeployTimeout, PollInterval)
loggr.Info("DSPA Deployed.")
}

Expand Down Expand Up @@ -185,7 +198,7 @@ var _ = BeforeEach(func() {

var _ = AfterSuite(func() {
if !skipCleanup {
systemsTesttUtil.DeleteDSPA(ctx, clientmgr.k8sClient, DSPA.Name, DSPANamespace, DefaultDeployTimeout, DefaultPollInterval)
systemsTesttUtil.DeleteDSPA(ctx, clientmgr.k8sClient, DSPA.Name, DSPANamespace, DeployTimeout, PollInterval)
}
forwarderResult.Close()
})

0 comments on commit 754004f

Please sign in to comment.