-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
acc0d70
commit 70ce51f
Showing
2 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
apiVersion: crd.nsx.vmware.com/v1alpha1 | ||
kind: Subnet | ||
metadata: | ||
name: public-subnet | ||
spec: | ||
ipv4SubnetSize: 16 | ||
accessMode: Public | ||
DHCPConfig: | ||
enableDHCP: false | ||
--- | ||
apiVersion: vmoperator.vmware.com/v1alpha3 | ||
kind: VirtualMachine | ||
metadata: | ||
name: public-vm | ||
spec: | ||
network: | ||
interfaces: | ||
- name: eth0 | ||
network: | ||
name: public-subnet | ||
kind: Subnet | ||
apiVersion: crd.nsx.vmware.com/v1alpha1 | ||
bootstrap: | ||
cloudInit: | ||
rawCloudConfig: | ||
key: user-data | ||
name: user-data-1 | ||
className: best-effort-xsmall | ||
imageName: vmi-72c452bfd23215d72 | ||
storageClass: wcplocal-storage-profile | ||
powerState: PoweredOn | ||
--- | ||
apiVersion: v1 | ||
kind: Secret | ||
metadata: | ||
name: user-data-1 | ||
stringData: | ||
user-data: | | ||
#cloud-config | ||
ssh_pwauth: true | ||
users: | ||
- name: vmware | ||
sudo: ALL=(ALL) NOPASSWD:ALL | ||
lock_passwd: false | ||
# Password set to Admin!23 | ||
passwd: '$1$salt$SOC33fVbA/ZxeIwD5yw1u1' | ||
shell: /bin/bash | ||
write_files: | ||
- path: /etc/my-plaintext | ||
permissions: '0644' | ||
owner: root:root | ||
content: | | ||
Hello, world. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
"path/filepath" | ||
"testing" | ||
"time" | ||
|
||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
func TestCreateVM(t *testing.T) { | ||
t.Run("testCreateVMBasic", func(t *testing.T) { testCreateVMBasic(t) }) | ||
} | ||
|
||
func testCreateVMBasic(t *testing.T) { | ||
_, deadlineCancel := context.WithTimeout(context.Background(), defaultTimeout) | ||
defer deadlineCancel() | ||
|
||
ns := "test-create-vm-basic" | ||
|
||
err := testData.createVCNamespace(ns) | ||
if err != nil { | ||
t.Fatalf("Failed to create VC namespace: %v", err) | ||
} | ||
defer func() { | ||
err := testData.deleteVCNamespace(ns) | ||
if err != nil { | ||
t.Fatalf("Failed to delete VC namespace: %v", err) | ||
} | ||
}() | ||
|
||
// Create public vm | ||
vmPath, _ := filepath.Abs("./manifest/testVM/public_vm.yaml") | ||
require.NoError(t, applyYAML(vmPath, ns)) | ||
defer deleteYAML(vmPath, ns) | ||
time.Sleep(time.Hour * 10) | ||
} |