diff --git a/Jenkinsfile.integration b/Jenkinsfile.integration new file mode 100644 index 000000000..fccced209 --- /dev/null +++ b/Jenkinsfile.integration @@ -0,0 +1,32 @@ +pipeline { + agent { label 'upbound-gce' } + + options { + disableConcurrentBuilds() + timestamps() + } + + environment { + GCP_SA = credentials('inttests-sa') + KUBE_SECRET = credentials('inttests-kubeconfig') + } + + stages { + stage('Integration Tests') { + steps { + sh ''' + set +x + cp $KUBE_SECRET kubeconfig.yaml + cp $GCP_SA sa.json + ''' + sh "./build/run make -j\$(nproc) go-integration" + } + } + } + + post { + always { + deleteDir() + } + } +} diff --git a/Makefile b/Makefile index 4d0f6a3a5..abcb1c0b3 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,8 @@ NPROCS ?= 1 # to half the number of CPU cores. GO_TEST_PARALLEL := $(shell echo $$(( $(NPROCS) / 2 ))) +GO_INTEGRATION_TESTS_SUBDIRS = test + GO_STATIC_PACKAGES = $(GO_PROJECT)/cmd/stack GO_LDFLAGS += -X $(GO_PROJECT)/pkg/version.Version=$(VERSION) GO_SUBDIRS += cmd pkg apis @@ -93,6 +95,9 @@ test-integration: $(KIND) $(KUBECTL) @$(ROOT_DIR)/cluster/local/integration_tests.sh || $(FAIL) @$(OK) integration tests passed +go-integration: + GO_TEST_FLAGS=-v GO_TAGS=integration $(MAKE) go.test.integration + # Update the submodules, such as the common build scripts. submodules: @git submodule sync @@ -142,7 +147,7 @@ clean-stack-package: manifests: @$(INFO) Deprecated. Run make generate instead. -.PHONY: cobertura reviewable submodules fallthrough test-integration run clean-stack-package build-stack-package manifests +.PHONY: cobertura reviewable submodules fallthrough test-integration run clean-stack-package build-stack-package manifests go-integration # ==================================================================================== # Special Targets diff --git a/go.mod b/go.mod index 2ab927868..e7a787a37 100644 --- a/go.mod +++ b/go.mod @@ -23,4 +23,5 @@ require ( k8s.io/client-go v0.0.0-20190918160344-1fbdaa4c8d90 sigs.k8s.io/controller-runtime v0.4.0 sigs.k8s.io/controller-tools v0.2.4 + sigs.k8s.io/yaml v1.1.0 ) diff --git a/go.sum b/go.sum index e7a9968eb..22679f2d9 100644 --- a/go.sum +++ b/go.sum @@ -9,15 +9,21 @@ cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbf cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= github.com/Azure/go-ansiterm v0.0.0-20170929234023-d6e3b3328b78/go.mod h1:LmzpDX56iTiv29bbRTIsUNlaFfuhWRQBWjQdVyAevI8= github.com/Azure/go-autorest/autorest v0.9.0/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= +github.com/Azure/go-autorest/autorest v0.9.2 h1:6AWuh3uWrsZJcNoCHrCF/+g4aKPCU39kaMO6/qrnK/4= github.com/Azure/go-autorest/autorest v0.9.2/go.mod h1:xyHB1BMZT0cuDHU7I0+g046+BFDTQ8rEZB0s4Yfa6bI= github.com/Azure/go-autorest/autorest/adal v0.5.0/go.mod h1:8Z9fGy2MpX0PvDjB1pEgQTmVqjGhiHBW7RJJEciWzS0= +github.com/Azure/go-autorest/autorest/adal v0.8.0 h1:CxTzQrySOxDnKpLjFJeZAS5Qrv/qFPkgLjx5bOAi//I= github.com/Azure/go-autorest/autorest/adal v0.8.0/go.mod h1:Z6vX6WXXuyieHAXwMj0S6HY6e6wcHn37qQMBQlvY3lc= github.com/Azure/go-autorest/autorest/date v0.1.0/go.mod h1:plvfp3oPSKwf2DNjlBjWF/7vwR+cUD/ELuzDCXwHUVA= +github.com/Azure/go-autorest/autorest/date v0.2.0 h1:yW+Zlqf26583pE43KhfnhFcdmSWlm5Ew6bxipnr/tbM= github.com/Azure/go-autorest/autorest/date v0.2.0/go.mod h1:vcORJHLJEh643/Ioh9+vPmf1Ij9AEBM5FuBIXLmIy0g= github.com/Azure/go-autorest/autorest/mocks v0.1.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= github.com/Azure/go-autorest/autorest/mocks v0.2.0/go.mod h1:OTyCOPRA2IgIlWxVYxBee2F5Gr4kF2zd2J5cFRaIDN0= +github.com/Azure/go-autorest/autorest/mocks v0.3.0 h1:qJumjCaCudz+OcqE9/XtEPfvtOjOmKaui4EOpFI6zZc= github.com/Azure/go-autorest/autorest/mocks v0.3.0/go.mod h1:a8FDP3DYzQ4RYfVAxAN3SVSiiO77gL2j2ronKKP0syM= +github.com/Azure/go-autorest/logger v0.1.0 h1:ruG4BSDXONFRrZZJ2GUXDiUyVpayPmb1GnWeHDdaNKY= github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6LSNgds39diKLz7Vrc= +github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -37,11 +43,13 @@ github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk5 github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8= github.com/asaskevich/govalidator v0.0.0-20180720115003-f9ffefc3facf/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= github.com/asaskevich/govalidator v0.0.0-20190424111038-f61b66f89f4a/go.mod h1:lB+ZfQJz7igIIfQNfa7Ml4HSf2uFQQRzpGGRXenZAgY= +github.com/aws/aws-sdk-go v1.15.78 h1:LaXy6lWR0YK7LKyuU0QWy2ws/LWTPfYV/UgfiBu4tvY= github.com/aws/aws-sdk-go v1.15.78/go.mod h1:E3/ieXAlvM0XWO57iftYVDLLvQ824smPP3ATZkfNZeM= github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d h1:xDfNPAt8lFiC1UJrqV3uuy861HCTo708pDMbjHHdCas= github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d/go.mod h1:6QX/PXZ00z/TKoufEY6K/a0k6AhaJrQKdFe6OfVXsa4= github.com/blang/semver v3.5.0+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= github.com/cheggaaa/pb v1.0.27/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s= @@ -70,6 +78,7 @@ github.com/davecgh/go-spew v0.0.0-20151105211317-5215b55f46b2/go.mod h1:J7Y8YcW2 github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/dgrijalva/jwt-go v3.2.0+incompatible h1:7qlOGliEKZXTDg6OTjfoBKDXWrumCAMpl/TFQ4/5kLM= github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/docker/docker v0.7.3-0.20190327010347-be7ac8be2ae0/go.mod h1:eEKB0N0r5NX/I1kEveEz05bcu8tLC/8azJZsviup8Sk= github.com/docker/go-units v0.3.3/go.mod h1:fgPhTUdO+D/Jk86RDLlptpiXQzgHJF7gydDDbaIK4Dk= @@ -181,15 +190,20 @@ github.com/googleapis/gnostic v0.0.0-20170729233727-0c5108395e2d/go.mod h1:sJBsC github.com/googleapis/gnostic v0.3.1 h1:WeAefnSUHlBb0iJKwxFDZdbfGwkd7xRNuV+IpXMJhYk= github.com/googleapis/gnostic v0.3.1/go.mod h1:on+2t9HRStVgn95RSsFWFz+6Q0Snyqv1awfrALZdbtU= github.com/gophercloud/gophercloud v0.1.0/go.mod h1:vxM41WHh5uqHVBMZHzuwNOHh8XEoIEcSTewFxm1c5g8= +github.com/gophercloud/gophercloud v0.6.0 h1:Xb2lcqZtml1XjgYZxbeayEemq7ASbeTp09m36gQFpEU= github.com/gophercloud/gophercloud v0.6.0/go.mod h1:GICNByuaEBibcjmjvI7QvYJSZEbGkcYwAR7EZK2WMqM= github.com/gorilla/websocket v1.4.0/go.mod h1:E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ= github.com/gregjones/httpcache v0.0.0-20170728041850-787624de3eb7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA= github.com/grpc-ecosystem/go-grpc-middleware v0.0.0-20190222133341-cfaf5686ec79/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs= github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0/go.mod h1:8NvIoxWQoOIhqOTXgfV/d3M/q6VIi02HzZEHgUlZvzk= github.com/grpc-ecosystem/grpc-gateway v1.3.0/go.mod h1:RSKVYQBd5MCa4OVpNdGskqpgL2+G+NZTnrVHpWWfpdw= +github.com/hashicorp/go-cleanhttp v0.5.0 h1:wvCrVc9TjDls6+YGAF2hAifE1E5U1+b4tH6KdvN3Gig= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-getter v1.4.0 h1:ENHNi8494porjD0ZhIrjlAHnveSFhY7hvOJrV/fsKkw= github.com/hashicorp/go-getter v1.4.0/go.mod h1:7qxyCd8rBfcShwsvxgIguu4KbS3l8bUCwg2Umn7RjeY= +github.com/hashicorp/go-safetemp v1.0.0 h1:2HR189eFNrjHQyENnQMMpCiBAsRxzbTMIgBhEyExpmo= github.com/hashicorp/go-safetemp v1.0.0/go.mod h1:oaerMy3BhqiTbVye6QuFhFtIceqFoDHxNAB65b+Rj1I= +github.com/hashicorp/go-version v1.1.0 h1:bPIoEKD27tNdebFGGxxYwcL4nepeY4j1QP23PFRGzg0= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -204,6 +218,7 @@ github.com/imdario/mergo v0.3.7 h1:Y+UAYTZ7gDEuOfhxKWy+dvb5dRQ6rJjFSdX2HZY1/gI= github.com/imdario/mergo v0.3.7/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= +github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8 h1:12VvqtR6Aowv3l/EQUlocDHW2Cp4G9WJVH7uyH8QFJE= github.com/jmespath/go-jmespath v0.0.0-20160202185014-0b12d6b521d8/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo= github.com/json-iterator/go v0.0.0-20180612202835-f2b4162afba3/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= @@ -239,7 +254,9 @@ github.com/mattn/go-runewidth v0.0.4/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzp github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/go-testing-interface v1.0.0 h1:fzU/JVNcaqHQEcVFAKeR41fkiLdIPrefOvVG1VZ96U0= github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -319,6 +336,7 @@ github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJy github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/tmc/grpc-websocket-proxy v0.0.0-20170815181823-89b8d40f7ca8/go.mod h1:ncp9v5uamzpCO7NfCPTXjqaC+bZgJeR0sMTm6dMHP7U= github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0= +github.com/ulikunitz/xz v0.5.5 h1:pFrO0lVpTBXLpYw+pnLj6TbvHuyjXMfjGeCwSqCVwok= github.com/ulikunitz/xz v0.5.5/go.mod h1:2bypXElzHzzJZwzH67Y6wb67pO62Rzfn7BSiF4ABRW8= github.com/xiang90/probing v0.0.0-20160813154853-07dd2e8dfe18/go.mod h1:UETIi67q53MR2AWcXfiuqkDkRtnGDLqkBTpCHuJHxtU= github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q= diff --git a/test/integration/create_classes_test.go b/test/integration/create_classes_test.go new file mode 100644 index 000000000..9f86e20ab --- /dev/null +++ b/test/integration/create_classes_test.go @@ -0,0 +1,245 @@ +// +build integration + +/* +Copyright 2019 The Crossplane Authors. + +Licensed 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 integration + +import ( + "context" + "io/ioutil" + "os" + "testing" + + "github.com/crossplaneio/crossplane-runtime/pkg/test/integration" + crossplaneapis "github.com/crossplaneio/crossplane/apis" + "k8s.io/client-go/tools/clientcmd" + "sigs.k8s.io/controller-runtime/pkg/client" + "sigs.k8s.io/yaml" + + "github.com/crossplaneio/stack-gcp/apis" + cachev1beta1 "github.com/crossplaneio/stack-gcp/apis/cache/v1beta1" + computev1alpha3 "github.com/crossplaneio/stack-gcp/apis/compute/v1alpha3" + containerv1beta1 "github.com/crossplaneio/stack-gcp/apis/container/v1beta1" + databasev1beta1 "github.com/crossplaneio/stack-gcp/apis/database/v1beta1" + storagev1alpha3 "github.com/crossplaneio/stack-gcp/apis/storage/v1alpha3" + "github.com/crossplaneio/stack-gcp/apis/v1alpha3" + "github.com/crossplaneio/stack-gcp/pkg/controller" +) + +func TestCreateAllClasses(t *testing.T) { + cases := map[string]struct { + reason string + test func(c client.Client) error + }{ + "CreateProvider": { + reason: "A GCP Provider should be created without error.", + test: func(c client.Client) error { + dat, err := ioutil.ReadFile("../../examples/gcp-provider.yaml") + if err != nil { + return err + } + p := &v1alpha3.Provider{} + if err := yaml.Unmarshal(dat, p); err != nil { + return err + } + + defer func() { + if err := c.Delete(context.Background(), p); err != nil { + t.Error(err) + } + }() + + return c.Create(context.Background(), p) + }, + }, + "CreateBucketClass": { + reason: "A GCP BucketClass should be created without error.", + test: func(c client.Client) error { + dat, err := ioutil.ReadFile("../../examples/storage/bucket/resource-class.yaml") + if err != nil { + return err + } + b := &storagev1alpha3.BucketClass{} + if err := yaml.Unmarshal(dat, b); err != nil { + return err + } + + defer func() { + if err := c.Delete(context.Background(), b); err != nil { + t.Error(err) + } + }() + + return c.Create(context.Background(), b) + }, + }, + "CreatePostgreSQLCloudSQLClass": { + reason: "A GCP PostgreSQL CloudSQLClass should be created without error.", + test: func(c client.Client) error { + dat, err := ioutil.ReadFile("../../examples/database/postgresqlinstance/resource-class.yaml") + if err != nil { + return err + } + s := &databasev1beta1.CloudSQLInstanceClass{} + if err := yaml.Unmarshal(dat, s); err != nil { + return err + } + + defer func() { + if err := c.Delete(context.Background(), s); err != nil { + t.Error(err) + } + }() + + return c.Create(context.Background(), s) + }, + }, + "CreateMySQLCloudSQLClass": { + reason: "A GCP MySQL CloudSQLClass should be created without error.", + test: func(c client.Client) error { + dat, err := ioutil.ReadFile("../../examples/database/mysqlinstance/resource-class.yaml") + if err != nil { + return err + } + s := &databasev1beta1.CloudSQLInstanceClass{} + if err := yaml.Unmarshal(dat, s); err != nil { + return err + } + + defer func() { + if err := c.Delete(context.Background(), s); err != nil { + t.Error(err) + } + }() + + return c.Create(context.Background(), s) + }, + }, + "CreateV1Beta1GKEClusterClass": { + reason: "A v1beta1 GCP GKEClusterClass should be created without error.", + test: func(c client.Client) error { + dat, err := ioutil.ReadFile("../../examples/container/kubernetescluster/resource-class.yaml") + if err != nil { + return err + } + s := &containerv1beta1.GKEClusterClass{} + if err := yaml.Unmarshal(dat, s); err != nil { + return err + } + + defer func() { + if err := c.Delete(context.Background(), s); err != nil { + t.Error(err) + } + }() + + return c.Create(context.Background(), s) + }, + }, + "CreateV1Alpha1GKEClusterClass": { + reason: "A v1alpha3 GCP GKEClusterClass should be created without error.", + test: func(c client.Client) error { + dat, err := ioutil.ReadFile("../../examples/compute/kubernetescluster/resource-class.yaml") + if err != nil { + return err + } + s := &computev1alpha3.GKEClusterClass{} + if err := yaml.Unmarshal(dat, s); err != nil { + return err + } + + defer func() { + if err := c.Delete(context.Background(), s); err != nil { + t.Error(err) + } + }() + + return c.Create(context.Background(), s) + }, + }, + "CreateCloudMemorystoreInstanceClass": { + reason: "A GCP CloudMemorystoreInstanceClass should be created without error.", + test: func(c client.Client) error { + dat, err := ioutil.ReadFile("../../examples/cache/rediscluster/resource-class.yaml") + if err != nil { + return err + } + s := &cachev1beta1.CloudMemorystoreInstanceClass{} + if err := yaml.Unmarshal(dat, s); err != nil { + return err + } + + defer func() { + if err := c.Delete(context.Background(), s); err != nil { + t.Error(err) + } + }() + + return c.Create(context.Background(), s) + }, + }, + } + + cfg, err := clientcmd.BuildConfigFromFlags("", "../../kubeconfig.yaml") + if err != nil { + t.Fatal(err) + } + + if err := os.Setenv("GOOGLE_APPLICATION_CREDENTIALS", "../../sa.json"); err != nil { + t.Fatal(err) + } + + i, err := integration.New(cfg, + integration.WithCRDPaths("../../config/crd"), + integration.WithCleaners( + integration.NewCRDCleaner(), + integration.NewCRDDirCleaner()), + ) + + if err != nil { + t.Fatal(err) + } + + if err := apis.AddToScheme(i.GetScheme()); err != nil { + t.Fatal(err) + } + + if err := crossplaneapis.AddToScheme(i.GetScheme()); err != nil { + t.Fatal(err) + } + + if err := (&controller.Controllers{}).SetupWithManager(i); err != nil { + t.Fatal(err) + } + + i.Run() + + defer func() { + if err := i.Cleanup(); err != nil { + t.Fatal(err) + } + }() + + for name, tc := range cases { + t.Run(name, func(t *testing.T) { + err := tc.test(i.GetClient()) + if err != nil { + t.Error(err) + } + }) + } +} diff --git a/test/integration/doc.go b/test/integration/doc.go new file mode 100644 index 000000000..df0d5b4aa --- /dev/null +++ b/test/integration/doc.go @@ -0,0 +1,17 @@ +/* +Copyright 2019 The Crossplane Authors. + +Licensed 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 integration