-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed Issue 80: Modified the test framework for tink repo
This framework was written a while ago but is commented and there have been a lot of changes since then. 1. Remove the target concepts completely 2. Changed the way of writting templates 3. Changed the way of creating workflows 4. Generating certs are not the part of docker-compose anymore TODO: This framework works well for single worker. There are few changes required in the framework to make it work for multiple workers
- Loading branch information
parauliya
committed
Jun 18, 2020
1 parent
db1c9c2
commit b678d32
Showing
14 changed files
with
268 additions
and
344 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,5 +1,2 @@ | ||
FROM bash | ||
ADD hello_world.sh /bin/hello_world.sh | ||
RUN chmod +x /bin/hello_world.sh | ||
#CMD echo '{"action_01": "data_01"}' > /workflow/data | ||
ENTRYPOINT [ "/bin/hello_world.sh" ] | ||
CMD echo '{"action_01": "data_01"}' > /workflow/data |
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
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
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
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 |
---|---|---|
@@ -1,72 +1,73 @@ | ||
package e2e | ||
|
||
//import ( | ||
// "os" | ||
// "time" | ||
// "testing" | ||
// | ||
// "github.com/tinkerbell/tink/client" | ||
// "github.com/tinkerbell/tink/protos/workflow" | ||
// "github.com/tinkerbell/tink/test/framework" | ||
// "github.com/sirupsen/logrus" | ||
//) | ||
// | ||
//var log *logrus.Logger = framework.Log | ||
// | ||
//func TestMain(m *testing.M) { | ||
// log.Infoln("########Creating Setup########") | ||
// time.Sleep(10 * time.Second) | ||
// err := framework.StartStack() | ||
// if err != nil { | ||
// os.Exit(1) | ||
// } | ||
// os.Setenv("TINKERBELL_GRPC_AUTHORITY", "127.0.0.1:42113") | ||
// os.Setenv("TINKERBELL_CERT_URL", "http://127.0.0.1:42114/cert") | ||
// client.Setup() | ||
// log.Infoln("########Setup Created########") | ||
// | ||
// log.Infoln("Creating hardware inventory") | ||
// //push hardware data into hardware table | ||
// hwData := []string{"hardware_1.json", "hardware_2.json"} | ||
// err = framework.PushHardwareData(hwData) | ||
// if err != nil { | ||
// log.Errorln("Failed to push hardware inventory : ", err) | ||
// os.Exit(2) | ||
// } | ||
// log.Infoln("Hardware inventory created") | ||
// | ||
// log.Infoln("########Starting Tests########") | ||
// status := m.Run() | ||
// log.Infoln("########Finished Tests########") | ||
// log.Infoln("########Removing setup########") | ||
// //err = framework.TearDown() | ||
// if err != nil { | ||
// os.Exit(3) | ||
// } | ||
// log.Infoln("########Setup removed########") | ||
// os.Exit(status) | ||
//} | ||
// | ||
//var testCases = map[string]struct { | ||
// hardware string | ||
// template string | ||
// workers int64 | ||
// expected workflow.ActionState | ||
// ephData string | ||
//}{ | ||
// "testWfWithWorker": {"hardware_1.json", "sample_1", 1, workflow.ActionState_ACTION_SUCCESS, `{"action_02": "data_02"}`}, | ||
// "testWfTimeout": {"hardware_1.json", "sample_2", 1, workflow.ActionState_ACTION_TIMEOUT, `{"action_01": "data_01"}`}, | ||
// //"testWfWithMultiWorkers": {"hardware_1.json", "sample_3", 2, workflow.ActionState_ACTION_SUCCESS, `{"action_01": "data_01"}`}, | ||
//} | ||
// | ||
//var runTestMap = map[string]func(t *testing.T){ | ||
// "testWfWithWorker": TestWfWithWorker, | ||
// "testWfTimeout": TestWfTimeout, | ||
// //"testWfWithMultiWorkers": TestWfWithMultiWorkers, | ||
//} | ||
// | ||
//func TestE2E(t *testing.T) { | ||
// for key, val := range runTestMap { | ||
// t.Run(key, val) | ||
// } | ||
//} | ||
import ( | ||
"os" | ||
"testing" | ||
"time" | ||
|
||
"github.com/sirupsen/logrus" | ||
"github.com/tinkerbell/tink/client" | ||
"github.com/tinkerbell/tink/protos/workflow" | ||
"github.com/tinkerbell/tink/test/framework" | ||
) | ||
|
||
var log *logrus.Logger = framework.Log | ||
|
||
func TestMain(m *testing.M) { | ||
log.Infoln("########Creating Setup########") | ||
time.Sleep(10 * time.Second) | ||
err := framework.StartStack() | ||
if err != nil { | ||
os.Exit(1) | ||
} | ||
os.Setenv("TINKERBELL_GRPC_AUTHORITY", "127.0.0.1:42113") | ||
os.Setenv("TINKERBELL_CERT_URL", "http://127.0.0.1:42114/cert") | ||
client.Setup() | ||
log.Infoln("########Setup Created########") | ||
|
||
log.Infoln("Creating hardware inventory") | ||
//push hardware data into hardware table | ||
hwData := []string{"hardware_1.json", "hardware_2.json"} | ||
err = framework.PushHardwareData(hwData) | ||
if err != nil { | ||
log.Errorln("Failed to push hardware inventory : ", err) | ||
os.Exit(2) | ||
} | ||
log.Infoln("Hardware inventory created") | ||
|
||
log.Infoln("########Starting Tests########") | ||
status := m.Run() | ||
log.Infoln("########Finished Tests########") | ||
log.Infoln("########Removing setup########") | ||
//err = framework.TearDown() | ||
if err != nil { | ||
os.Exit(3) | ||
} | ||
log.Infoln("########Setup removed########") | ||
os.Exit(status) | ||
} | ||
|
||
var testCases = map[string]struct { | ||
hardware string | ||
hMAC string | ||
template string | ||
workers int64 | ||
expected workflow.ActionState | ||
ephData string | ||
}{ | ||
"testWfWithWorker": {"hardware_1.json", "98:03:9b:89:d7:ba", "sample_1", 1, workflow.ActionState_ACTION_SUCCESS, `{"action_02": "data_02"}`}, | ||
"testWfTimeout": {"hardware_1.json", "98:03:9b:89:d7:ba", "sample_2", 1, workflow.ActionState_ACTION_TIMEOUT, `{"action_01": "data_01"}`}, | ||
//"testWfWithMultiWorkers": {"hardware_1.json", "sample_3", 2, workflow.ActionState_ACTION_SUCCESS, `{"action_01": "data_01"}`}, | ||
} | ||
|
||
var runTestMap = map[string]func(t *testing.T){ | ||
"testWfWithWorker": TestWfWithWorker, | ||
"testWfTimeout": TestWfTimeout, | ||
//"testWfWithMultiWorkers": TestWfWithMultiWorkers, | ||
} | ||
|
||
func TestE2E(t *testing.T) { | ||
for key, val := range runTestMap { | ||
t.Run(key, val) | ||
} | ||
} |
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
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
Oops, something went wrong.