Skip to content

Commit

Permalink
e2e-test: add e2e tests for ApisixPluginConfig v2 (#1067)
Browse files Browse the repository at this point in the history
  • Loading branch information
lingsamuel authored Jun 7, 2022
1 parent d3a823f commit 96dd07f
Show file tree
Hide file tree
Showing 3 changed files with 310 additions and 240 deletions.
53 changes: 53 additions & 0 deletions samples/deploy/crd/v1/ApisixPluginConfig.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,59 @@ spec:
- apc
versions:
- name: v2beta3
served: true
storage: false
subresources:
status: {}
additionalPrinterColumns:
- jsonPath: .metadata.creationTimestamp
name: Age
type: date
priority: 0
schema:
openAPIV3Schema:
type: object
properties:
spec:
type: object
required:
- plugins
properties:
plugins:
type: array
items:
type: object
properties:
name:
type: string
minLength: 1
enable:
type: boolean
config:
type: object
x-kubernetes-preserve-unknown-fields: true # we have to enable it since plugin config
required:
- name
- enable
status:
type: object
properties:
conditions:
type: array
items:
type: object
properties:
"type":
type: string
reason:
type: string
status:
type: string
message:
type: string
observedGeneration:
type: integer
- name: v2
served: true
storage: true
subresources:
Expand Down
16 changes: 16 additions & 0 deletions test/e2e/scaffold/scaffold.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"context"
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"io/ioutil"
"net"
Expand Down Expand Up @@ -54,6 +55,7 @@ type Options struct {
APISIXRouteVersion string
APISIXTlsVersion string
APISIXConsumerVersion string
ApisixPluginConfigVersion string
APISIXClusterConfigVersion string
APISIXAdminAPIKey string
EnableWebhooks bool
Expand Down Expand Up @@ -115,6 +117,9 @@ func NewScaffold(o *Options) *Scaffold {
if o.APISIXConsumerVersion == "" {
o.APISIXConsumerVersion = config.ApisixV2beta3
}
if o.ApisixPluginConfigVersion == "" {
o.ApisixPluginConfigVersion = config.ApisixV2beta3
}
if o.APISIXClusterConfigVersion == "" {
o.APISIXClusterConfigVersion = config.ApisixV2beta3
}
Expand Down Expand Up @@ -145,6 +150,7 @@ func NewDefaultScaffold() *Scaffold {
APISIXRouteVersion: kube.ApisixRouteV2beta3,
APISIXTlsVersion: config.ApisixV2beta3,
APISIXConsumerVersion: config.ApisixV2beta3,
ApisixPluginConfigVersion: config.ApisixV2beta3,
APISIXClusterConfigVersion: config.ApisixV2beta3,
EnableWebhooks: false,
APISIXPublishAddress: "",
Expand All @@ -163,6 +169,7 @@ func NewDefaultV2Scaffold() *Scaffold {
APISIXRouteVersion: kube.ApisixRouteV2,
APISIXTlsVersion: config.ApisixV2,
APISIXConsumerVersion: config.ApisixV2,
ApisixPluginConfigVersion: config.ApisixV2,
APISIXClusterConfigVersion: config.ApisixV2,
EnableWebhooks: false,
APISIXPublishAddress: "",
Expand Down Expand Up @@ -532,3 +539,12 @@ func generateWebhookCert(ns string) error {

return nil
}

func (s *Scaffold) CreateVersionedApisixPluginConfig(yml string) error {
if !strings.Contains(yml, "kind: ApisixPluginConfig") {
return errors.New("not a ApisixPluginConfig")
}

ac := s.replaceApiVersion(yml, s.opts.ApisixPluginConfigVersion)
return s.CreateResourceFromString(ac)
}
Loading

0 comments on commit 96dd07f

Please sign in to comment.