Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Acceptance e2e tests for BTP user journey #2318

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,6 @@ mod
/template.yaml

dist/
tests/btp/sm.env
tests/btp/hana-admin-api-binding.json
tests/btp/config.json
65 changes: 60 additions & 5 deletions tests/btp/integration-test-btp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,75 @@ echo "Step2: List modules"
../../bin/kyma@v3 alpha module list

# -------------------------------------------------------------------------------------
echo "Step3: Connecting to remote BTP subaccount"
echo "Step3: Connecting to a service manager from remote BTP subaccount"

kubectl create secret generic remote-service-manager-credentials --namespace kyma-system --from-env-file sm.env

# -------------------------------------------------------------------------------------
echo "Step4: Create Shared Service Instance Reference"
echo "Step4: Create service instance reference to a shared object-store service instance"

echo "Waiting for CRD btp operator"
while ! kubectl get crd btpoperators.operator.kyma-project.io; do echo "Waiting for CRD btp operator..."; sleep 1; done
kubectl wait --for condition=established crd/btpoperators.operator.kyma-project.io
while ! kubectl get btpoperators.operator.kyma-project.io btpoperator --namespace kyma-system; do echo "Waiting for btpoperator..."; sleep 1; done
kubectl wait --for condition=Ready btpoperators.operator.kyma-project.io/btpoperator -n kyma-system --timeout=180s
../../bin/kyma@v3 alpha reference-instance \
--btp-secret-name remote-service-manager-credentials \
--namespace kyma-system \
--offering-name objectstore \
--plan-selector standard \
--reference-name object-store-reference

kubectl apply -n kyma-system -f ./k8s-resources/object-store-binding.yaml
while ! kubectl get secret object-store-reference-binding --namespace kyma-system; do echo "Waiting for object-store-reference-binding secret..."; sleep 5; done

# -------------------------------------------------------------------------------------
# Enable Docker Registry
echo "Step5: Enable Docker Registry from experimental channel (with persistent BTP based storage)"
../../bin/kyma@v3 alpha module add docker-registry --channel experimental --cr-path k8s-resources/exposed-docker-registry.yaml
../../bin/kyma@v3 alpha module add docker-registry --channel experimental --cr-path k8s-resources/custom-docker-registry.yaml

echo "..waiting for docker registry"
kubectl wait --for condition=Installed dockerregistries.operator.kyma-project.io/default -n kyma-system --timeout=360s
kubectl wait --for condition=Installed dockerregistries.operator.kyma-project.io/custom-dr -n kyma-system --timeout=360s

dr_external_url=$(../../bin/kyma@v3 alpha registry config --externalurl)

#TODO new cli command
# dr_internal_pull_url=$(../../bin/kyma@v3 alpha registry config --internalurl)
dr_internal_pull_url=$(kubectl get dockerregistries.operator.kyma-project.io -n kyma-system custom-dr -ojsonpath={.status.internalAccess.pullAddress})

../../bin/kyma@v3 alpha registry config --output config.json

echo "Docker Registry enabled \n\t(URLs: $dr_external_url, $dr_internal_pull_url)"
echo "\t config.json for docker CLI access generated"
# -------------------------------------------------------------------------------------
echo "Step6: Map bookstore DB"
echo "Step6: Map SAP Hana DB instance with Kyma runtime"

../../bin/kyma@v3 alpha hana map --credentials-path hana-admin-api-binding.json

# -------------------------------------------------------------------------------------
echo "Step7: Push bookstore application (w/o Dockerfile)"

# build hdi-deploy via pack and push it via docker CLI (external url)
pack build hdi-deploy:latest -p sample-http-db-nodejs/hdi-deploy -B paketobuildpacks/builder:base
docker tag hdi-deploy:latest $dr_external_url/hdi-deploy:latest
docker --config . push $dr_external_url/hdi-deploy:latest

# continue



# -------------------------------------------------------------------------------------
echo "Cleanup"

kubectl delete dockerregistries.operator.kyma-project.io -n kyma-system custom-dr
# ../../bin/kyma@v3 alpha module delete docker-registry

kubectl delete servicebindings.services.cloud.sap.com -n kyma-system object-store-reference-binding
kubectl delete serviceinstances.services.cloud.sap.com -n kyma-system object-store-reference
kubectl delete secret -n kyma-system remote-service-manager-credentials

# TODO new command ?
# ../../bin/kyma@v3 alpha hana unmap --credentials-path hana-admin-api-binding.json
# -------------------------------------------------------------------------------------


Expand Down
11 changes: 11 additions & 0 deletions tests/btp/k8s-resources/custom-docker-registry.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: operator.kyma-project.io/v1alpha1
kind: DockerRegistry
metadata:
name: custom-dr
namespace: kyma-system
spec:
externalAccess:
enabled: true
storage:
btpObjectStore:
secretName: object-store-reference-binding
182 changes: 182 additions & 0 deletions tests/btp/k8s-resources/db/books-hdi-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: books-hdi-config
data:
books.hdbtable: |
COLUMN TABLE "bookstore.db::books"
(
"id" INTEGER,
"title" VARCHAR(100),
"author" VARCHAR(100),
PRIMARY KEY ("id")
)
books.hdbtabledata: |
{
"format_version": 1,
"imports": [
{
"target_table": "bookstore.db::books",
"source_data": {
"data_type": "CSV",
"file_name": "bookstore.db::books.csv",
"has_header": true,
"type_config": {
"delimiter": ",",
"do_quote": true
}
},
"import_settings": {
"import_columns": [
"id",
"title",
"author"
]
}
}
]
}
books.csv: |
id,title,author
1,Dune,Frank Herbert
2,Pippi Goes on Board,Astrid Lindgren
.hdinamespace: |-
{
"name": "bookstore.db",
"subfolder": "append"
}
.hdiconfig: |-
{
"minimum_feature_version": "1000",
"file_suffixes": {
"hdbapplicationtime": {
"plugin_name": "com.sap.hana.di.applicationtime"
},
"hdbcalculationview": {
"plugin_name": "com.sap.hana.di.calculationview"
},
"hdbconstraint": {
"plugin_name": "com.sap.hana.di.constraint"
},
"txt": {
"plugin_name": "com.sap.hana.di.copyonly"
},
"hdbdropcreatetable": {
"plugin_name": "com.sap.hana.di.dropcreatetable"
},
"hdbflowgraph": {
"plugin_name": "com.sap.hana.di.flowgraph"
},
"hdbfunction": {
"plugin_name": "com.sap.hana.di.function"
},
"hdbgraphworkspace": {
"plugin_name": "com.sap.hana.di.graphworkspace"
},
"hdbindex": {
"plugin_name": "com.sap.hana.di.index"
},
"hdblibrary": {
"plugin_name": "com.sap.hana.di.library"
},
"hdblogicalschema": {
"plugin_name": "com.sap.hana.di.logicalschema"
},
"hdbprocedure": {
"plugin_name": "com.sap.hana.di.procedure"
},
"hdbprojectionview": {
"plugin_name": "com.sap.hana.di.projectionview"
},
"hdbprojectionviewconfig": {
"plugin_name": "com.sap.hana.di.projectionview.config"
},
"hdbreptask": {
"plugin_name": "com.sap.hana.di.reptask"
},
"hdbresultcache": {
"plugin_name": "com.sap.hana.di.resultcache"
},
"hdbrole": {
"plugin_name": "com.sap.hana.di.role"
},
"hdbroleconfig": {
"plugin_name": "com.sap.hana.di.role.config"
},
"hdbsearchruleset": {
"plugin_name": "com.sap.hana.di.searchruleset"
},
"hdbsequence": {
"plugin_name": "com.sap.hana.di.sequence"
},
"hdbanalyticprivilege": {
"plugin_name": "com.sap.hana.di.analyticprivilege"
},
"hdbview": {
"plugin_name": "com.sap.hana.di.view"
},
"hdbstatistics": {
"plugin_name": "com.sap.hana.di.statistics"
},
"hdbstructuredprivilege": {
"plugin_name": "com.sap.hana.di.structuredprivilege"
},
"hdbsynonym": {
"plugin_name": "com.sap.hana.di.synonym"
},
"hdbsynonymconfig": {
"plugin_name": "com.sap.hana.di.synonym.config"
},
"hdbsystemversioning": {
"plugin_name": "com.sap.hana.di.systemversioning"
},
"hdbtable": {
"plugin_name": "com.sap.hana.di.table"
},
"hdbmigrationtable": {
"plugin_name": "com.sap.hana.di.table.migration"
},
"hdbtabletype": {
"plugin_name": "com.sap.hana.di.tabletype"
},
"hdbtabledata": {
"plugin_name": "com.sap.hana.di.tabledata"
},
"csv": {
"plugin_name": "com.sap.hana.di.tabledata.source"
},
"properties": {
"plugin_name": "com.sap.hana.di.tabledata.properties"
},
"tags": {
"plugin_name": "com.sap.hana.di.tabledata.properties"
},
"hdbtrigger": {
"plugin_name": "com.sap.hana.di.trigger"
},
"hdbvirtualfunction": {
"plugin_name": "com.sap.hana.di.virtualfunction"
},
"hdbvirtualfunctionconfig": {
"plugin_name": "com.sap.hana.di.virtualfunction.config"
},
"hdbvirtualpackagehadoop": {
"plugin_name": "com.sap.hana.di.virtualpackage.hadoop"
},
"hdbvirtualpackagesparksql": {
"plugin_name": "com.sap.hana.di.virtualpackage.sparksql"
},
"hdbvirtualprocedure": {
"plugin_name": "com.sap.hana.di.virtualprocedure"
},
"hdbvirtualprocedureconfig": {
"plugin_name": "com.sap.hana.di.virtualprocedure.config"
},
"hdbvirtualtable": {
"plugin_name": "com.sap.hana.di.virtualtable"
},
"hdbvirtualtableconfig": {
"plugin_name": "com.sap.hana.di.virtualtable.config"
}
}
}
42 changes: 42 additions & 0 deletions tests/btp/k8s-resources/db/books-hdi-initjob-template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
apiVersion: batch/v1
kind: Job
metadata:
creationTimestamp: null
name: hana-hdi-initjob
spec:
completions: 1
manualSelector: false
parallelism: 1
template:
metadata:
creationTimestamp: null
labels:
sidecar.istio.io/inject: "false"
spec:
containers:
- env:
- name: SERVICE_BINDING_ROOT
value: /bindings
- name: EXIT
value: "true"
- name: EXIT_PROCESS_AFTER_UPLOAD
value: "true"
image: foo # this will be changed dynamically
imagePullPolicy: Always
name: bookstore-db
resources: {}
volumeMounts:
- name: hdi
mountPath: /bindings/hdi
readOnly: true
restartPolicy: OnFailure
securityContext:
runAsNonRoot: true
runAsUser: 1000
volumes:
- name: hdi
secret:
secretName: hana-hdi-binding
imagePullSecrets:
- name: dockerregistry-config
status: {}
8 changes: 8 additions & 0 deletions tests/btp/k8s-resources/db/hana-hdi-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: services.cloud.sap.com/v1
kind: ServiceBinding
metadata:
name: hana-hdi-binding
spec:
serviceInstanceName: hana-hdi-instance
externalName: hana-hdi
secretName: hana-hdi-binding
8 changes: 8 additions & 0 deletions tests/btp/k8s-resources/db/hana-hdi-instance.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: services.cloud.sap.com/v1
kind: ServiceInstance
metadata:
name: hana-hdi-instance
spec:
externalName: hana-hdi
serviceOfferingName: hana
servicePlanName: hdi-shared
8 changes: 8 additions & 0 deletions tests/btp/k8s-resources/db/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- hana-hdi-instance.yaml
- hana-hdi-binding.yaml
- books-hdi-config.yaml
- books-hdi-initjob.yaml

7 changes: 0 additions & 7 deletions tests/btp/k8s-resources/exposed-docker-registry.yaml

This file was deleted.

8 changes: 8 additions & 0 deletions tests/btp/k8s-resources/object-store-binding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: services.cloud.sap.com/v1
kind: ServiceBinding
metadata:
name: object-store-reference-binding
spec:
serviceInstanceName: object-store-reference
externalName: object-store-reference-binding
secretName: object-store-reference-binding
Loading
Loading