|
1 | 1 | package main_test |
2 | 2 |
|
3 | 3 | import ( |
4 | | - "fmt" |
5 | 4 | "os" |
6 | 5 | "os/exec" |
7 | | - "time" |
8 | 6 |
|
9 | 7 | . "github.com/onsi/ginkgo/v2" |
10 | 8 | . "github.com/onsi/gomega" |
@@ -66,73 +64,4 @@ var _ = Describe("Main", func() { |
66 | 64 | Entry("When the FABRIC_K8S_BUILDER_OBJECT_NAME_PREFIX starts with a number", "1prefix", `run \[\d+\]: The FABRIC_K8S_BUILDER_OBJECT_NAME_PREFIX environment variable must be a valid DNS-1035 label: a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character`), |
67 | 65 | Entry("When the FABRIC_K8S_BUILDER_OBJECT_NAME_PREFIX starts with a dash", "-prefix", `run \[\d+\]: The FABRIC_K8S_BUILDER_OBJECT_NAME_PREFIX environment variable must be a valid DNS-1035 label: a DNS-1035 label must consist of lower case alphanumeric characters or '-', start with an alphabetic character, and end with an alphanumeric character`), |
68 | 66 | ) |
69 | | - |
70 | | - It( |
71 | | - "should start a chaincode job using the supplied configuration environment variables", |
72 | | - Label("kind"), |
73 | | - func() { |
74 | | - homedir, err := os.UserHomeDir() |
75 | | - Expect(err).NotTo(HaveOccurred()) |
76 | | - |
77 | | - args := []string{"./testdata/validimage", "./testdata/validchaincode"} |
78 | | - command := exec.Command(runCmdPath, args...) |
79 | | - command.Env = append(os.Environ(), |
80 | | - fmt.Sprintf("KUBECONFIG_PATH=%s/.kube/config", homedir), |
81 | | - "CORE_PEER_ID=core-peer-id-abcdefghijklmnopqrstuvwxyz-0123456789", |
82 | | - "FABRIC_K8S_BUILDER_DEBUG=true", |
83 | | - "FABRIC_K8S_BUILDER_NAMESPACE=chaincode", |
84 | | - "FABRIC_K8S_BUILDER_SERVICE_ACCOUNT=chaincode", |
85 | | - ) |
86 | | - session, err := gexec.Start(command, GinkgoWriter, GinkgoWriter) |
87 | | - Expect(err).NotTo(HaveOccurred()) |
88 | | - |
89 | | - Eventually(session).ShouldNot(gexec.Exit()) |
90 | | - Eventually( |
91 | | - session.Err, |
92 | | - ).Should(gbytes.Say(`run \[\d+\] DEBUG: FABRIC_K8S_BUILDER_NAMESPACE=chaincode`)) |
93 | | - Eventually( |
94 | | - session.Err, |
95 | | - ).Should(gbytes.Say(`run \[\d+\] DEBUG: FABRIC_K8S_BUILDER_SERVICE_ACCOUNT=chaincode`)) |
96 | | - Eventually( |
97 | | - session.Err, |
98 | | - ).Should(gbytes.Say(`run \[\d+\]: Running chaincode ID CHAINCODE_LABEL:6f98c4bb29414771312eddd1a813eef583df2121c235c4797792f141a46d4b45 with kubernetes job chaincode/hlfcc-chaincodelabel-piihcaj6ryttc`)) |
99 | | - |
100 | | - waitArgs := []string{ |
101 | | - "wait", |
102 | | - "--for=jsonpath=.status.ready=1", |
103 | | - "job", |
104 | | - "--timeout=120s", |
105 | | - "--namespace=chaincode", |
106 | | - "-l", |
107 | | - "fabric-builder-k8s-cclabel=CHAINCODE_LABEL", |
108 | | - } |
109 | | - waitCommand := exec.Command("kubectl", waitArgs...) |
110 | | - waitSession, err := gexec.Start(waitCommand, GinkgoWriter, GinkgoWriter) |
111 | | - Expect(err).NotTo(HaveOccurred()) |
112 | | - Eventually(waitSession).WithTimeout(240 * time.Second).Should(gexec.Exit(0)) |
113 | | - |
114 | | - descArgs := []string{ |
115 | | - "describe", |
116 | | - "job", |
117 | | - "--namespace=chaincode", |
118 | | - "-l", |
119 | | - "fabric-builder-k8s-cclabel=CHAINCODE_LABEL", |
120 | | - } |
121 | | - descCommand := exec.Command("kubectl", descArgs...) |
122 | | - descSession, err := gexec.Start(descCommand, GinkgoWriter, GinkgoWriter) |
123 | | - Expect(err).NotTo(HaveOccurred()) |
124 | | - |
125 | | - Eventually(descSession).Should(gexec.Exit(0)) |
126 | | - Eventually(descSession.Out).Should(gbytes.Say(`Namespace:\s+chaincode`)) |
127 | | - Eventually( |
128 | | - descSession.Out, |
129 | | - ).Should(gbytes.Say(`fabric-builder-k8s-ccid:\s+CHAINCODE_LABEL:6f98c4bb29414771312eddd1a813eef583df2121c235c4797792f141a46d4b45`)) |
130 | | - Eventually(descSession.Out).Should(gbytes.Say(`fabric-builder-k8s-mspid:\s+MSPID`)) |
131 | | - Eventually(descSession.Out).Should(gbytes.Say(`fabric-builder-k8s-peeraddress:\s+PEER_ADDRESS`)) |
132 | | - Eventually(descSession.Out).Should(gbytes.Say(`fabric-builder-k8s-peerid:\s+core-peer-id-abcdefghijklmnopqrstuvwxyz-0123456789`)) |
133 | | - Eventually(descSession.Out).Should(gbytes.Say(`CORE_CHAINCODE_ID_NAME:\s+CHAINCODE_LABEL:6f98c4bb29414771312eddd1a813eef583df2121c235c4797792f141a46d4b45`)) |
134 | | - Eventually(descSession.Out).Should(gbytes.Say(`CORE_PEER_ADDRESS:\s+PEER_ADDRESS`)) |
135 | | - Eventually(descSession.Out).Should(gbytes.Say(`CORE_PEER_LOCALMSPID:\s+MSPID`)) |
136 | | - }, |
137 | | - ) |
138 | 67 | }) |
0 commit comments