func TestDeleteArtifactsBundle(t *testing.T) {
	var (
		d                   *I3STest
		c                   *i3s.I3SClient
		testName            string
		testArtifactsBundle i3s.ArtifactsBundle
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_deployment_plan")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		err := c.DeleteArtifactsBundle(testName)
		assert.NoError(t, err, "DeleteArtifactsBundle err-> %s", err)

		testArtifactsBundle, err = c.GetArtifactsBundleByName(testName)
		assert.NoError(t, err, "GetArtifactsBundleByName with deleted artifactsBundle-> %+v", err)
		assert.Equal(t, "", testArtifactsBundle.Name, fmt.Sprintf("Problem getting artifactsBundle name, %+v", testArtifactsBundle))
	} else {
		_, c = getTestDriverU("test_artifacts_bundle")
		err := c.DeleteArtifactsBundle("footest")
		assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, testArtifactsBundle))
	}

}
func TestGetOSVolumeByName(t *testing.T) {
	var (
		d        *I3STest
		c        *i3s.I3SClient
		testName string
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_os_volume")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		testOSVolume, err := c.GetOSVolumeByName(testName)
		assert.NoError(t, err, "GetOSVolumeByName thew an error -> %s", err)
		assert.Equal(t, testName, testOSVolume.Name)

		testOSVolume, err = c.GetOSVolumeByName("bad")
		assert.NoError(t, err, "GetOSVolumeByName with fake name -> %s", err)
		assert.Equal(t, "", testOSVolume.Name)

	} else {
		d, c = getTestDriverU("test_os_volume")
		testName = d.Tc.GetTestData(d.Env, "Name").(string)
		data, err := c.GetOSVolumeByName(testName)
		assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, data))
	}
}
func TestDeletePlanScript(t *testing.T) {
	var (
		d              *I3STest
		c              *i3s.I3SClient
		testName       string
		testPlanScript i3s.PlanScript
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_plan_script")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		err := c.DeletePlanScript(testName)
		assert.NoError(t, err, "DeletePlanScript err-> %s", err)

		testPlanScript, err = c.GetPlanScriptByName(testName)
		assert.NoError(t, err, "GetPlanScriptByName with deleted plan script-> %+v", err)
		assert.Equal(t, "", testPlanScript.Name, fmt.Sprintf("Problem getting plan script name, %+v", testPlanScript))
	} else {
		_, c = getTestDriverU("test_plan_script")
		err := c.DeletePlanScript("footest")
		assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, testPlanScript))
	}

}
func TestDeleteGoldenImage(t *testing.T) {
	var (
		d               *I3STest
		c               *i3s.I3SClient
		testName        string
		testGoldenImage i3s.GoldenImage
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_golden_image")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		err := c.DeleteGoldenImage(testName)
		assert.NoError(t, err, "DeleteGoldenImage err-> %s", err)

		testGoldenImage, err = c.GetGoldenImageByName(testName)
		assert.NoError(t, err, "GetGoldenImageByName with deleted golden image-> %+v", err)
		assert.Equal(t, "", testGoldenImage.Name, fmt.Sprintf("Problem getting golden image name, %+v", testGoldenImage))
	} else {
		_, c = getTestDriverU("test_golden_image")
		err := c.DeleteGoldenImage("footest")
		assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, testGoldenImage))
	}

}
func TestDeleteOSBuildPlan(t *testing.T) {
	var (
		d               *I3STest
		c               *i3s.I3SClient
		testName        string
		testOSBuildPlan i3s.OSBuildPlan
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_os_build_plan")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		err := c.DeleteOSBuildPlan(testName)
		assert.NoError(t, err, "DeleteOSBuildPlan err-> %s", err)

		testOSBuildPlan, err = c.GetOSBuildPlanByName(testName)
		assert.NoError(t, err, "GetOSBuildPlanByName with deleted os build plan-> %+v", err)
		assert.Equal(t, "", testOSBuildPlan.Name, fmt.Sprintf("Problem getting os build plan name, %+v", testOSBuildPlan))
	} else {
		_, c = getTestDriverU("test_os_build_plan")
		err := c.DeleteOSBuildPlan("footest")
		assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, testOSBuildPlan))
	}

}
Пример #6
0
// Get the current idle timeout from the logged in session
func TestGetIdleTimeout(t *testing.T) {
	var (
		c *i3s.I3SClient
		// d *OVTest
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		_, c = getTestDriverA("dev")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		log.Debugf(" login key -> %s", c.APIKey)

		timeout, err := c.GetIdleTimeout()
		assert.Error(t, err, "Timeout: %s", err)
		assert.NoError(t, err, "GetIdleTimeout threw error -> %s", err)
		log.Debugf(" idle timeout -> %d", timeout)
	}
}
Пример #7
0
// Set idle timeout
func TestSetIdleTimeout(t *testing.T) {
	var (
		c        *i3s.I3SClient
		testtime int64
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		testtime = 25000
		_, c = getTestDriverA("dev")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}

		err := c.SetIdleTimeout(testtime)
		assert.NoError(t, err, "SetIdleTimeout threw error -> %s", err)

		timeout, err := c.GetIdleTimeout()
		assert.NoError(t, err, "GetIdleTimeout threw error -> %s", err)
		assert.Equal(t, testtime, timeout, "Should get timeout equal, %s", timeout)
		log.Debugf(" idle timeout -> %d", timeout)
	}
}
func TestCreatePlanScript(t *testing.T) {
	var (
		d        *I3STest
		c        *i3s.I3SClient
		testName string
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_plan_script")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		// find out if the test plan script already exist
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		testPlanScript, err := c.GetPlanScriptByName(testName)
		assert.NoError(t, err, "CreatePlanScript get the PlanScript error -> %s", err)

		if testPlanScript.URI.IsNil() {
			testPlanScript = i3s.PlanScript{
				Name:        testName,
				Type:        d.Tc.GetTestData(d.Env, "Type").(string),
				PlanType:    d.Tc.GetTestData(d.Env, "PlanType").(string),
				Description: d.Tc.GetTestData(d.Env, "Description").(string),
				Content:     d.Tc.GetTestData(d.Env, "Content").(string),
			}
			err := c.CreatePlanScript(testPlanScript)
			assert.NoError(t, err, "CreatePlanScript error -> %s", err)

			log.Infof("Submitting the same plan script to confirm I3S will error")
			err = c.CreatePlanScript(testPlanScript)
			assert.Error(t, err, "CreatePlanScript should error because the PlanScript already exists, err-> %s", err)

		} else {
			log.Warnf("The planScript already exist, so skipping CreatePlanScript test for %s", testName)
		}

		// reload the test profile that we just created
		testPlanScript, err = c.GetPlanScriptByName(testName)
		assert.NoError(t, err, "GetPlanScript error -> %s", err)
	}
}
func TestCreateOSBuildPlan(t *testing.T) {
	var (
		d        *I3STest
		c        *i3s.I3SClient
		testName string
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_os_build_plan")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		// find out if the test os build plan already exist
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		testOSBuildPlan, err := c.GetOSBuildPlanByName(testName)
		assert.NoError(t, err, "CreateOSBuildPlan get the OS BuildPlan error -> %s", err)

		if testOSBuildPlan.URI.IsNil() {
			testOSBuildPlan = i3s.OSBuildPlan{
				Name:            testName,
				Type:            d.Tc.GetTestData(d.Env, "Type").(string),
				OEBuildPlanType: d.Tc.GetTestData(d.Env, "OEBuildPlanType").(string),
			}
			err := c.CreateOSBuildPlan(testOSBuildPlan)
			assert.NoError(t, err, "CreateOSBuildPlan error -> %s", err)

			err = c.CreateOSBuildPlan(testOSBuildPlan)
			assert.Error(t, err, "CreateOSBuildPlan should error because the OSBuildPlan already exists, err-> %s", err)

		} else {
			log.Warnf("The osBuildPlan already exist, so skipping CreateOSBuildPlan test for %s", testName)
		}

		// reload the os build plan that we just created
		testOSBuildPlan, err = c.GetOSBuildPlanByName(testName)
		assert.NoError(t, err, "GetOSBuildPlan error -> %s", err)
	}
}
func TestCreateGoldenImage(t *testing.T) {
	var (
		d        *I3STest
		c        *i3s.I3SClient
		testName string
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_golden_image")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		// find out if the test golden image already exist
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		testGoldenImage, err := c.GetGoldenImageByName(testName)
		assert.NoError(t, err, "CreateGoldenImage get the GoldenImage error -> %s", err)

		if testGoldenImage.URI.IsNil() {
			testGoldenImage = i3s.GoldenImage{
				Name: testName,
				Type: d.Tc.GetTestData(d.Env, "Type").(string),
			}
			err := c.CreateGoldenImage(testGoldenImage)
			assert.NoError(t, err, "CreateGoldenImage error -> %s", err)

			err = c.CreateGoldenImage(testGoldenImage)
			assert.Error(t, err, "CreateGoldenImage should error because the GoldenImage already exists, err-> %s", err)

		} else {
			log.Warnf("The goldenImage already exist, so skipping CreateGoldenImage test for %s", testName)
		}

		// reload the test profile that we just created
		testGoldenImage, err = c.GetGoldenImageByName(testName)
		assert.NoError(t, err, "GetGoldenImage error -> %s", err)
	}
}
func TestCreateArtifactsBundle(t *testing.T) {
	var (
		d        *I3STest
		c        *i3s.I3SClient
		testName string
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		d, c = getTestDriverA("test_artifacts_bundle")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		// find out if the test artifactsBundle already exist
		testName = d.Tc.GetTestData(d.Env, "Name").(string)

		testArtifactsBundle, err := c.GetArtifactsBundleByName(testName)
		assert.NoError(t, err, "CreateArtifactsBundle get the ArtifactsBundle error -> %s", err)

		if testArtifactsBundle.URI.IsNil() {
			testInputArtifactsBundle := i3s.InputArtifactsBundle{
				Name: testName,
			}
			err := c.CreateArtifactsBundle(testInputArtifactsBundle)
			assert.NoError(t, err, "CreateArtifactsBundle error -> %s", err)

			err = c.CreateArtifactsBundle(testInputArtifactsBundle)
			assert.Error(t, err, "CreateArtifactsBundle should error because the ArtifactsBundle already exists, err-> %s", err)

		} else {
			log.Warnf("The ArtifactsBundle already exist, so skipping CreateArtifactsBundle test for %s", testName)
		}

		// reload the test artifact bundle that we just created
		testArtifactsBundle, err = c.GetArtifactsBundleByName(testName)
		assert.NoError(t, err, "GetArtifactsBundle error -> %s", err)
	}
}
func TestGetOSVolumes(t *testing.T) {
	var (
		c *i3s.I3SClient
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		_, c = getTestDriverA("test_os_volume")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}
		osVolumes, err := c.GetOSVolumes("", "")
		assert.NoError(t, err, "GetOSVolumes threw error -> %s, %+v\n", err, osVolumes)

		osVolumes, err = c.GetOSVolumes("", "name:asc")
		assert.NoError(t, err, "GetOSVolumes name:asc error -> %s, %+v\n", err, osVolumes)

	} else {
		_, c = getTestDriverU("test_os_volume")
		data, err := c.GetOSVolumes("", "")
		assert.Error(t, err, fmt.Sprintf("ALL ok, no error, caught as expected: %s,%+v\n", err, data))
	}
}
func TestDeleteDeploymentPlanNotFound(t *testing.T) {
	var (
		c                  *i3s.I3SClient
		testName           = "fake"
		testDeploymentPlan i3s.DeploymentPlan
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		_, c = getTestDriverA("test_deployment_plan")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}

		err := c.DeleteDeploymentPlan(testName)
		assert.NoError(t, err, "DeleteDeploymentPlan err-> %s", err)

		testDeploymentPlan, err = c.GetDeploymentPlanByName(testName)
		assert.NoError(t, err, "GetDeploymentPlanByName with deleted deployment plan -> %+v", err)
		assert.Equal(t, "", testDeploymentPlan.Name, fmt.Sprintf("Problem getting deployment plan name, %+v", testDeploymentPlan))
	} else {
		_, c = getTestDriverU("test_deployment_plan")
		err := c.DeleteDeploymentPlan(testName)
		assert.Error(t, err, fmt.Sprintf("All ok, no error, caught as expected: %s,%+v\n", err, testDeploymentPlan))
	}
}
func TestDeleteArtifactsBundleNotFound(t *testing.T) {
	var (
		c                   *i3s.I3SClient
		testName            = "fake"
		testArtifactsBundle i3s.ArtifactsBundle
	)
	if os.Getenv("I3S_TEST_ACCEPTANCE") == "true" {
		_, c = getTestDriverA("test_artifacts_bundle")
		if c == nil {
			t.Fatalf("Failed to execute getTestDriver() ")
		}

		err := c.DeleteArtifactsBundle(testName)
		assert.NoError(t, err, "DeleteArtifactsBundle err-> %s", err)

		testArtifactsBundle, err = c.GetArtifactsBundleByName(testName)
		assert.NoError(t, err, "GetArtifactsBundleByName with deleted artifacts bundle -> %+v", err)
		assert.Equal(t, "", testArtifactsBundle.Name, fmt.Sprintf("Problem getting artifacts bundle name, %+v", testArtifactsBundle))
	} else {
		_, c = getTestDriverU("test_artifacts_bundle")
		err := c.DeleteArtifactsBundle(testName)
		assert.Error(t, err, fmt.Sprintf("All ok, no error, caught as expected: %s,%+v\n", err, testArtifactsBundle))
	}
}