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

test(api): refactor e2e label and annotation test case #515

Open
wants to merge 2 commits into
base: test/api/resource-deletion-step-in-e2e-tests
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
1 change: 0 additions & 1 deletion tests/e2e/Taskfile.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ tasks:
- |
ginkgo \
--skip-file vm_test.go \
--skip-file vm_label_annotation_test.go \
--skip-file ipam_test.go \
--skip-file disks_test.go \
-v
Expand Down
19 changes: 10 additions & 9 deletions tests/e2e/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,15 +128,16 @@ type Config struct {
}

type TestData struct {
ComplexTest string `yaml:"complexTest"`
Connectivity string `yaml:"connectivity"`
DiskResizing string `yaml:"diskResizing"`
SizingPolicy string `yaml:"sizingPolicy"`
VmConfiguration string `yaml:"vmConfiguration"`
VmMigration string `yaml:"vmMigration"`
VmDiskAttachment string `yaml:"vmDiskAttachment"`
Sshkey string `yaml:"sshKey"`
SshUser string `yaml:"sshUser"`
ComplexTest string `yaml:"complexTest"`
Connectivity string `yaml:"connectivity"`
DiskResizing string `yaml:"diskResizing"`
SizingPolicy string `yaml:"sizingPolicy"`
VmConfiguration string `yaml:"vmConfiguration"`
VmLabelAnnotation string `yaml:"vmLabelAnnotation"`
VmMigration string `yaml:"vmMigration"`
VmDiskAttachment string `yaml:"vmDiskAttachment"`
Sshkey string `yaml:"sshKey"`
SshUser string `yaml:"sshUser"`
}

type StorageClass struct {
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/default_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ testData:
diskResizing: "/tmp/testdata/disk-resizing"
sizingPolicy: "/tmp/testdata/sizing-policy"
vmConfiguration: "/tmp/testdata/vm-configuration"
vmLabelAnnotation: "/tmp/testdata/vm-label-annotation"
vmMigration: "/tmp/testdata/vm-migration"
vmDiskAttachment: "/tmp/testdata/vm-disk-attachment"
sshKey: "/tmp/testdata/sshkeys/id_ed"
Expand Down
12 changes: 12 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/base/cfg/cloudinit.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#cloud-config
users:
- name: cloud
# passwd: cloud
passwd: $6$rounds=4096$vln/.aPHBOI7BMYR$bBMkqQvuGs5Gyd/1H5DP4m9HjQSy.kgrxpaGEHwkX7KEFV8BS.HZWPitAtZ2Vd8ZqIZRqmlykRCagTgPejt1i.
shell: /bin/bash
sudo: ALL=(ALL) NOPASSWD:ALL
chpasswd: { expire: False }
lock_passwd: false
ssh_authorized_keys:
# testcases
- ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFxcXHmwaGnJ8scJaEN5RzklBPZpVSic4GdaAsKjQoeA [email protected]
14 changes: 14 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./vm.yaml
- ./vd-root.yaml
configurations:
- transformer.yaml
generatorOptions:
disableNameSuffixHash: true
secretGenerator:
- files:
- userData=cfg/cloudinit.yaml
name: cloud-init
type: provisioning.virtualization.deckhouse.io/cloud-init
54 changes: 54 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/base/transformer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# https://github.com/kubernetes-sigs/kustomize/blob/master/examples/transformerconfigs/README.md#transformer-configurations

namespace:
- kind: ClusterVirtualImage
path: spec/dataSource/objectRef/namespace
nameReference:
- kind: VirtualImage
version: v1alpha2 # optional
fieldSpecs:
- path: spec/dataSource/objectRef/name
kind: ClusterVirtualImage
- path: spec/dataSource/objectRef/name
kind: VirtualImage
- path: spec/dataSource/objectRef/name
kind: VirtualDisk
- path: spec/blockDeviceRefs/name
kind: VirtualMachine
- kind: ClusterVirtualImage
version: v1alpha2 # optional
fieldSpecs:
- path: spec/dataSource/objectRef/name
kind: ClusterVirtualImage
- path: spec/dataSource/objectRef/name
kind: VirtualImage
- path: spec/dataSource/objectRef/name
kind: VirtualDisk
- path: spec/blockDeviceRefs/name
kind: VirtualMachine
- kind: VirtualDisk
version: v1alpha2 # optional
fieldSpecs:
- path: spec/blockDeviceRefs/name
kind: VirtualMachine
- path: spec/blockDeviceRef/name
kind: VirtualMachineBlockDeviceAttachment
- kind: Secret
fieldSpecs:
- path: spec/provisioning/userDataRef/name
kind: VirtualMachine
- kind: VirtualMachineIPAddress
version: v1alpha2
fieldSpecs:
- path: spec/virtualMachineIPAddressName
kind: VirtualMachine
- kind: VirtualMachine
version: v1alpha2
fieldSpecs:
- path: spec/virtualMachineName
kind: VirtualMachineBlockDeviceAttachment
- kind: VirtualMachineClass
version: v1alpha2
fieldSpecs:
- path: spec/virtualMachineClassName
kind: VirtualMachine
12 changes: 12 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/base/vd-root.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualDisk
metadata:
name: vd-root
spec:
persistentVolumeClaim:
size: 512Mi
dataSource:
type: ObjectRef
objectRef:
kind: VirtualImage
name: vi-alpine-http
21 changes: 21 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/base/vm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualMachine
metadata:
name: vm
spec:
virtualMachineClassName: generic
cpu:
cores: 1
coreFraction: 5%
memory:
size: 256Mi
disruptions:
restartApprovalMode: Manual
provisioning:
type: UserDataRef
userDataRef:
kind: Secret
name: cloud-init
blockDeviceRefs:
- kind: VirtualDisk
name: vd-root
15 changes: 15 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: testcases
namePrefix: pr-number-or-commit-hash-
resources:
- ns.yaml
- vi
- overlays/vm-labal-annotation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the directory name: vm-label-annotation

configurations:
- transformer.yaml
labels:
- includeSelectors: true
pairs:
id: pr-number-or-commit-hash
testcase: vm-label-annotation
4 changes: 4 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/ns.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: default
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
nameSuffix: -label-annotation
resources:
- ../../base
patches:
- patch: |-
- op: replace
path: /spec/runPolicy
value: AlwaysOn
target:
kind: VirtualMachine
name: vm
- patch: |-
- op: replace
path: /spec/disruptions/restartApprovalMode
value: Automatic
target:
kind: VirtualMachine
name: vm
52 changes: 52 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/transformer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
namespace:
- kind: ClusterVirtualImage
path: spec/dataSource/objectRef/namespace
nameReference:
- kind: VirtualImage
version: v1alpha2 # optional
fieldSpecs:
- path: spec/dataSource/objectRef/name
kind: ClusterVirtualImage
- path: spec/dataSource/objectRef/name
kind: VirtualImage
- path: spec/dataSource/objectRef/name
kind: VirtualDisk
- path: spec/blockDeviceRefs/name
kind: VirtualMachine
- kind: ClusterVirtualImage
version: v1alpha2 # optional
fieldSpecs:
- path: spec/dataSource/objectRef/name
kind: ClusterVirtualImage
- path: spec/dataSource/objectRef/name
kind: VirtualImage
- path: spec/dataSource/objectRef/name
kind: VirtualDisk
- path: spec/blockDeviceRefs/name
kind: VirtualMachine
- kind: VirtualDisk
version: v1alpha2 # optional
fieldSpecs:
- path: spec/blockDeviceRefs/name
kind: VirtualMachine
- path: spec/blockDeviceRef/name
kind: VirtualMachineBlockDeviceAttachment
- kind: Secret
fieldSpecs:
- path: spec/provisioning/userDataRef/name
kind: VirtualMachine
- kind: VirtualMachineIPAddress
version: v1alpha2
fieldSpecs:
- path: spec/virtualMachineIPAddressName
kind: VirtualMachine
- kind: VirtualMachine
version: v1alpha2
fieldSpecs:
- path: spec/virtualMachineName
kind: VirtualMachineBlockDeviceAttachment
- kind: VirtualMachineClass
version: v1alpha2
fieldSpecs:
- path: spec/virtualMachineClassName
kind: VirtualMachine
4 changes: 4 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/vi/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- vi-alpine-http.yaml
11 changes: 11 additions & 0 deletions tests/e2e/testdata/vm-label-annotation/vi/vi-alpine-http.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
apiVersion: virtualization.deckhouse.io/v1alpha2
kind: VirtualImage
metadata:
name: vi-alpine-http
spec:
storage: ContainerRegistry
dataSource:
type: HTTP
http:
url: https://0e773854-6b4e-4e76-a65b-d9d81675451a.selstorage.ru/alpine/alpine-v3-20.qcow2
18 changes: 0 additions & 18 deletions tests/e2e/testdata/vm/vm_label_annotation.yaml

This file was deleted.

1 change: 1 addition & 0 deletions tests/e2e/tests_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ func init() {
fmt.Sprintf("%s/%s", conf.TestData.DiskResizing, "kustomization.yaml"),
fmt.Sprintf("%s/%s", conf.TestData.SizingPolicy, "kustomization.yaml"),
fmt.Sprintf("%s/%s", conf.TestData.VmConfiguration, "kustomization.yaml"),
fmt.Sprintf("%s/%s", conf.TestData.VmLabelAnnotation, "kustomization.yaml"),
fmt.Sprintf("%s/%s", conf.TestData.VmMigration, "kustomization.yaml"),
fmt.Sprintf("%s/%s", conf.TestData.VmDiskAttachment, "kustomization.yaml"),
}
Expand Down
Loading
Loading