scaffold

package
v0.0.0-...-a51f0d9 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2024 License: Apache-2.0 Imports: 45 Imported by: 0

Documentation

Overview

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.

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.

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.

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.

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.

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.

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.

Index

Constants

View Source
const (
	CoreDNSDeployment = "coredns"
)
View Source
const (
	EtcdServiceName = "etcd-service-e2e-test"
)
View Source
const (
	IngressControllerServiceName = "apisix-ingress-controller"
)

Variables

This section is empty.

Functions

func ApisixResourceVersion

func ApisixResourceVersion() *apisixResourceVersionInfo

func GetKubeconfig

func GetKubeconfig() string

GetKubeconfig returns the kubeconfig file path. Order: env KUBECONFIG; ~/.kube/config; "" (in case in-cluster configuration will be used).

Types

type APISIXConfig

type APISIXConfig struct {
	// Used for template rendering.
	EtcdServiceFQDN string
}

type ApisixRouteRule

type ApisixRouteRule struct {
	Host string              `json:"host"`
	HTTP ApisixRouteRuleHTTP `json:"http"`
}

ApisixRouteRule defines the route policies of ApisixRoute.

type ApisixRouteRuleHTTP

type ApisixRouteRuleHTTP struct {
	Paths []ApisixRouteRuleHTTPPath `json:"paths"`
}

ApisixRouteRuleHTTP defines the HTTP part of route policies.

type ApisixRouteRuleHTTPBackend

type ApisixRouteRuleHTTPBackend struct {
	ServiceName string `json:"serviceName"`
	ServicePort int32  `json:"servicePort"`
}

ApisixRouteRuleHTTPBackend defines a HTTP backend.

type ApisixRouteRuleHTTPPath

type ApisixRouteRuleHTTPPath struct {
	Path    string                     `json:"path"`
	Backend ApisixRouteRuleHTTPBackend `json:"backend"`
}

ApisixRouteRuleHTTP defines a route in the HTTP part of ApisixRoute.

type Options

type Options struct {
	Name                         string
	Kubeconfig                   string
	APISIXAdminAPIVersion        string
	APISIXConfigPath             string
	IngressAPISIXReplicas        int
	HTTPBinServicePort           int
	APISIXAdminAPIKey            string
	EnableWebhooks               bool
	APISIXPublishAddress         string
	ApisixResourceSyncInterval   string
	ApisixResourceSyncComparison string
	ApisixResourceVersion        string
	DisableStatus                bool
	IngressClass                 string
	EnableEtcdServer             bool

	NamespaceSelectorLabel   map[string][]string
	DisableNamespaceSelector bool
	DisableNamespaceLabel    bool
}

type Scaffold

type Scaffold struct {
	// contains filtered or unexported fields
}

func NewDefaultScaffold

func NewDefaultScaffold() *Scaffold

NewDefaultScaffold creates a scaffold with some default options. apisix-version default v2

func NewDefaultV2Scaffold

func NewDefaultV2Scaffold() *Scaffold

NewDefaultV2Scaffold creates a scaffold with some default options.

func NewScaffold

func NewScaffold(o *Options) *Scaffold

NewScaffold creates an e2e test scaffold.

func NewV2Scaffold

func NewV2Scaffold(o *Options) *Scaffold

NewV2Scaffold creates a scaffold with some default options.

func (*Scaffold) APISIXGatewayServiceEndpoint

func (s *Scaffold) APISIXGatewayServiceEndpoint() string

APISIXGatewayServiceEndpoint returns the apisix http gateway endpoint.

func (*Scaffold) ApisixAdminServiceAndPort

func (s *Scaffold) ApisixAdminServiceAndPort() (string, int32)

ApisixAdminServiceAndPort returns the apisix service name and it's admin port.

func (*Scaffold) ApisixConsumerBasicAuthCreated

func (s *Scaffold) ApisixConsumerBasicAuthCreated(name, username, password string) error

func (*Scaffold) ApisixConsumerBasicAuthSecretCreated

func (s *Scaffold) ApisixConsumerBasicAuthSecretCreated(name, secret string) error

func (*Scaffold) ApisixConsumerKeyAuthCreated

func (s *Scaffold) ApisixConsumerKeyAuthCreated(name, key string) error

func (*Scaffold) ApisixConsumerKeyAuthSecretCreated

func (s *Scaffold) ApisixConsumerKeyAuthSecretCreated(name, secret string) error

func (*Scaffold) ApisixResourceVersion

func (s *Scaffold) ApisixResourceVersion() string

func (*Scaffold) ClusterClient

func (s *Scaffold) ClusterClient() (apisix.Cluster, error)

func (*Scaffold) CreateApisixConsumerByApisixAdmin

func (s *Scaffold) CreateApisixConsumerByApisixAdmin(body []byte) error

CreateApisixRouteByApisixAdmin create or update a consumer

func (*Scaffold) CreateApisixPluginMetadataByApisixAdmin

func (s *Scaffold) CreateApisixPluginMetadataByApisixAdmin(pluginName string, body []byte) error

func (*Scaffold) CreateApisixRoute

func (s *Scaffold) CreateApisixRoute(name string, rules []ApisixRouteRule)

CreateApisixRoute creates an ApisixRoute object.

func (*Scaffold) CreateApisixRouteByApisixAdmin

func (s *Scaffold) CreateApisixRouteByApisixAdmin(routeID string, body []byte) error

CreateApisixRouteByApisixAdmin create or update a route

func (*Scaffold) CreateResourceFromString

func (s *Scaffold) CreateResourceFromString(yaml string) error

CreateResourceFromString creates resource from a loaded yaml string.

func (*Scaffold) CreateResourceFromStringWithNamespace

func (s *Scaffold) CreateResourceFromStringWithNamespace(yaml, namespace string) error

CreateResourceFromStringWithNamespace creates resource from a loaded yaml string and sets its namespace to the specified one.

func (*Scaffold) CreateVersionedApisixResource

func (s *Scaffold) CreateVersionedApisixResource(yml string) error

func (*Scaffold) CreateVersionedApisixResourceWithNamespace

func (s *Scaffold) CreateVersionedApisixResourceWithNamespace(yml, namespace string) error

func (*Scaffold) DNSResolver

func (s *Scaffold) DNSResolver() *net.Resolver

func (*Scaffold) DefaultHTTPBackend

func (s *Scaffold) DefaultHTTPBackend() (string, []int32)

DefaultHTTPBackend returns the service name and service ports of the default http backend.

func (*Scaffold) DeleteApisixClusterConfig

func (s *Scaffold) DeleteApisixClusterConfig(name string, enable bool, enablePreferName bool) error

DeleteApisixClusterConfig removes an ApisixClusterConfig CRD

func (*Scaffold) DeleteApisixConsumerByApisixAdmin

func (s *Scaffold) DeleteApisixConsumerByApisixAdmin(consumerName string) error

DeleteApisixConsumerByApisixAdmin deletes a consumer by its consumer name in APISIX cluster.

func (*Scaffold) DeleteApisixRouteByApisixAdmin

func (s *Scaffold) DeleteApisixRouteByApisixAdmin(routeID string) error

DeleteApisixRouteByApisixAdmin deletes a route by its route name in APISIX cluster.

func (*Scaffold) DeleteApisixTls

func (s *Scaffold) DeleteApisixTls(name string, host, secretName string) error

DeleteApisixTls remove ApisixTls CRD

func (*Scaffold) DeleteHTTPBINService

func (s *Scaffold) DeleteHTTPBINService() error

DeleteHTTPBINService deletes the HTTPBIN service object.

func (*Scaffold) DeleteResource

func (s *Scaffold) DeleteResource(resourceType, name string) error

func (*Scaffold) DeleteResourceFromString

func (s *Scaffold) DeleteResourceFromString(yaml string) error

func (*Scaffold) DeleteResourceFromStringWithNamespace

func (s *Scaffold) DeleteResourceFromStringWithNamespace(yaml, namespace string) error

func (*Scaffold) DeployAdminaAPIMode

func (s *Scaffold) DeployAdminaAPIMode()

func (*Scaffold) DeployCompositeMode

func (s *Scaffold) DeployCompositeMode()

func (*Scaffold) DeployRetryTimeout

func (s *Scaffold) DeployRetryTimeout()

func (*Scaffold) DeployTestService

func (s *Scaffold) DeployTestService()

func (*Scaffold) DialTLSOverTcp

func (s *Scaffold) DialTLSOverTcp(serverName string) (*tls.Conn, error)

func (*Scaffold) EnsureNumApisixConsumersCreated

func (s *Scaffold) EnsureNumApisixConsumersCreated(desired int) error

EnsureNumApisixConsumersCreated waits until desired number of Consumers are created in APISIX cluster.

func (*Scaffold) EnsureNumApisixPluginConfigCreated

func (s *Scaffold) EnsureNumApisixPluginConfigCreated(desired int) error

EnsureNumApisixPluginConfigCreated waits until desired number of PluginConfig are created in APISIX cluster.

func (*Scaffold) EnsureNumApisixRoutesCreated

func (s *Scaffold) EnsureNumApisixRoutesCreated(desired int) error

EnsureNumApisixRoutesCreated waits until desired number of Routes are created in APISIX cluster.

func (*Scaffold) EnsureNumApisixStreamRoutesCreated

func (s *Scaffold) EnsureNumApisixStreamRoutesCreated(desired int) error

EnsureNumApisixStreamRoutesCreated waits until desired number of Stream Routes are created in APISIX cluster.

func (*Scaffold) EnsureNumApisixTlsCreated

func (s *Scaffold) EnsureNumApisixTlsCreated(desired int) error

EnsureNumApisixTlsCreated waits until desired number of tls ssl created in APISIX cluster.

func (*Scaffold) EnsureNumApisixUpstreamsCreated

func (s *Scaffold) EnsureNumApisixUpstreamsCreated(desired int) error

EnsureNumApisixUpstreamsCreated waits until desired number of Upstreams are created in APISIX cluster.

func (*Scaffold) EnsureNumEndpointsReady

func (s *Scaffold) EnsureNumEndpointsReady(t testing.TestingT, endpointsName string, desired int)

func (*Scaffold) EnsureNumListUpstreamNodesNth

func (s *Scaffold) EnsureNumListUpstreamNodesNth(n, desired int) error

EnsureNumListUpstreamNodesNth waits until desired number of upstreams[n-1].Nodes created in APISIX cluster. The upstreams[n-1].Nodes number is equal to desired.

func (*Scaffold) Exec

func (s *Scaffold) Exec(podName, containerName string, args ...string) (string, error)

func (*Scaffold) FormatRegistry

func (s *Scaffold) FormatRegistry(workloadTemplate string) string

FormatRegistry replace default registry to custom registry if exist

func (*Scaffold) GenerateCert

func (s *Scaffold) GenerateCert(t ginkgo.GinkgoTInterface, dnsNames []string) (certPemBytes, privPemBytes bytes.Buffer)

func (*Scaffold) GenerateMACert

func (s *Scaffold) GenerateMACert(t ginkgo.GinkgoTInterface, dnsNames []string) (caCertBytes, serverCertBytes, serverKeyBytes, clientCertBytes, clientKeyBytes bytes.Buffer)

GenerateMACert used for generate MutualAuthCerts

func (*Scaffold) GetAPISIXHTTPSEndpoint

func (s *Scaffold) GetAPISIXHTTPSEndpoint() string

GetAPISIXHTTPSEndpoint get apisix https endpoint from tunnel map

func (*Scaffold) GetDeploymentLogs

func (s *Scaffold) GetDeploymentLogs(name string) string

func (*Scaffold) GetIngressPodDetails

func (s *Scaffold) GetIngressPodDetails() ([]corev1.Pod, error)

GetIngressPodDetails returns a batch of pod description about apisix-ingress-controller.

func (*Scaffold) GetKubernetesClient

func (s *Scaffold) GetKubernetesClient() *kubernetes.Clientset

GetKubernetesClient get kubernetes client use by scaffold

func (*Scaffold) GetOutputFromString

func (s *Scaffold) GetOutputFromString(shell ...string) (string, error)

func (*Scaffold) GetServerInfo

func (s *Scaffold) GetServerInfo() (map[string]interface{}, error)

GetServerInfo collect server info from "/v1/server_info" (Control API) exposed by server-info plugin

func (*Scaffold) GetServiceByName

func (s *Scaffold) GetServiceByName(name string) (*corev1.Service, error)

func (*Scaffold) IsEtcdServer

func (s *Scaffold) IsEtcdServer() bool

Skip case if is not supported etcdserver

func (*Scaffold) KillPod

func (s *Scaffold) KillPod(podName string) error

KillPod kill the pod which name is podName.

func (*Scaffold) ListApisixConsumers

func (s *Scaffold) ListApisixConsumers() ([]*v1.Consumer, error)

ListApisixConsumers list all consumers from APISIX.

func (*Scaffold) ListApisixGlobalRules

func (s *Scaffold) ListApisixGlobalRules() ([]*v1.GlobalRule, error)

ListApisixGlobalRules list all global_rules from APISIX

func (*Scaffold) ListApisixPluginConfig

func (s *Scaffold) ListApisixPluginConfig() ([]*v1.PluginConfig, error)

ListApisixRoutes list all pluginConfigs from APISIX.

func (*Scaffold) ListApisixRoutes

func (s *Scaffold) ListApisixRoutes() ([]*v1.Route, error)

ListApisixRoutes list all routes from APISIX.

func (*Scaffold) ListApisixSsl

func (s *Scaffold) ListApisixSsl() ([]*v1.Ssl, error)

ListApisixSsl list all ssl from APISIX

func (*Scaffold) ListApisixStreamRoutes

func (s *Scaffold) ListApisixStreamRoutes() ([]*v1.StreamRoute, error)

ListApisixStreamRoutes list all stream_routes from APISIX.

func (*Scaffold) ListApisixUpstreams

func (s *Scaffold) ListApisixUpstreams() ([]*v1.Upstream, error)

ListApisixUpstreams list all upstreams from APISIX

func (*Scaffold) ListPluginMetadatas

func (s *Scaffold) ListPluginMetadatas() ([]*v1.PluginMetadata, error)

func (*Scaffold) ListPodsByLabels

func (s *Scaffold) ListPodsByLabels(labels string) ([]corev1.Pod, error)

ListPodsByLabels lists all pods which matching the label selector.

func (*Scaffold) Namespace

func (s *Scaffold) Namespace() string

Namespace returns the current working namespace.

func (*Scaffold) NamespaceSelectorLabel

func (s *Scaffold) NamespaceSelectorLabel() map[string][]string

func (*Scaffold) NamespaceSelectorLabelStrings

func (s *Scaffold) NamespaceSelectorLabelStrings() []string

func (*Scaffold) NewAPISIX

func (s *Scaffold) NewAPISIX() (apisix.APISIX, error)

func (*Scaffold) NewAPISIXClient

func (s *Scaffold) NewAPISIXClient() *httpexpect.Expect

NewAPISIXClient creates the default HTTP client.

func (*Scaffold) NewAPISIXClientWithTCPProxy

func (s *Scaffold) NewAPISIXClientWithTCPProxy() *httpexpect.Expect

NewAPISIXClientWithTCPProxy creates the HTTP client but with the TCP proxy of APISIX.

func (*Scaffold) NewAPISIXClientWithTLSOverTCP

func (s *Scaffold) NewAPISIXClientWithTLSOverTCP(host string) *httpexpect.Expect

NewAPISIXClientWithTLSOverTCP creates a TSL over TCP client

func (*Scaffold) NewAPISIXHttpsClient

func (s *Scaffold) NewAPISIXHttpsClient(host string) *httpexpect.Expect

NewAPISIXHttpsClient creates the default HTTPS client.

func (*Scaffold) NewAPISIXHttpsClientWithCertificates

func (s *Scaffold) NewAPISIXHttpsClientWithCertificates(host string, insecure bool, ca *x509.CertPool, certs []tls.Certificate) *httpexpect.Expect

NewAPISIXHttpsClientWithCertificates creates the default HTTPS client with giving trusted CA and client certs.

func (*Scaffold) NewApisixClusterConfig

func (s *Scaffold) NewApisixClusterConfig(name string, enable bool, enablePreferName bool) error

NewApisixClusterConfig creates an ApisixClusterConfig CRD

func (*Scaffold) NewApisixTls

func (s *Scaffold) NewApisixTls(name, host, secretName string, ingressClassName ...string) error

NewApisixTls new a ApisixTls CRD

func (*Scaffold) NewApisixTlsWithClientCA

func (s *Scaffold) NewApisixTlsWithClientCA(name, host, secretName, clientCASecret, skipMtlsUriRegex string) error

NewApisixTlsWithClientCA new a ApisixTls CRD

func (*Scaffold) NewApisixUpstreamsWithMTLS

func (s *Scaffold) NewApisixUpstreamsWithMTLS(name, scheme, secretName string) error

NewApisixUpstreamsWithMTLS new a ApisixUpstreams CRD

func (*Scaffold) NewClientCASecret

func (s *Scaffold) NewClientCASecret(name, cert, key string) error

NewClientCASecret new a k8s secret

func (*Scaffold) NewCoreDNSService

func (s *Scaffold) NewCoreDNSService() *corev1.Service

NewCoreDNSService creates a new UDP backend for testing.

func (*Scaffold) NewDeploymentForRetryTimeoutTest

func (s *Scaffold) NewDeploymentForRetryTimeoutTest() error

func (*Scaffold) NewHTTPBINWithNamespace

func (s *Scaffold) NewHTTPBINWithNamespace(namespace string) (*corev1.Service, error)

func (*Scaffold) NewKubeTlsSecret

func (s *Scaffold) NewKubeTlsSecret(name, cert, key string) error

NewKubeTlsSecret new a kube style tls secret

func (*Scaffold) NewMQTTClient

func (s *Scaffold) NewMQTTClient() mqtt.Client

func (*Scaffold) NewSecret

func (s *Scaffold) NewSecret(name, cert, key string) error

NewSecret new a k8s secret

func (*Scaffold) NewServiceForRetryTimeoutTest

func (s *Scaffold) NewServiceForRetryTimeoutTest() error

func (*Scaffold) RemoveResourceByString

func (s *Scaffold) RemoveResourceByString(yaml string) error

RemoveResourceByString remove resource from a loaded yaml string.

func (*Scaffold) RestartAPISIXDeploy

func (s *Scaffold) RestartAPISIXDeploy()

RestartAPISIXDeploy delete apisix pod and wait new pod be ready

func (*Scaffold) RestartIngressControllerDeploy

func (s *Scaffold) RestartIngressControllerDeploy()

func (*Scaffold) RunDigDNSClientFromK8s

func (s *Scaffold) RunDigDNSClientFromK8s(args ...string) (string, error)

func (*Scaffold) RunKubectlAndGetOutput

func (s *Scaffold) RunKubectlAndGetOutput(args ...string) (string, error)

func (*Scaffold) ScaleHTTPBIN

func (s *Scaffold) ScaleHTTPBIN(desired int) error

ScaleHTTPBIN scales the number of HTTPBIN pods to desired.

func (*Scaffold) ScaleIngressController

func (s *Scaffold) ScaleIngressController(desired int) error

ScaleIngressController scales the number of Ingress Controller pods to desired.

func (*Scaffold) UpdateNamespace

func (s *Scaffold) UpdateNamespace(ns string)

func (*Scaffold) WaitAllHTTPBINPodsAvailable

func (s *Scaffold) WaitAllHTTPBINPodsAvailable() error

WaitAllHTTPBINPodsAvailable waits until all httpbin pods ready.

func (*Scaffold) WaitAllIngressControllerPodsAvailable

func (s *Scaffold) WaitAllIngressControllerPodsAvailable() error

func (*Scaffold) WaitGetLeaderLease

func (s *Scaffold) WaitGetLeaderLease() (*coordinationv1.Lease, error)

WaitGetLeaderLease waits the lease to be created and returns it.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL