func TestSimpleJobSubmission(t *testing.T) {
	if s, err := MakeSession(); err != nil {
		t.Fatalf("Error during MakeSession(): %s\n", err)
	} else {
		defer s.Exit()
		jt, errAlloc := s.AllocateJobTemplate()
		if errAlloc != nil {
			t.Fatalf("Failed allocating a new job template: %s", errAlloc)
		}
		defer s.DeleteJobTemplate(&jt)
		jt.SetRemoteCommand("/bin/sleep")
		jt.SetArg("10")
		jt.SetJobName("TestSimpleJobSubmissionGoDRMAATestJob")
		id, errRun := s.RunJob(&jt)
		if errRun != nil {
			t.Fatalf("Error submitting job: %s", errRun)
		}
		errHold := s.HoldJob(id)
		if errHold != nil {
			t.Errorf("Error holding job: %s", errHold)
		}
		errRls := s.ReleaseJob(id)
		if errRls != nil {
			t.Errorf("Error releasing job: %s", errRls)
		}
		ps, errPs := s.JobPs(id)
		if errPs != nil {
			t.Errorf("Error during job status requests: %s", errPs)
		}
		if ps == PsRunning {
			t.Log("Job is running")
		} else {
			t.Logf("Job is in state %s", ps)
		}
		errTerm := s.TerminateJob(id)
		if errTerm != nil {
			t.Fatalf("Error terminating job %s: %s", id, errTerm)
		}
	}
}
TestSimpleJobSubmission requires a connected cluster / DRM.
Note that this test submits one job to the system running 10 seconds
doing nothing.
package drmaa
import (
	"testing"
	"time"
)
func testVectorSetter(t *testing.T, f func([]string) error, arg []string, g func() ([]string, error)) {
	if err := f(arg); err != nil {
		t.Error(err)
	} else {
		garg, gerr := g()
		if gerr != nil {
			t.Error(gerr)
		} else {
			if len(arg) != len(garg) {
				t.Error("Length of array set in the job template does not match length of retrieved values")
			} else {
				for i := range arg {
					if arg[i] != garg[i] {
						t.Errorf("Values are not the same: %s vs %s", arg[i], garg[i])
					}
				}
			}
		}
	}
}
func testStringSetter(t *testing.T, f func(string) error, arg string, g func() (string, error)) {
	if err := f(arg); err != nil {
		t.Error(err)
	} else {
		garg, gerr := g()
		if gerr != nil {
			t.Error(gerr)
		} else {
			if arg != garg {
				t.Errorf("Value is not the same: %s vs %s", arg, garg)
			}
		}
	}
}
func testDurationSetter(t *testing.T, f func(time.Duration) error, arg time.Duration, g func() (time.Duration, error)) {
	if err := f(arg); err != nil {
		t.Error(err)
	} else {
		garg, gerr := g()
		if gerr != nil {
			t.Error(gerr)
		} else {
			if arg.String() != garg.String() {
				t.Errorf("Value is not the same: %s vs %s", arg, garg)
			}
		}
	}
}
func TestJobTemplate(t *testing.T) {
	if s, err := MakeSession(); err != nil {
		t.Fatalf("Error during MakeSession(): %s\n", err)
	} else {
		defer s.Exit()
		jt, errJT := s.AllocateJobTemplate()
		if errJT != nil {
			t.Fatalf("Error during AllocateJobTemplate(): %s\n", errJT)
		}
		testVectorSetter(t, jt.SetArgs, []string{"arg1", "arg2"}, jt.Args)
		testVectorSetter(t, jt.SetEmail, []string{"a@b.c", "c@d.a"}, jt.Email)
		testVectorSetter(t, jt.SetEnv, []string{"LD_LIBRARY_PATH", "PATH"}, jt.Env)
		jt.SetJobSubmissionState(HoldState)
		if state, _ := jt.JobSubmissionState(); state != HoldState {
			t.Errorf("Error when setting JobSubmissionState.")
		}
		testStringSetter(t, jt.SetWD, "/", jt.WD)
		testStringSetter(t, jt.SetNativeSpecification, "-binding linear:1", jt.NativeSpecification)
		testStringSetter(t, jt.SetJobName, "MY_TEST_JOB", jt.JobName)
		if false {
			duration := time.Second * 77
			testDurationSetter(t, jt.SetHardWallclockTimeLimit, duration, jt.HardWallclockTimeLimit)
			testDurationSetter(t, jt.SetSoftWallclockTimeLimit, duration, jt.SoftWallclockTimeLimit)
			testDurationSetter(t, jt.SetHardRunDurationLimit, duration, jt.HardRunDurationLimit)
			testDurationSetter(t, jt.SetSoftRunDurationLimit, duration, jt.SoftRunDurationLimit)
		}
		if e := jt.SetBlockEmail(true); e != nil {
			t.Errorf("Error during SetBlockEmail(true): %s", e)
		} else {
			if em, e2 := jt.BlockEmail(); e2 != nil {
				t.Errorf("Error during BlockEmail(): %s", e2)
			} else {
				if em != true {
					t.Error("SetBlockEmail() set to true but BlocEmail() returns false")
				}
			}
		}
	}
}
func TestGetVectorAttributeNames(t *testing.T) {
	if s, err := MakeSession(); err != nil {
		t.Fatalf("Error during MakeSession(): %s\n", err)
	} else {
		defer s.Exit()
		names, err := s.GetVectorAttributeNames()
		if err != nil {
			t.Errorf("Error during calling GetVectorAttributeNames(): %s", err)
		} else {
			t.Logf("Supported job template vector attributes: %v\n", names)
		}
	}
}
func TestGetAttributeNames(t *testing.T) {
	if s, err := MakeSession(); err != nil {
		t.Fatalf("Error during MakeSession(): %s\n", err)
	} else {
		defer s.Exit()
		names, err := s.GetAttributeNames()
		if err != nil {
			t.Errorf("Error during calling GetAttributeNames(): %s", err)
		} else {
			t.Logf("Supported job template attributes: %v\n", names)
		}
	}
}